git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-p4: Strip branch name prefixes if --use-client-spec enabled

From
PMPatrick C. McGinty <casey.mcginty@gmail.com>
Date
Aug 20, 2012, 23:43 UTC
Message-ID
<1345506210-17382-1-git-send-email-casey.mcginty@gmail.com>
From: "Patrick C. McGinty" <casey.mcginty@gmail.com>

This removes the branch names from being included in the file system path when using the both --use-client-spec and --detect-branches options.

Used alone, the --detect-branches option did the right thing, removing the branch names from the relative git path. By adding the --use-client-spec option, the old logic would incorrectly bypass this step.

Signed-off-by: Patrick C. McGinty <casey.mcginty@gmail.com>
---
 git-p4.py |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/git-p4.py b/git-p4.py
index e67d37d..9489845 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -1819,7 +1819,15 @@ class P4Sync(Command, P4UserMap):
 
     def stripRepoPath(self, path, prefixes):
         if self.useClientSpec:
-            return self.clientSpecDirs.map_in_client(path)
+            # map path to user defined client location
+            path = self.clientSpecDirs.map_in_client(path)
+            # Remove prefixes (e.g. branch names) from path. Apply the
+            # clientSpecDirs map to the prefix paths to match the
+            # modified path value.
+            for p in map(self.clientSpecDirs.map_in_client, prefixes):
+               if p and p4PathStartsWith( path, p):
+                  path = path[len(p):]
+            return path
 
         if self.keepRepoPath:
             prefixes = [re.sub("^(//[^/]+/).*", r'\1', prefixes[0])]
-- 
1.7.9.5
Next: Pete Wyckoff
Message 1 of 2 in “git-p4: Strip branch name prefixes if --use-client-spec enabled”
  1. git-p4: Strip branch name prefixes if --use-client-spec enabledPatrick C. McGinty, Aug 20, 2012
  2. Pete WyckoffAug 22, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.