From: Vitor Antunes <vitor.hda@gmail.com>
To: git@vger.kernel.org
Cc: Pete Wyckoff <pw@padd.com>, Tor Arvid Lund <torarvid@gmail.com>,
Vitor Antunes <vitor.hda@gmail.com>
Subject: [PATCH v2 1/3] git-p4: Correct branch base depot path detection
Date: Sat, 26 Feb 2011 23:46:09 +0000 [thread overview]
Message-ID: <1298763971-20556-2-git-send-email-vitor.hda@gmail.com> (raw)
In-Reply-To: <1298763971-20556-1-git-send-email-vitor.hda@gmail.com>
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>
---
contrib/fast-import/git-p4 | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index a92beb6..fad3371 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -1599,12 +1599,14 @@ class P4Sync(Command):
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
--
1.7.4.1
next prev parent reply other threads:[~2011-02-26 23:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-26 23:46 [PATCH v2 0/3] git-p4: Improve branch support Vitor Antunes
2011-02-26 23:46 ` Vitor Antunes [this message]
2011-02-26 23:46 ` [PATCH v2 2/3] git-p4: Allow filtering Perforce branches by user Vitor Antunes
2011-02-26 23:46 ` [PATCH v2 3/3] git-p4: Allow branch definition with git config Vitor Antunes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1298763971-20556-2-git-send-email-vitor.hda@gmail.com \
--to=vitor.hda@gmail.com \
--cc=git@vger.kernel.org \
--cc=pw@padd.com \
--cc=torarvid@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).