Skip to content

Commit 04d277b

Browse files
vhdagitster
authored andcommitted
git-p4: Correct branch base depot path detection
When branch detection is enabled each branch is named in git after their relative depot path in Perforce. To do this the depot paths are compared against each other to find their common base path. The current algorithm makes this comparison on a character by character basis. Assuming we have the following branches: //depot/branches/featureA //depot/branches/featureB Then the base depot path would be //depot/branches/feature, which is an invalid depot path. The current patch fixes this by splitting the path into a list and comparing the list entries, making it choose correctly //depot/branches as the base path. Signed-off-by: Vitor Antunes <[email protected]> Acked-by: Pete Wyckoff <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 68cbcf1 commit 04d277b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

contrib/fast-import/git-p4

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,12 +1829,14 @@ class P4Sync(Command, P4UserMap):
18291829
else:
18301830
paths = []
18311831
for (prev, cur) in zip(self.previousDepotPaths, depotPaths):
1832-
for i in range(0, min(len(cur), len(prev))):
1833-
if cur[i] <> prev[i]:
1832+
prev_list = prev.split("/")
1833+
cur_list = cur.split("/")
1834+
for i in range(0, min(len(cur_list), len(prev_list))):
1835+
if cur_list[i] <> prev_list[i]:
18341836
i = i - 1
18351837
break
18361838

1837-
paths.append (cur[:i + 1])
1839+
paths.append ("/".join(cur_list[:i + 1]))
18381840

18391841
self.previousDepotPaths = paths
18401842

0 commit comments

Comments
 (0)