Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 0d4d81e

Browse files
committed
File paths will now be consistent across platforms
Previously go-git used filepath.Join when walking tree structures and constructing paths, but its results are platform-dependent as it will return different results on different systems. For example, it will use backslashes as a path separator on Windows. As a result the SuiteTree.TestFiles test was failing on Windows because the returned paths didn't match what was expected. filepath.Join has been changed to path.Join, which will return consistent results for all platforms. This change makes it so that go-git will always return paths with forward-slash delimiters. Users of the library should convert the resulting file paths into platform-compatible paths when necessary.
1 parent a989631 commit 0d4d81e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tree.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"errors"
66
"io"
77
"os"
8-
"path/filepath"
8+
"path"
99
"strconv"
1010
"strings"
1111

@@ -138,14 +138,14 @@ func (t *Tree) walkEntries(base string, ch chan *File) {
138138
if obj.Type() == core.TreeObject {
139139
tree := &Tree{r: t.r}
140140
tree.Decode(obj)
141-
tree.walkEntries(filepath.Join(base, entry.Name), ch)
141+
tree.walkEntries(path.Join(base, entry.Name), ch)
142142
continue
143143
}
144144

145145
blob := &Blob{}
146146
blob.Decode(obj)
147147

148-
ch <- &File{Name: filepath.Join(base, entry.Name), Reader: blob.Reader(), Hash: entry.Hash}
148+
ch <- &File{Name: path.Join(base, entry.Name), Reader: blob.Reader(), Hash: entry.Hash}
149149
}
150150
}
151151

0 commit comments

Comments
 (0)