Skip to content

Commit 018647f

Browse files
committed
libgit2 v1.2.0 #major
This commit introduces libgit2 v1.2.0 to git2go, which brings a large number of [bugfixes and features](https://github.com/libgit2/libgit2/releases/tag/v1.2.0). This also marks the start of the v32 release.
1 parent b78bde3 commit 018647f

15 files changed

+211
-78
lines changed

.github/workflows/backport.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
branch: [ 'release-1.0', 'release-0.28', 'release-0.27' ]
15+
branch: [ 'release-1.1', 'release-1.0', 'release-0.28', 'release-0.27' ]
1616

1717
runs-on: ubuntu-20.04
1818

.github/workflows/ci.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ jobs:
6262
fail-fast: false
6363
matrix:
6464
libgit2:
65-
- 'v1.1.0'
66-
- 'v1.2.0'
65+
- '109b4c887ffb63962c7017a66fc4a1f48becb48e' # v1.2.0 with a fixed symbol
6766
name: Go (system-wide, dynamic)
6867

6968
runs-on: ubuntu-20.04

Build_bundled_static.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build static && !system_libgit2
12
// +build static,!system_libgit2
23

34
package git
@@ -9,8 +10,8 @@ package git
910
#cgo CFLAGS: -DLIBGIT2_STATIC
1011
#include <git2.h>
1112
12-
#if LIBGIT2_VER_MAJOR != 1 || LIBGIT2_VER_MINOR < 1 || LIBGIT2_VER_MINOR > 2
13-
# error "Invalid libgit2 version; this git2go supports libgit2 between v1.1.0 and v1.2.0"
13+
#if LIBGIT2_VER_MAJOR != 1 || LIBGIT2_VER_MINOR < 2 || LIBGIT2_VER_MINOR > 2
14+
# error "Invalid libgit2 version; this git2go supports libgit2 between v1.2.0 and v1.2.0"
1415
#endif
1516
*/
1617
import "C"

Build_system_dynamic.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build !static
12
// +build !static
23

34
package git
@@ -7,8 +8,8 @@ package git
78
#cgo CFLAGS: -DLIBGIT2_DYNAMIC
89
#include <git2.h>
910
10-
#if LIBGIT2_VER_MAJOR != 1 || LIBGIT2_VER_MINOR < 1 || LIBGIT2_VER_MINOR > 2
11-
# error "Invalid libgit2 version; this git2go supports libgit2 between v1.1.0 and v1.2.0"
11+
#if LIBGIT2_VER_MAJOR != 1 || LIBGIT2_VER_MINOR < 2 || LIBGIT2_VER_MINOR > 2
12+
# error "Invalid libgit2 version; this git2go supports libgit2 between v1.2.0 and v1.2.0"
1213
#endif
1314
*/
1415
import "C"

Build_system_static.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build static && system_libgit2
12
// +build static,system_libgit2
23

34
package git
@@ -7,8 +8,8 @@ package git
78
#cgo CFLAGS: -DLIBGIT2_STATIC
89
#include <git2.h>
910
10-
#if LIBGIT2_VER_MAJOR != 1 || LIBGIT2_VER_MINOR < 1 || LIBGIT2_VER_MINOR > 2
11-
# error "Invalid libgit2 version; this git2go supports libgit2 between v1.1.0 and v1.2.0"
11+
#if LIBGIT2_VER_MAJOR != 1 || LIBGIT2_VER_MINOR < 2 || LIBGIT2_VER_MINOR > 2
12+
# error "Invalid libgit2 version; this git2go supports libgit2 between v1.2.0 and v1.2.0"
1213
#endif
1314
*/
1415
import "C"

README.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,21 @@ Due to the fact that Go 1.11 module versions have semantic meaning and don't nec
1010

1111
| libgit2 | git2go |
1212
|---------|---------------|
13-
| main | (will be v32) |
13+
| main | (will be v33) |
14+
| 1.2 | v32 |
1415
| 1.1 | v31 |
1516
| 1.0 | v30 |
1617
| 0.99 | v29 |
1718
| 0.28 | v28 |
1819
| 0.27 | v27 |
1920

20-
You can import them in your project with the version's major number as a suffix. For example, if you have libgit2 v1.1 installed, you'd import git2go v31 with:
21+
You can import them in your project with the version's major number as a suffix. For example, if you have libgit2 v1.2 installed, you'd import git2go v32 with:
2122

2223
```sh
23-
go get github.com/libgit2/git2go/v31
24+
go get github.com/libgit2/git2go/v32
2425
```
2526
```go
26-
import "github.com/libgit2/git2go/v31"
27+
import "github.com/libgit2/git2go/v32"
2728
```
2829

2930
which will ensure there are no sudden changes to the API.
@@ -44,10 +45,10 @@ This project wraps the functionality provided by libgit2. If you're using a vers
4445

4546
### Versioned branch, dynamic linking
4647

47-
When linking dynamically against a released version of libgit2, install it via your system's package manager. CGo will take care of finding its pkg-config file and set up the linking. Import via Go modules, e.g. to work against libgit2 v1.1
48+
When linking dynamically against a released version of libgit2, install it via your system's package manager. CGo will take care of finding its pkg-config file and set up the linking. Import via Go modules, e.g. to work against libgit2 v1.2
4849

4950
```go
50-
import "github.com/libgit2/git2go/v31"
51+
import "github.com/libgit2/git2go/v32"
5152
```
5253

5354
### Versioned branch, static linking
@@ -77,7 +78,7 @@ In order to let Go pass the correct flags to `pkg-config`, `-tags static` needs
7778

7879
One thing to take into account is that since Go expects the `pkg-config` file to be within the same directory where `make install-static` was called, so the `go.mod` file may need to have a [`replace` directive](https://github.com/golang/go/wiki/Modules#when-should-i-use-the-replace-directive) so that the correct setup is achieved. So if `git2go` is checked out at `$GOPATH/src/github.com/libgit2/git2go` and your project at `$GOPATH/src/github.com/my/project`, the `go.mod` file of `github.com/my/project` might need to have a line like
7980

80-
replace github.com/libgit2/git2go/v31 ../../libgit2/git2go
81+
replace github.com/libgit2/git2go/v32 ../../libgit2/git2go
8182

8283
Parallelism and network operations
8384
----------------------------------

commit.go

+20-3
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ func (c *Commit) Message() string {
3737
return ret
3838
}
3939

40-
func (c *Commit) MessageEncoding() string {
41-
ret := C.GoString(C.git_commit_message_encoding(c.cast_ptr))
40+
func (c *Commit) MessageEncoding() MessageEncoding {
41+
ptr := C.git_commit_message_encoding(c.cast_ptr)
42+
if ptr == nil {
43+
return MessageEncodingUTF8
44+
}
45+
ret := C.GoString(ptr)
4246
runtime.KeepAlive(c)
43-
return ret
47+
return MessageEncoding(ret)
4448
}
4549

4650
func (c *Commit) RawMessage() string {
@@ -64,6 +68,19 @@ func (c *Commit) ContentToSign() string {
6468
// CommitSigningCallback defines a function type that takes some data to sign and returns (signature, signature_field, error)
6569
type CommitSigningCallback func(string) (signature, signatureField string, err error)
6670

71+
// CommitCreateCallback defines a function type that is called when another
72+
// function is going to create commits (for example, Rebase) to allow callers
73+
// to override the commit creation behavior. For example, users may wish to
74+
// sign commits by providing this information to Repository.CreateCommitBuffer,
75+
// signing that buffer, then calling Repository.CreateCommitWithSignature.
76+
type CommitCreateCallback func(
77+
author, committer *Signature,
78+
messageEncoding MessageEncoding,
79+
message string,
80+
tree *Tree,
81+
parents ...*Commit,
82+
) (oid *Oid, err error)
83+
6784
// WithSignatureUsing creates a new signed commit from this one using the given signing callback
6885
func (c *Commit) WithSignatureUsing(f CommitSigningCallback) (*Oid, error) {
6986
signature, signatureField, err := f(c.ContentToSign())

deprecated.go

+16
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,22 @@ func SubmoduleVisitor(csub unsafe.Pointer, name *C.char, handle unsafe.Pointer)
237237
return C.int(ErrorCodeOK)
238238
}
239239

240+
// reference.go
241+
242+
// Deprecated: ReferenceIsValidName is a deprecated alias of ReferenceNameIsValid.
243+
func ReferenceIsValidName(name string) bool {
244+
valid, _ := ReferenceNameIsValid(name)
245+
return valid
246+
}
247+
248+
// remote.go
249+
250+
// Deprecated: RemoteIsValidName is a deprecated alias of RemoteNameIsValid.
251+
func RemoteIsValidName(name string) bool {
252+
valid, _ := RemoteNameIsValid(name)
253+
return valid
254+
}
255+
240256
// tree.go
241257

242258
// Deprecated: CallbackGitTreeWalk is not used.

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/libgit2/git2go/v31
1+
module github.com/libgit2/git2go/v32
22

33
go 1.13
44

0 commit comments

Comments
 (0)