From b7cc5d9bccb94fa06e3c9a231376dd981f343a9b Mon Sep 17 00:00:00 2001 From: Jleagle Date: Thu, 25 May 2023 12:52:22 +0100 Subject: plumbing: gitignore, Allow gitconfig to contain a gitignore relative to user home --- plumbing/format/gitignore/dir.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'plumbing/format/gitignore/dir.go') 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() -- cgit