Skip to content

Instantly share code, notes, and snippets.

@ry
Created October 17, 2014 17:39
Show Gist options
  • Save ry/21587c5d66e20ab0d123 to your computer and use it in GitHub Desktop.
Save ry/21587c5d66e20ab0d123 to your computer and use it in GitHub Desktop.
From e4960abfa668b3e6ad63e88c3eec4b127bd4863a Mon Sep 17 00:00:00 2001
From: Ryan Dahl <ry@tinyclouds.org>
Date: Fri, 17 Oct 2014 13:37:16 -0400
Subject: [PATCH] more explicit Filemode typing
---
index_test.go | 6 +++---
tree.go | 12 ++++++------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/index_test.go b/index_test.go
index cd178b9..800f382 100644
--- a/index_test.go
+++ b/index_test.go
@@ -54,10 +54,10 @@ func TestIndexAddAndWriteTreeTo(t *testing.T) {
idx, err := NewIndex()
checkFatal(t, err)
- entry := IndexEntry {
+ entry := IndexEntry{
Path: "README",
- Id: blobID,
- Mode: FilemodeBlob,
+ Id: blobID,
+ Mode: uint(FilemodeBlob),
}
err = idx.Add(&entry)
diff --git a/tree.go b/tree.go
index e5fe361..45de9f1 100644
--- a/tree.go
+++ b/tree.go
@@ -17,10 +17,10 @@ type Filemode int
const (
FilemodeTree Filemode = C.GIT_FILEMODE_TREE
- FilemodeBlob = C.GIT_FILEMODE_BLOB
- FilemodeBlobExecutable = C.GIT_FILEMODE_BLOB_EXECUTABLE
- FilemodeLink = C.GIT_FILEMODE_LINK
- FilemodeCommit = C.GIT_FILEMODE_COMMIT
+ FilemodeBlob Filemode = C.GIT_FILEMODE_BLOB
+ FilemodeBlobExecutable Filemode = C.GIT_FILEMODE_BLOB_EXECUTABLE
+ FilemodeLink Filemode = C.GIT_FILEMODE_LINK
+ FilemodeCommit Filemode = C.GIT_FILEMODE_COMMIT
)
type Tree struct {
@@ -32,7 +32,7 @@ type TreeEntry struct {
Name string
Id *Oid
Type ObjectType
- Filemode int
+ Filemode Filemode
}
func newTreeEntry(entry *C.git_tree_entry) *TreeEntry {
@@ -40,7 +40,7 @@ func newTreeEntry(entry *C.git_tree_entry) *TreeEntry {
C.GoString(C.git_tree_entry_name(entry)),
newOidFromC(C.git_tree_entry_id(entry)),
ObjectType(C.git_tree_entry_type(entry)),
- int(C.git_tree_entry_filemode(entry)),
+ Filemode(C.git_tree_entry_filemode(entry)),
}
}
--
2.0.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment