diff options
author | Jleagle <jimeagle@gmail.com> | 2023-05-25 12:52:22 +0100 |
---|---|---|
committer | Jleagle <jimeagle@gmail.com> | 2023-05-25 12:52:22 +0100 |
commit | b7cc5d9bccb94fa06e3c9a231376dd981f343a9b (patch) | |
tree | 2ecfdfb24fb4f53b84711c28a77a849e53117d74 /plumbing/format/gitignore/dir.go | |
parent | 8bcb67c2cb09f9cf2fd0b0765c6cfcbc6355321a (diff) | |
download | go-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.go | 8 |
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() |