aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-07-19 00:50:27 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2017-07-19 00:50:27 +0200
commit11f75e288e5cd4343e5a48cea30f9480c5828059 (patch)
tree1dcb33fd1f5ea440d0df4da9a25a19fb3648295a
parente92973bea8d9a8ee5c06777ce34a1363ea018371 (diff)
downloadgo-git-11f75e288e5cd4343e5a48cea30f9480c5828059.tar.gz
worktree: commit, use path package instead of filepath
-rw-r--r--worktree_commit.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/worktree_commit.go b/worktree_commit.go
index a342240..02a5d03 100644
--- a/worktree_commit.go
+++ b/worktree_commit.go
@@ -1,7 +1,7 @@
package git
import (
- "path/filepath"
+ "path"
"strings"
"gopkg.in/src-d/go-git.v4/plumbing"
@@ -128,36 +128,36 @@ func (h *buildTreeHelper) BuildTree(idx *index.Index) (plumbing.Hash, error) {
}
func (h *buildTreeHelper) commitIndexEntry(e *index.Entry) error {
- parts := strings.Split(e.Name, string(filepath.Separator))
+ parts := strings.Split(e.Name, "/")
- var path string
+ var fullpath string
for _, part := range parts {
- parent := path
- path = filepath.Join(path, part)
+ parent := fullpath
+ fullpath = path.Join(fullpath, part)
- h.doBuildTree(e, parent, path)
+ h.doBuildTree(e, parent, fullpath)
}
return nil
}
-func (h *buildTreeHelper) doBuildTree(e *index.Entry, parent, path string) {
- if _, ok := h.trees[path]; ok {
+func (h *buildTreeHelper) doBuildTree(e *index.Entry, parent, fullpath string) {
+ if _, ok := h.trees[fullpath]; ok {
return
}
- if _, ok := h.entries[path]; ok {
+ if _, ok := h.entries[fullpath]; ok {
return
}
- te := object.TreeEntry{Name: filepath.Base(path)}
+ te := object.TreeEntry{Name: path.Base(fullpath)}
- if path == e.Name {
+ if fullpath == e.Name {
te.Mode = e.Mode
te.Hash = e.Hash
} else {
te.Mode = filemode.Dir
- h.trees[path] = &object.Tree{}
+ h.trees[fullpath] = &object.Tree{}
}
h.trees[parent].Entries = append(h.trees[parent].Entries, te)
@@ -169,7 +169,7 @@ func (h *buildTreeHelper) copyTreeToStorageRecursive(parent string, t *object.Tr
continue
}
- path := filepath.Join(parent, e.Name)
+ path := path.Join(parent, e.Name)
var err error
e.Hash, err = h.copyTreeToStorageRecursive(path, h.trees[path])