diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-04-26 20:55:00 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2017-04-26 20:55:00 +0200 |
commit | 75c5adffb8b1e80665753784129e2f16210514c1 (patch) | |
tree | a51878832cabcd1f2142e4eb855b17f16d7c2ddf /worktree_status.go | |
parent | 9b75cb91384dd08eed2acce8c3099e082835da12 (diff) | |
download | go-git-75c5adffb8b1e80665753784129e2f16210514c1.tar.gz |
*: applying new index.Index changes
Diffstat (limited to 'worktree_status.go')
-rw-r--r-- | worktree_status.go | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/worktree_status.go b/worktree_status.go index 6becada..46922da 100644 --- a/worktree_status.go +++ b/worktree_status.go @@ -234,7 +234,7 @@ func (w *Worktree) addOrUpdateFileToIndex(filename string, h plumbing.Hash) erro } func (w *Worktree) doAddFileToIndex(idx *index.Index, filename string) error { - idx.Entries = append(idx.Entries, index.Entry{ + idx.Entries = append(idx.Entries, &index.Entry{ Name: filename, }) @@ -247,21 +247,18 @@ func (w *Worktree) doUpdateFileToIndex(idx *index.Index, filename string, h plum return err } - for i, e := range idx.Entries { - if e.Name != filename { - continue - } - - e.Hash = h - e.ModifiedAt = info.ModTime() - e.Mode, err = filemode.NewFromOSFileMode(info.Mode()) - if err != nil { - return err - } + e, err := idx.Entry(filename) + if err != nil { + return err + } - fillSystemInfo(&e, info.Sys()) - idx.Entries[i] = e + e.Hash = h + e.ModifiedAt = info.ModTime() + e.Mode, err = filemode.NewFromOSFileMode(info.Mode()) + if err != nil { + return err } + fillSystemInfo(e, info.Sys()) return nil } |