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

[PATCH] git-p4: Fix depot path stripping

From
NSNuno Subtil <subtil@gmail.com>
Date
Feb 27, 2018, 04:16 UTC
Message-ID
<01020161d57a3c14-1177a79b-cc21-4d78-8bbd-b6650f7a6169-000000@eu-west-1.amazonses.com>

When useClientSpec=true, stripping of P4 depot paths doesn't happen correctly on sync. Modifies stripRepoPath to handle this case better.

Signed-off-by: Nuno Subtil <subtil@gmail.com>
---
 git-p4.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/git-p4.py b/git-p4.py
index 7bb9cadc69738..3df95d0fd1d83 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -2480,7 +2480,7 @@ def stripRepoPath(self, path, prefixes):
                     if path.startswith(b + "/"):
                         path = path[len(b)+1:]
 
-        elif self.keepRepoPath:
+        if self.keepRepoPath:
             # Preserve everything in relative path name except leading
             # //depot/; just look at first prefix as they all should
             # be in the same depot.
@@ -2490,6 +2490,12 @@ def stripRepoPath(self, path, prefixes):
 
         else:
             for p in prefixes:
+		if self.useClientSpec and not self.keepRepoPath:
+                    # when useClientSpec is false, the prefix will contain the depot name but the path will not
+                    # extract the depot name and add it to the path so the match below will do the right thing
+                    depot = re.sub("^(//[^/]+/).*", r'\1', p)
+                    path = depot + path
+
                 if p4PathStartsWith(path, p):
                     path = path[len(p):]
                     break
@@ -2526,8 +2532,8 @@ def splitFilesIntoBranches(self, commit):
             # go in a p4 client
             if self.useClientSpec:
                 relPath = self.clientSpecDirs.map_in_client(path)
-            else:
-                relPath = self.stripRepoPath(path, self.depotPaths)
+
+            relPath = self.stripRepoPath(path, self.depotPaths)
 
             for branch in self.knownBranches.keys():
                 # add a trailing slash so that a commit into qt/4.2foo

--
https://github.com/git/git/pull/463
Next: Luke Diamand
Message 1 of 5 in “git-p4: Fix depot path stripping”
  1. git-p4: Fix depot path strippingNuno Subtil, Feb 27, 2018
  2. Luke DiamandFeb 27, 2018
  3. Luke DiamandFeb 27, 2018
  4. Luke DiamandMar 2, 2018
  5. Nuno SubtilMar 2, 2018

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.