From: Kirill Frolov Date: Mon, 21 Mar 2022 12:43:22 +0000 (+0000) Subject: git-p4: fix issue with multiple perforce remotes X-Git-Tag: v2.37.0-rc0~78^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=944db25c603ec56aeea95c193a4b74eb5da5d90d;p=thirdparty%2Fgit.git git-p4: fix issue with multiple perforce remotes Single perforce branch might be sync'ed multiple times with different revision numbers, so it will be seen to Git as complete different commits. This can be done by the following command: git p4 sync --branch=NAME //perforce/path... It is assumed, that this command applied multiple times and peforce repository changes between command invocations. In such situation, git p4 will see multiple perforce branches with same name and different revision numbers. The problem is that to make a shelve, git-p4 script will try to find "origin" branch, if not specified in command line explicitly. And previously script selected any branch with same name and don't mention particular revision number. Later this may cause failure of the command "git diff-tree -r $rev^ $rev", so shelve can't be created (due to wrong origin branch/commit). This commit fixes the heuristic by which git p4 selects origin branch: first it tries to select branch with same perforce path and perforce revision, and if it fails, then selects branch with only same perforce path (ignoring perforce revision number). Signed-off-by: Kirill Frolov Signed-off-by: Junio C Hamano --- diff --git a/git-p4.py b/git-p4.py index a9b1f90441..4903e86351 100755 --- a/git-p4.py +++ b/git-p4.py @@ -946,8 +946,12 @@ def findUpstreamBranchPoint(head = "HEAD"): log = extractLogMessageFromGitCommit(tip) settings = extractSettingsGitLog(log) if "depot-paths" in settings: + git_branch = "remotes/p4/" + branch paths = ",".join(settings["depot-paths"]) - branchByDepotPath[paths] = "remotes/p4/" + branch + branchByDepotPath[paths] = git_branch + if "change" in settings: + paths = paths + ";" + settings["change"] + branchByDepotPath[paths] = git_branch settings = None parent = 0 @@ -957,6 +961,10 @@ def findUpstreamBranchPoint(head = "HEAD"): settings = extractSettingsGitLog(log) if "depot-paths" in settings: paths = ",".join(settings["depot-paths"]) + if "change" in settings: + expaths = paths + ";" + settings["change"] + if expaths in branchByDepotPath: + return [branchByDepotPath[expaths], settings] if paths in branchByDepotPath: return [branchByDepotPath[paths], settings]