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:
@@ -1198,6 +1198,14 @@ func setupGlobalGitIgnore(homeDir string, verbose bool) error {
|
|||||||
if err == nil && len(output) > 0 {
|
if err == nil && len(output) > 0 {
|
||||||
// User has already configured a global gitignore file, use it
|
// User has already configured a global gitignore file, use it
|
||||||
ignorePath = strings.TrimSpace(string(output))
|
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 {
|
if verbose {
|
||||||
fmt.Printf("Using existing configured global gitignore file: %s\n", ignorePath)
|
fmt.Printf("Using existing configured global gitignore file: %s\n", ignorePath)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user