aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plumbing/format/gitattributes/dir.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/plumbing/format/gitattributes/dir.go b/plumbing/format/gitattributes/dir.go
index d3b0dbe..4238196 100644
--- a/plumbing/format/gitattributes/dir.go
+++ b/plumbing/format/gitattributes/dir.go
@@ -2,6 +2,8 @@ package gitattributes
import (
"os"
+ "path/filepath"
+ "strings"
"github.com/go-git/go-billy/v5"
@@ -59,7 +61,14 @@ func walkDirectory(fs billy.Filesystem, root []string) (attributes []MatchAttrib
continue
}
- path := append(root, fi.Name())
+ p := fi.Name()
+
+ // Handles the case whereby just the volume name ("C:") is appended,
+ // to root. Change it to "C:\", which is better handled by fs.Join().
+ if filepath.VolumeName(p) != "" && !strings.HasSuffix(p, string(filepath.Separator)) {
+ p = p + string(filepath.Separator)
+ }
+ path := append(root, p)
dirAttributes, err := ReadAttributesFile(fs, path, gitattributesFile, false)
if err != nil {