Skip to content

Commit ea3cfc9

Browse files
committed
plumbing: format, Handle case where fs.Join breaks with C: in Windows
Signed-off-by: Paulo Gomes <pjbgf@linux.com>
1 parent d283fea commit ea3cfc9

File tree

1 file changed

+10
-1
lines changed
  • plumbing/format/gitattributes

1 file changed

+10
-1
lines changed

plumbing/format/gitattributes/dir.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package gitattributes
22

33
import (
44
"os"
5+
"path/filepath"
6+
"strings"
57

68
"github.com/go-git/go-billy/v5"
79

@@ -59,7 +61,14 @@ func walkDirectory(fs billy.Filesystem, root []string) (attributes []MatchAttrib
5961
continue
6062
}
6163

62-
path := append(root, fi.Name())
64+
p := fi.Name()
65+
66+
// Handles the case whereby just the volume name ("C:") is appended,
67+
// to root. Change it to "C:\", which is better handled by fs.Join().
68+
if filepath.VolumeName(p) != "" && !strings.HasSuffix(p, string(filepath.Separator)) {
69+
p = p + string(filepath.Separator)
70+
}
71+
path := append(root, p)
6372

6473
dirAttributes, err := ReadAttributesFile(fs, path, gitattributesFile, false)
6574
if err != nil {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy