aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-04-12 03:46:28 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2017-04-12 03:46:28 +0200
commit63f234847bf613b621b3a714d77fc077d88717e6 (patch)
tree610c99bb6fe6c9cbc7b8666652352321726212ee /plumbing
parente14ee7a2645b486d72f52a0c62714b3049077554 (diff)
downloadgo-git-63f234847bf613b621b3a714d77fc077d88717e6.tar.gz
worktree, reset implementation and status improvements
Diffstat (limited to 'plumbing')
-rw-r--r--plumbing/format/index/index.go27
-rw-r--r--plumbing/object/tree.go2
2 files changed, 16 insertions, 13 deletions
diff --git a/plumbing/format/index/index.go b/plumbing/format/index/index.go
index 3675c4e..61e7d66 100644
--- a/plumbing/format/index/index.go
+++ b/plumbing/format/index/index.go
@@ -5,6 +5,8 @@ import (
"fmt"
"time"
+ "bytes"
+
"gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/filemode"
)
@@ -50,12 +52,12 @@ type Index struct {
// String is equivalent to `git ls-files --stage --debug`
func (i *Index) String() string {
- var o string
+ buf := bytes.NewBuffer(nil)
for _, e := range i.Entries {
- o += e.String()
+ buf.WriteString(e.String())
}
- return o
+ return buf.String()
}
// Entry represents a single file (or stage of a file) in the cache. An entry
@@ -90,15 +92,16 @@ type Entry struct {
}
func (e Entry) String() string {
- var o string
- o += fmt.Sprintf("%06o %s %d\t%s\n", e.Mode, e.Hash, e.Stage, e.Name)
- o += fmt.Sprintf(" ctime: %d:%d\n", e.CreatedAt.Unix(), e.CreatedAt.Nanosecond())
- o += fmt.Sprintf(" mtime: %d:%d\n", e.ModifiedAt.Unix(), e.ModifiedAt.Nanosecond())
- o += fmt.Sprintf(" dev: %d\tino: %d\n", e.Dev, e.Inode)
- o += fmt.Sprintf(" uid: %d\tgid: %d\n", e.UID, e.GID)
- o += fmt.Sprintf(" size: %d\tflags: %x\n", e.Size, 0)
-
- return o
+ buf := bytes.NewBuffer(nil)
+
+ fmt.Fprintf(buf, "%06o %s %d\t%s\n", e.Mode, e.Hash, e.Stage, e.Name)
+ fmt.Fprintf(buf, " ctime: %d:%d\n", e.CreatedAt.Unix(), e.CreatedAt.Nanosecond())
+ fmt.Fprintf(buf, " mtime: %d:%d\n", e.ModifiedAt.Unix(), e.ModifiedAt.Nanosecond())
+ fmt.Fprintf(buf, " dev: %d\tino: %d\n", e.Dev, e.Inode)
+ fmt.Fprintf(buf, " uid: %d\tgid: %d\n", e.UID, e.GID)
+ fmt.Fprintf(buf, " size: %d\tflags: %x\n", e.Size, 0)
+
+ return buf.String()
}
// Tree contains pre-computed hashes for trees that can be derived from the
diff --git a/plumbing/object/tree.go b/plumbing/object/tree.go
index b768b96..d2265a8 100644
--- a/plumbing/object/tree.go
+++ b/plumbing/object/tree.go
@@ -109,7 +109,7 @@ func (t *Tree) TreeEntryFile(e *TreeEntry) (*File, error) {
return NewFile(e.Name, e.Mode, blob), nil
}
-// FindEntry search a TreeEntry in this tree or any subtree
+// FindEntry search a TreeEntry in this tree or any subtree.
func (t *Tree) FindEntry(path string) (*TreeEntry, error) {
pathParts := strings.Split(path, "/")