summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--branch.go4
-rw-r--r--checkout.go2
-rw-r--r--commit.go4
-rw-r--r--config.go12
-rw-r--r--config_test.go2
-rw-r--r--describe.go2
-rw-r--r--diff.go2
-rw-r--r--git.go2
-rw-r--r--merge.go24
-rw-r--r--note.go2
-rw-r--r--object.go2
-rw-r--r--odb.go4
-rw-r--r--odb_test.go16
-rw-r--r--patch.go2
-rw-r--r--settings.go2
-rw-r--r--signature.go2
m---------vendor/libgit20
17 files changed, 58 insertions, 26 deletions
diff --git a/branch.go b/branch.go
index d6e7a53..6f79825 100644
--- a/branch.go
+++ b/branch.go
@@ -208,7 +208,7 @@ func (repo *Repository) RemoteName(canonicalBranchName string) (string, error) {
if ret < 0 {
return "", MakeGitError(ret)
}
- defer C.git_buf_free(&nameBuf)
+ defer C.git_buf_dispose(&nameBuf)
return C.GoString(nameBuf.ptr), nil
}
@@ -256,7 +256,7 @@ func (repo *Repository) UpstreamName(canonicalBranchName string) (string, error)
if ret < 0 {
return "", MakeGitError(ret)
}
- defer C.git_buf_free(&nameBuf)
+ defer C.git_buf_dispose(&nameBuf)
return C.GoString(nameBuf.ptr), nil
}
diff --git a/checkout.go b/checkout.go
index db3118f..2b12058 100644
--- a/checkout.go
+++ b/checkout.go
@@ -35,7 +35,7 @@ const (
CheckoutDontUpdateIndex CheckoutStrategy = C.GIT_CHECKOUT_DONT_UPDATE_INDEX // Normally checkout updates index entries as it goes; this stops that
CheckoutNoRefresh CheckoutStrategy = C.GIT_CHECKOUT_NO_REFRESH // Don't refresh index/config/etc before doing checkout
CheckoutSkipUnmerged CheckoutStrategy = C.GIT_CHECKOUT_SKIP_UNMERGED // Allow checkout to skip unmerged files
- CheckoutUserOurs CheckoutStrategy = C.GIT_CHECKOUT_USE_OURS // For unmerged files, checkout stage 2 from index
+ CheckoutUseOurs CheckoutStrategy = C.GIT_CHECKOUT_USE_OURS // For unmerged files, checkout stage 2 from index
CheckoutUseTheirs CheckoutStrategy = C.GIT_CHECKOUT_USE_THEIRS // For unmerged files, checkout stage 3 from index
CheckoutDisablePathspecMatch CheckoutStrategy = C.GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH // Treat pathspec as simple list of exact match file paths
CheckoutSkipLockedDirectories CheckoutStrategy = C.GIT_CHECKOUT_SKIP_LOCKED_DIRECTORIES // Ignore directories in use, they will be left empty
diff --git a/commit.go b/commit.go
index 223b093..0ab720d 100644
--- a/commit.go
+++ b/commit.go
@@ -37,10 +37,10 @@ func (c *Commit) RawMessage() string {
func (c *Commit) ExtractSignature() (string, string, error) {
var c_signed C.git_buf
- defer C.git_buf_free(&c_signed)
+ defer C.git_buf_dispose(&c_signed)
var c_signature C.git_buf
- defer C.git_buf_free(&c_signature)
+ defer C.git_buf_dispose(&c_signature)
oid := c.Id()
repo := C.git_commit_owner(c.cast_ptr)
diff --git a/config.go b/config.go
index ab9af38..7260089 100644
--- a/config.go
+++ b/config.go
@@ -134,7 +134,7 @@ func (c *Config) LookupString(name string) (string, error) {
if ret < 0 {
return "", MakeGitError(ret)
}
- defer C.git_buf_free(&valBuf)
+ defer C.git_buf_dispose(&valBuf)
return C.GoString(valBuf.ptr), nil
}
@@ -344,7 +344,7 @@ func (c *Config) OpenLevel(parent *Config, level ConfigLevel) (*Config, error) {
}
// OpenOndisk creates a new config instance containing a single on-disk file
-func OpenOndisk(parent *Config, path string) (*Config, error) {
+func OpenOndisk(path string) (*Config, error) {
cpath := C.CString(path)
defer C.free(unsafe.Pointer(cpath))
@@ -390,7 +390,7 @@ func (iter *ConfigIterator) Free() {
func ConfigFindGlobal() (string, error) {
var buf C.git_buf
- defer C.git_buf_free(&buf)
+ defer C.git_buf_dispose(&buf)
runtime.LockOSThread()
defer runtime.UnlockOSThread()
@@ -405,7 +405,7 @@ func ConfigFindGlobal() (string, error) {
func ConfigFindSystem() (string, error) {
var buf C.git_buf
- defer C.git_buf_free(&buf)
+ defer C.git_buf_dispose(&buf)
runtime.LockOSThread()
defer runtime.UnlockOSThread()
@@ -420,7 +420,7 @@ func ConfigFindSystem() (string, error) {
func ConfigFindXDG() (string, error) {
var buf C.git_buf
- defer C.git_buf_free(&buf)
+ defer C.git_buf_dispose(&buf)
runtime.LockOSThread()
defer runtime.UnlockOSThread()
@@ -438,7 +438,7 @@ func ConfigFindXDG() (string, error) {
// Look for the file in %PROGRAMDATA%\Git\config used by portable git.
func ConfigFindProgramdata() (string, error) {
var buf C.git_buf
- defer C.git_buf_free(&buf)
+ defer C.git_buf_dispose(&buf)
runtime.LockOSThread()
defer runtime.UnlockOSThread()
diff --git a/config_test.go b/config_test.go
index 196d4ad..398236e 100644
--- a/config_test.go
+++ b/config_test.go
@@ -13,7 +13,7 @@ func setupConfig() (*Config, error) {
err error
)
- c, err = OpenOndisk(nil, tempConfig)
+ c, err = OpenOndisk(tempConfig)
if err != nil {
return nil, err
}
diff --git a/describe.go b/describe.go
index 0b75076..f7036df 100644
--- a/describe.go
+++ b/describe.go
@@ -212,7 +212,7 @@ func (result *DescribeResult) Format(opts *DescribeFormatOptions) (string, error
if ecode < 0 {
return "", MakeGitError(ecode)
}
- defer C.git_buf_free(&resultBuf)
+ defer C.git_buf_dispose(&resultBuf)
return C.GoString(resultBuf.ptr), nil
}
diff --git a/diff.go b/diff.go
index 3088320..20eb9e8 100644
--- a/diff.go
+++ b/diff.go
@@ -246,7 +246,7 @@ const (
func (stats *DiffStats) String(format DiffStatsFormat,
width uint) (string, error) {
buf := C.git_buf{}
- defer C.git_buf_free(&buf)
+ defer C.git_buf_dispose(&buf)
runtime.LockOSThread()
defer runtime.UnlockOSThread()
diff --git a/git.go b/git.go
index 0925e45..a1c07f6 100644
--- a/git.go
+++ b/git.go
@@ -309,7 +309,7 @@ func Discover(start string, across_fs bool, ceiling_dirs []string) (string, erro
defer C.free(unsafe.Pointer(cstart))
var buf C.git_buf
- defer C.git_buf_free(&buf)
+ defer C.git_buf_dispose(&buf)
runtime.LockOSThread()
defer runtime.UnlockOSThread()
diff --git a/merge.go b/merge.go
index adc521a..bc672ce 100644
--- a/merge.go
+++ b/merge.go
@@ -344,9 +344,29 @@ type MergeFileFlags int
const (
MergeFileDefault MergeFileFlags = C.GIT_MERGE_FILE_DEFAULT
- MergeFileStyleMerge MergeFileFlags = C.GIT_MERGE_FILE_STYLE_MERGE
- MergeFileStyleDiff MergeFileFlags = C.GIT_MERGE_FILE_STYLE_DIFF3
+ // Create standard conflicted merge files
+ MergeFileStyleMerge MergeFileFlags = C.GIT_MERGE_FILE_STYLE_MERGE
+
+ // Create diff3-style files
+ MergeFileStyleDiff MergeFileFlags = C.GIT_MERGE_FILE_STYLE_DIFF3
+
+ // Condense non-alphanumeric regions for simplified diff file
MergeFileStyleSimplifyAlnum MergeFileFlags = C.GIT_MERGE_FILE_SIMPLIFY_ALNUM
+
+ // Ignore all whitespace
+ MergeFileIgnoreWhitespace MergeFileFlags = C.GIT_MERGE_FILE_IGNORE_WHITESPACE
+
+ // Ignore changes in amount of whitespace
+ MergeFileIgnoreWhitespaceChange MergeFileFlags = C.GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE
+
+ // Ignore whitespace at end of line
+ MergeFileIgnoreWhitespaceEOL MergeFileFlags = C.GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL
+
+ // Use the "patience diff" algorithm
+ MergeFileDiffPatience MergeFileFlags = C.GIT_MERGE_FILE_DIFF_PATIENCE
+
+ // Take extra time to find minimal diff
+ MergeFileDiffMinimal MergeFileFlags = C.GIT_MERGE_FILE_DIFF_MINIMAL
)
type MergeFileOptions struct {
diff --git a/note.go b/note.go
index 21bed57..9df1b9d 100644
--- a/note.go
+++ b/note.go
@@ -132,7 +132,7 @@ func (c *NoteCollection) DefaultRef() (string, error) {
}
ret := C.GoString(buf.ptr)
- C.git_buf_free(&buf)
+ C.git_buf_dispose(&buf)
return ret, nil
}
diff --git a/object.go b/object.go
index 5505e35..66a4618 100644
--- a/object.go
+++ b/object.go
@@ -67,7 +67,7 @@ func (o *Object) ShortId() (string, error) {
if ecode < 0 {
return "", MakeGitError(ecode)
}
- defer C.git_buf_free(&resultBuf)
+ defer C.git_buf_dispose(&resultBuf)
return C.GoString(resultBuf.ptr), nil
}
diff --git a/odb.go b/odb.go
index fa6779f..7ae108a 100644
--- a/odb.go
+++ b/odb.go
@@ -8,6 +8,7 @@ extern void _go_git_odb_backend_free(git_odb_backend *backend);
*/
import "C"
import (
+ "io"
"reflect"
"runtime"
"unsafe"
@@ -297,6 +298,9 @@ func (stream *OdbReadStream) Read(data []byte) (int, error) {
if ret < 0 {
return 0, MakeGitError(ret)
}
+ if ret == 0 {
+ return 0, io.EOF
+ }
header.Len = int(ret)
diff --git a/odb_test.go b/odb_test.go
index 8502c36..46acdba 100644
--- a/odb_test.go
+++ b/odb_test.go
@@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"io"
+ "io/ioutil"
"testing"
)
@@ -62,22 +63,29 @@ func TestOdbStream(t *testing.T) {
str := "hello, world!"
- stream, error := odb.NewWriteStream(int64(len(str)), ObjectBlob)
+ writeStream, error := odb.NewWriteStream(int64(len(str)), ObjectBlob)
checkFatal(t, error)
- n, error := io.WriteString(stream, str)
+ n, error := io.WriteString(writeStream, str)
checkFatal(t, error)
if n != len(str) {
t.Fatalf("Bad write length %v != %v", n, len(str))
}
- error = stream.Close()
+ error = writeStream.Close()
checkFatal(t, error)
expectedId, error := NewOid("30f51a3fba5274d53522d0f19748456974647b4f")
checkFatal(t, error)
- if stream.Id.Cmp(expectedId) != 0 {
+ if writeStream.Id.Cmp(expectedId) != 0 {
t.Fatal("Wrong data written")
}
+
+ readStream, error := odb.NewReadStream(&writeStream.Id)
+ checkFatal(t, error)
+ data, error := ioutil.ReadAll(readStream)
+ if str != string(data) {
+ t.Fatalf("Wrong data read %v != %v", str, string(data))
+ }
}
func TestOdbHash(t *testing.T) {
diff --git a/patch.go b/patch.go
index 7e6f71d..6a16b5f 100644
--- a/patch.go
+++ b/patch.go
@@ -51,7 +51,7 @@ func (patch *Patch) String() (string, error) {
if ecode < 0 {
return "", MakeGitError(ecode)
}
- defer C.git_buf_free(&buf)
+ defer C.git_buf_dispose(&buf)
return C.GoString(buf.ptr), nil
}
diff --git a/settings.go b/settings.go
index c7f1850..b9bc216 100644
--- a/settings.go
+++ b/settings.go
@@ -31,7 +31,7 @@ import (
func SearchPath(level ConfigLevel) (string, error) {
var buf C.git_buf
- defer C.git_buf_free(&buf)
+ defer C.git_buf_dispose(&buf)
runtime.LockOSThread()
defer runtime.UnlockOSThread()
diff --git a/signature.go b/signature.go
index 16964d2..220fe57 100644
--- a/signature.go
+++ b/signature.go
@@ -26,7 +26,7 @@ func newSignatureFromC(sig *C.git_signature) *Signature {
}
}
-// the offset in mintes, which is what git wants
+// Offset returns the time zone offset of v.When in minutes, which is what git wants.
func (v *Signature) Offset() int {
_, offset := v.When.Zone()
return offset / 60
diff --git a/vendor/libgit2 b/vendor/libgit2
-Subproject 7f6c1ce9760c6c397e94d4eba506faeb9545270
+Subproject 838a2f2918b6d9fad8768d2498575ff5d75c35f