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

[PATCHv1 2/3] git-p4: do not terminate creating tag for unknown commit

From
Luke Diamand <luke@diamand.org>
Date
Aug 27, 2015, 07:18 UTC
Message-ID
<1440659938-12952-3-git-send-email-luke@diamand.org>
In-Reply-To
<1440659938-12952-1-git-send-email-luke@diamand.org>

If p4 reports a tag for a commit that git-p4 does not know about (e.g. because it references a P4 changelist that was imported prior to the point at which the repo was cloned into git), make sure that the error is correctly caught and handled. rather than just crashing.

Signed-off-by: Luke Diamand <luke@diamand.org>
---
 git-p4.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/git-p4.py b/git-p4.py
index 073f87b..a62611a 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -2494,9 +2494,9 @@ class P4Sync(Command, P4UserMap):
                 # find the corresponding git commit; take the oldest commit
                 changelist = int(change['change'])
                 gitCommit = read_pipe(["git", "rev-list", "--max-count=1",
-                     "--reverse", ":/\[git-p4:.*change = %d\]" % changelist])
+                     "--reverse", ":/\[git-p4:.*change = %d\]" % changelist], ignore_error=True)
                 if len(gitCommit) == 0:
-                    print "could not find git commit for changelist %d" % changelist
+                    print "importing label %s: could not find git commit for changelist %d" % (name, changelist)
                 else:
                     gitCommit = gitCommit.strip()
                     commitFound = True
-- 
2.5.0.rc0
Previous: Eric SunshineNext: Luke Diamand
Message 4 of 6 in “[PATCHv1 0/3] git-p4: fixing import with labels when commit is not transferred”
  1. Luke DiamandAug 27, 2015
  2. 1/3 git-p4: failing test for ignoring invalid p4 labelsLuke Diamand, Aug 27, 2015
  3. Eric SunshineAug 27, 2015
  4. 2/3 git-p4: do not terminate creating tag for unknown commitLuke Diamand, Aug 27, 2015
  5. 3/3 git-p4: fix P4 label import for unprocessed commitsLuke Diamand, Aug 27, 2015
  6. Holl, MarcusSep 14, 2015

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.