Merge pull request #320 from netnose/enum-mappings
Enum Mappings
diff --git a/diff.go b/diff.go
index 9a7ac78..8ae0512 100644
--- a/diff.go
+++ b/diff.go
@@ -217,6 +217,33 @@
return int(C.git_diff_stats_files_changed(stats.ptr))
}
+type DiffStatsFormat int
+
+const (
+ DiffStatsNone DiffStatsFormat = C.GIT_DIFF_STATS_NONE
+ DiffStatsFull DiffStatsFormat = C.GIT_DIFF_STATS_FULL
+ DiffStatsShort DiffStatsFormat = C.GIT_DIFF_STATS_SHORT
+ DiffStatsNumber DiffStatsFormat = C.GIT_DIFF_STATS_NUMBER
+ DiffStatsIncludeSummary DiffStatsFormat = C.GIT_DIFF_STATS_INCLUDE_SUMMARY
+)
+
+func (stats *DiffStats) String(format DiffStatsFormat,
+ width uint) (string, error) {
+ buf := C.git_buf{}
+ defer C.git_buf_free(&buf)
+
+ runtime.LockOSThread()
+ defer runtime.UnlockOSThread()
+
+ ret := C.git_diff_stats_to_buf(&buf,
+ stats.ptr, C.git_diff_stats_format_t(format), C.size_t(width))
+ if ret < 0 {
+ return "", MakeGitError(ret)
+ }
+
+ return C.GoString(buf.ptr), nil
+}
+
func (diff *Diff) Stats() (*DiffStats, error) {
stats := new(DiffStats)
diff --git a/repository.go b/repository.go
index 77e9f9c..efc506e 100644
--- a/repository.go
+++ b/repository.go
@@ -28,7 +28,7 @@
// read, write and delete notes from this repository.
Notes NoteCollection
// Tags represents the collection of tags and can be used to create,
- // list and iterate tags in this repository.
+ // list, iterate and remove tags in this repository.
Tags TagsCollection
}
diff --git a/reset.go b/reset.go
index 9da7625..031f5bd 100644
--- a/reset.go
+++ b/reset.go
@@ -24,3 +24,19 @@
}
return nil
}
+
+func (r *Repository) ResetDefaultToCommit(commit *Commit, pathspecs []string) error {
+ cpathspecs := C.git_strarray{}
+ cpathspecs.count = C.size_t(len(pathspecs))
+ cpathspecs.strings = makeCStringsFromStrings(pathspecs)
+ defer freeStrarray(&cpathspecs)
+
+ runtime.LockOSThread()
+ defer runtime.UnlockOSThread()
+ ret := C.git_reset_default(r.ptr, commit.ptr, &cpathspecs)
+
+ if ret < 0 {
+ return MakeGitError(ret)
+ }
+ return nil
+}
diff --git a/tag.go b/tag.go
index 8957430..81d7258 100644
--- a/tag.go
+++ b/tag.go
@@ -83,6 +83,21 @@
return oid, nil
}
+func (c *TagsCollection) Remove(name string) error {
+ runtime.LockOSThread()
+ defer runtime.UnlockOSThread()
+
+ cname := C.CString(name)
+ defer C.free(unsafe.Pointer(cname))
+
+ ret := C.git_tag_delete(c.repo.ptr, cname)
+ if ret < 0 {
+ return MakeGitError(ret)
+ }
+
+ return nil
+}
+
// CreateLightweight creates a new lightweight tag pointing to a commit
// and returns the id of the target object.
//