diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-07-19 22:04:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-19 22:04:46 +0200 |
commit | 8738a04708b91683d5804b4c648c871fdeb87f82 (patch) | |
tree | 017b15080dee8bd64026c9358d832e61d12674d5 /worktree_commit.go | |
parent | 595dfe6e53a038da4949263ea2d9a7a0020c48b7 (diff) | |
parent | 4a7e7cddc0e4f88085b263693c87635254de7f35 (diff) | |
download | go-git-8738a04708b91683d5804b4c648c871fdeb87f82.tar.gz |
Merge pull request #493 from src-d/windows
*: several windows support fixes
Diffstat (limited to 'worktree_commit.go')
-rw-r--r-- | worktree_commit.go | 26 |
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]) |