aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/gitignore/dir.go
diff options
context:
space:
mode:
authorJleagle <jimeagle@gmail.com>2023-05-25 12:52:22 +0100
committerJleagle <jimeagle@gmail.com>2023-05-25 12:52:22 +0100
commitb7cc5d9bccb94fa06e3c9a231376dd981f343a9b (patch)
tree2ecfdfb24fb4f53b84711c28a77a849e53117d74 /plumbing/format/gitignore/dir.go
parent8bcb67c2cb09f9cf2fd0b0765c6cfcbc6355321a (diff)
downloadgo-git-b7cc5d9bccb94fa06e3c9a231376dd981f343a9b.tar.gz
plumbing: gitignore, Allow gitconfig to contain a gitignore relative to user home
Diffstat (limited to 'plumbing/format/gitignore/dir.go')
-rw-r--r--plumbing/format/gitignore/dir.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/plumbing/format/gitignore/dir.go b/plumbing/format/gitignore/dir.go
index bb78655..bf6a1c1 100644
--- a/plumbing/format/gitignore/dir.go
+++ b/plumbing/format/gitignore/dir.go
@@ -25,6 +25,14 @@ const (
// readIgnoreFile reads a specific git ignore file.
func readIgnoreFile(fs billy.Filesystem, path []string, ignoreFile string) (ps []Pattern, err error) {
+
+ if strings.HasPrefix(ignoreFile, "~") {
+ home, err := os.UserHomeDir()
+ if err == nil {
+ ignoreFile = strings.Replace(ignoreFile, "~", home, 1)
+ }
+ }
+
f, err := fs.Open(fs.Join(append(path, ignoreFile)...))
if err == nil {
defer f.Close()