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

[PATCHv1 1/3] git-p4: failing test for ignoring invalid p4 labels

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

When importing a label which references a commit that git-p4 does not know about, git-p4 should skip it and go on to process other labels that can be imported.

Instead it crashes when attempting to find the missing commit in the git history. This test demonstrates the problem.

Signed-off-by: Luke Diamand <luke@diamand.org>
---
 t/t9811-git-p4-label-import.sh | 45 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
diff --git a/t/t9811-git-p4-label-import.sh b/t/t9811-git-p4-label-import.sh
index 095238f..f7d5048 100755
--- a/t/t9811-git-p4-label-import.sh
+++ b/t/t9811-git-p4-label-import.sh
@@ -214,6 +214,51 @@ test_expect_success 'use git config to enable import/export of tags' '
 	)
 '
 
+p4_head_revision() {
+	p4 changes -m 1 "$@" | awk '{print $2}'
+}
+
+# Importing a label that references a P4 commit that has
+# has not been seen. The presence of a label on a commit
+# we haven't seen should not cause git-p4 to fail. It should
+# merely skip that label, and still import other labels.
+test_expect_failure 'importing labels with missing revisions' '
+	test_when_finished cleanup_git &&
+	(
+		rm -fr "$cli" "$git" &&
+		mkdir "$cli" &&
+		P4CLIENT=missing-revision &&
+		client_view "//depot/missing-revision/... //missing-revision/..." &&
+		cd "$cli" &&
+		>f1 && p4 add f1 && p4 submit -d "start" &&
+
+		p4 tag -l TAG_S0 ... &&
+
+		>f2 && p4 add f2 && p4 submit -d "second" &&
+
+		startrev=$(p4_head_revision //depot/missing-revision/...) &&
+
+		>f3 && p4 add f3 && p4 submit -d "third" &&
+
+		p4 edit f2 && date >f2 && p4 submit -d "change" f2 &&
+
+		endrev=$(p4_head_revision //depot/missing-revision/...) &&
+
+		p4 tag -l TAG_S1 ... &&
+
+		# we should skip TAG_S0 since it is before our startpoint,
+		# but pick up TAG_S1.
+
+		git p4 clone --dest="$git" --import-labels -v \
+			//depot/missing-revision/...@$startrev,$endrev &&
+		(
+			cd "$git" &&
+			git rev-parse TAG_S1 &&
+			! git rev-parse TAG_S0
+		)
+	)
+'
+
 
 test_expect_success 'kill p4d' '
 	kill_p4d
-- 
2.5.0.rc0
Previous: Luke DiamandNext: Eric Sunshine
Message 2 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.