diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2024-05-29 16:25:41 +0200 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2024-06-03 13:02:46 +0200 |
commit | b2011dca359fbf5a5dde7118fe2ad27a41410ed6 (patch) | |
tree | b58eb516d6b2e5a6c9813bbdcd13ed0e5a685d9c /pkg | |
parent | 19d0048cc486b087ca938a14ce2be91ea0f0a3ae (diff) |
Remove the cache invalidation logic from getMergeBase
It is a valid case for a branch to share no history with any of the main
branches, in which case git merge-base returns an error (and an empty string).
Since we can't distinguish this from one of the main branches having been
deleted, we shouldn't invalidate the cache in that case.
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/commands/git_commands/commit_loader.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/pkg/commands/git_commands/commit_loader.go b/pkg/commands/git_commands/commit_loader.go index 737e4c077..86418453d 100644 --- a/pkg/commands/git_commands/commit_loader.go +++ b/pkg/commands/git_commands/commit_loader.go @@ -483,16 +483,17 @@ func (self *CommitLoader) getMergeBase(refName string) string { // We pass all configured main branches to the merge-base call; git will // return the base commit for the closest one. - output, err := self.cmd.New( + // We ignore errors from this call, since we can't distinguish whether the + // error is because one of the main branches has been deleted since the last + // call to determineMainBranches, or because the refName has no common + // history with any of the main branches. Since the former should happen + // very rarely, users must quit and restart lazygit to fix it; the latter is + // also not very common, but can totally happen and is not an error. + + output, _ := self.cmd.New( NewGitCmd("merge-base").Arg(refName).Arg(self.mainBranches...). ToArgv(), ).DontLog().RunWithOutput() - if err != nil { - // If there's an error, it must be because one of the main branches that - // used to exist when we called getExistingMainBranches() was deleted - // meanwhile. To fix this for next time, throw away our cache. - self.mainBranches = nil - } return ignoringWarnings(output) } |