Skip to content

Commit

Permalink
git-p4: Correct branch base depot path detection
Browse files Browse the repository at this point in the history
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 <vitor.hda@gmail.com>
Acked-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Vitor Antunes authored and Junio C Hamano committed Aug 23, 2011
1 parent 68cbcf1 commit 04d277b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions contrib/fast-import/git-p4
Original file line number Diff line number Diff line change
Expand Up @@ -1829,12 +1829,14 @@ class P4Sync(Command, P4UserMap):
else:
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
break

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

self.previousDepotPaths = paths

Expand Down

0 comments on commit 04d277b

Please sign in to comment.