fix: expand tilde in global gitignore path from git config

git config --global core.excludesfile may return paths like ~/...
which Go does not expand. This caused setupGlobalGitIgnore to fail
when users had configured their gitignore with a tilde path.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-11-26 19:06:50 -08:00
parent 9b51a090ca
commit 340b3507b9

View File

@@ -1198,6 +1198,14 @@ func setupGlobalGitIgnore(homeDir string, verbose bool) error {
if err == nil && len(output) > 0 {
// User has already configured a global gitignore file, use it
ignorePath = strings.TrimSpace(string(output))
// Expand tilde if present (git config may return ~/... which Go doesn't expand)
if strings.HasPrefix(ignorePath, "~/") {
ignorePath = filepath.Join(homeDir, ignorePath[2:])
} else if ignorePath == "~" {
ignorePath = homeDir
}
if verbose {
fmt.Printf("Using existing configured global gitignore file: %s\n", ignorePath)
}