Skip to content

Commit 07b38b7

Browse files
author
Thomas Desveaux
committed
Fix error in GetMergeBase when another command has commit-graph lock
1 parent 80e504c commit 07b38b7

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

modules/git/repo_compare.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,17 @@ func (repo *Repository) GetMergeBase(tmpRemote, base, head string) (string, stri
4040
if tmpRemote != "origin" {
4141
tmpBaseName := RemotePrefix + tmpRemote + "/tmp_" + base
4242
// Fetch commit into a temporary branch in order to be able to handle commits and tags
43-
_, _, err := NewCommand(repo.Ctx, "fetch", "--no-tags").AddDynamicArguments(tmpRemote).AddDashesAndList(base + ":" + tmpBaseName).RunStdString(&RunOpts{Dir: repo.Path})
44-
if err == nil {
43+
// --no-write-commit-graph: fetch will try to generate commit graph by default
44+
// this process require a lock-file (objects/info/commit-graphs/commit-graph-chain.lock)
45+
// and will make fetch return an error code if the file already exists
46+
47+
// Use RunStdString instead of Run to provide stderr in err object
48+
_, _, err := NewCommand(repo.Ctx, "fetch", "--no-write-commit-graph", "--no-tags").
49+
AddDynamicArguments(tmpRemote).AddDashesAndList(base + ":" + tmpBaseName).
50+
RunStdString(&RunOpts{Dir: repo.Path})
51+
if err != nil {
52+
logger.Error("Fetched new remote for GetMergeBase %v", err)
53+
} else {
4554
base = tmpBaseName
4655
}
4756
}

0 commit comments

Comments
 (0)