aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format
diff options
context:
space:
mode:
authorPaulo Gomes <pjbgf@linux.com>2024-05-20 23:25:39 +0100
committerPaulo Gomes <pjbgf@linux.com>2024-05-20 23:26:14 +0100
commitea3cfc94f9846f493e22d387eb22a135eb972807 (patch)
treec25880428da44663df2d78978a5e4a0b436e3d5d /plumbing/format
parentd283feac3d21c60d175522dc1486d723414dcf06 (diff)
downloadgo-git-ea3cfc94f9846f493e22d387eb22a135eb972807.tar.gz
plumbing: format, Handle case where fs.Join breaks with C: in Windows
Signed-off-by: Paulo Gomes <pjbgf@linux.com>
Diffstat (limited to 'plumbing/format')
-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 {