path: root/contrib/fast-import
diff options
authorVitor Antunes <>2011-08-18 23:44:03 (GMT)
committerJunio C Hamano <>2011-08-23 04:08:37 (GMT)
commit04d277b39e3e40f939fd7935c30beb48452015ec (patch)
tree525ec022ea6c5a82818d04a9bec49a44a46bb73e /contrib/fast-import
parent68cbcf1b2575ca151ed3b11698916bcbbd1b890c (diff)
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 <> Acked-by: Pete Wyckoff <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'contrib/fast-import')
1 files changed, 5 insertions, 3 deletions
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 0db3e72..72a5b6c 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -1829,12 +1829,14 @@ class P4Sync(Command, P4UserMap):
paths = []
for (prev, cur) in zip(self.previousDepotPaths, depotPaths):
- for i in range(0, min(len(cur), len(prev))):
- if cur[i] <> prev[i]:
+ prev_list = prev.split("/")
+ cur_list = cur.split("/")
+ for i in range(0, min(len(cur_list), len(prev_list))):
+ if cur_list[i] <> prev_list[i]:
i = i - 1
- paths.append (cur[:i + 1])
+ paths.append ("/".join(cur_list[:i + 1]))
self.previousDepotPaths = paths