mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-13 11:50:28 +02:00
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.
This commit is contained in:
parent
19d0048cc4
commit
b2011dca35
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user