diff --git a/pkg/commands/git_commands/working_tree.go b/pkg/commands/git_commands/working_tree.go index 99665d7cc..c3338650a 100644 --- a/pkg/commands/git_commands/working_tree.go +++ b/pkg/commands/git_commands/working_tree.go @@ -3,6 +3,7 @@ package git_commands import ( "fmt" "os" + "path" "github.com/go-errors/errors" "github.com/jesseduffield/lazygit/pkg/commands/models" @@ -232,7 +233,8 @@ func (self *WorkingTreeCommands) Ignore(filename string) error { // Exclude adds a file to the .git/info/exclude for the repo func (self *WorkingTreeCommands) Exclude(filename string) error { - return self.os.AppendLineToFile(".git/info/exclude", filename) + excludeFile := path.Join(self.repoPaths.repoGitDirPath, "info", "exclude") + return self.os.AppendLineToFile(excludeFile, filename) } // WorktreeFileDiff returns the diff of a file diff --git a/pkg/integration/tests/worktree/exclude_file_in_worktree.go b/pkg/integration/tests/worktree/exclude_file_in_worktree.go index 60d8d2b32..ba3f9e5a5 100644 --- a/pkg/integration/tests/worktree/exclude_file_in_worktree.go +++ b/pkg/integration/tests/worktree/exclude_file_in_worktree.go @@ -34,13 +34,8 @@ var ExcludeFileInWorktree = NewIntegrationTest(NewIntegrationTestArgs{ Tap(func() { t.ExpectPopup().Menu().Title(Equals("Ignore or exclude file")).Select(Contains("Add to .git/info/exclude")).Confirm() }). - /* EXPECTED: IsEmpty() - t.FileSystem().FileContent("../repo/.git/info/exclude", Contains("toExclude")) - ACTUAL: */ - Tap(func() { - t.ExpectPopup().Alert().Title(Equals("Error")).Content(Contains("open .git/info/exclude: not a directory")) - }) + t.FileSystem().FileContent("../repo/.git/info/exclude", Contains("toExclude")) }, })