From 8eb8fa3725d8d857c58fcb0b7d64a85d8b7bebdc Mon Sep 17 00:00:00 2001 From: Carlos Martín Nieto Date: Sat, 27 Aug 2016 21:35:26 +0200 Subject: Also remove a pkg-config directive that snuck in --- git.go | 1 - 1 file changed, 1 deletion(-) (limited to 'git.go') diff --git a/git.go b/git.go index ed891e6..a3c40e3 100644 --- a/git.go +++ b/git.go @@ -3,7 +3,6 @@ package git /* #include #include -#cgo pkg-config: libgit2 #if LIBGIT2_VER_MAJOR != 0 || LIBGIT2_VER_MINOR != 24 # error "Invalid libgit2 version; this git2go supports libgit2 v0.24" -- cgit v1.2.3 From a37f7f30ff94e32b20866cf2fa28496c60826278 Mon Sep 17 00:00:00 2001 From: Carlos Martín Nieto Date: Mon, 31 Oct 2016 21:12:03 +0100 Subject: Panic if libgit2 is not thread-aware Go calling C is inherently multi-threaded. If libgit2 cannot handle threading, then we're going to crash at some random point. Crash right at the start so we know what's happening. --- git.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'git.go') diff --git a/git.go b/git.go index a3c40e3..53b1a12 100644 --- a/git.go +++ b/git.go @@ -124,6 +124,15 @@ func init() { C.git_libgit2_init() + // Due to the multithreaded nature of Go and its interaction with + // calling C functions, we cannot work with a library that was not built + // with multi-threading support. The most likely outcome is a segfault + // or panic at an incomprehensible time, so let's make it easy by + // panicking right here. + if Features()&FeatureThreads == 0 { + panic("libgit2 was not built with threading support") + } + // This is not something we should be doing, as we may be // stomping all over someone else's setup. The user should do // this themselves or use some binding/wrapper which does it -- cgit v1.2.3 From 9c5fb973fcc1acd7cd55e120fefef101be46e60a Mon Sep 17 00:00:00 2001 From: Carlos Martín Nieto Date: Sat, 19 Dec 2015 01:30:28 +0100 Subject: Get rid of the with-static.sh script CGO can perform variable substitution in the directives, so we don't need to use a script to set up the variables; we can let the go tool do it for us. --- Makefile | 4 ++-- README.md | 11 +++++------ git.go | 4 ++++ script/with-static.sh | 12 ------------ 4 files changed, 11 insertions(+), 20 deletions(-) delete mode 100755 script/with-static.sh (limited to 'git.go') diff --git a/Makefile b/Makefile index 3040857..39fc558 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ build-libgit2: test: build-libgit2 go run script/check-MakeGitError-thread-lock.go - ./script/with-static.sh go test ./... + go test ./... install: build-libgit2 - ./script/with-static.sh go install ./... + go install ./... diff --git a/README.md b/README.md index 315032f..bd918d6 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ to use a version of git2go which will work against libgit2 v0.22 and dynamically import "github.com/libgit2/git2go" -to use the version which works against the latest release. +to use the 'master' branch, which works against the latest release of libgit2, whichever that one is at the time. ### From `next` @@ -44,15 +44,14 @@ libgit2 uses OpenSSL and LibSSH2 for performing encrypted network connections. F Running the tests ----------------- -For the stable version, `go test` will work as usual. For the `next` branch, similarly to installing, running the tests requires linking against the local libgit2 library, so the Makefile provides a wrapper +For the stable version, `go test` will work as usual. For the `next` branch, similarly to installing, running the tests requires building a local libgit2 library, so the Makefile provides a wrapper that makes sure it's built make test -Alternatively, if you want to pass arguments to `go test`, you can use the script that sets it all up +Alternatively, you can build the library manually first and then run the tests - ./script/with-static.sh go test -v - -which will run the specified arguments with the correct environment variables. + ./script/build-libgit2-static.sh + go test -v License ------- diff --git a/git.go b/git.go index 53b1a12..77394cf 100644 --- a/git.go +++ b/git.go @@ -1,6 +1,10 @@ package git /* +#cgo CFLAGS: -I${SRCDIR}/vendor/libgit2/include +#cgo LDFLAGS: -L${SRCDIR}/vendor/libgit2/build/ -lgit2 +#cgo windows LDFLAGS: -lwinhttp +#cgo !windows pkg-config: --static ${SRCDIR}/vendor/libgit2/build/libgit2.pc #include #include diff --git a/script/with-static.sh b/script/with-static.sh deleted file mode 100755 index 3f60e31..0000000 --- a/script/with-static.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -set -ex - -export BUILD="$PWD/vendor/libgit2/build" -export PCFILE="$BUILD/libgit2.pc" - -FLAGS=$(pkg-config --static --libs $PCFILE) || exit 1 -export CGO_LDFLAGS="$BUILD/libgit2.a -L$BUILD ${FLAGS}" -export CGO_CFLAGS="-I$PWD/vendor/libgit2/include" - -$@ -- cgit v1.2.3 From a41e2b66449f05093de71f8debc71092f0a8117e Mon Sep 17 00:00:00 2001 From: Carlos Martín Nieto Date: Sat, 19 Nov 2016 15:09:41 +0100 Subject: Update to 0.25-rc1 --- git.go | 4 ++-- vendor/libgit2 | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'git.go') diff --git a/git.go b/git.go index 77394cf..cb973ee 100644 --- a/git.go +++ b/git.go @@ -8,8 +8,8 @@ package git #include #include -#if LIBGIT2_VER_MAJOR != 0 || LIBGIT2_VER_MINOR != 24 -# error "Invalid libgit2 version; this git2go supports libgit2 v0.24" +#if LIBGIT2_VER_MAJOR != 0 || LIBGIT2_VER_MINOR != 25 +# error "Invalid libgit2 version; this git2go supports libgit2 v0.25" #endif */ diff --git a/vendor/libgit2 b/vendor/libgit2 index a051ee3..ae5838f 160000 --- a/vendor/libgit2 +++ b/vendor/libgit2 @@ -1 +1 @@ -Subproject commit a051ee31f2a3790410c2b482611f691135d2eae0 +Subproject commit ae5838f118a4819e608990a815bf8fc482be5772 -- cgit v1.2.3