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

[PATCH 01/14] git p4: test sync/clone --branch behavior

From
PWPete Wyckoff <pw@padd.com>
Date
Jan 15, 2013, 00:46 UTC
Message-ID
<1358210828-2369-2-git-send-email-pw@padd.com>
In-Reply-To
<1358210828-2369-1-git-send-email-pw@padd.com>

Add failing tests to document behavior when there are multiple p4 branches, as created using the --branch option. In particular:

Using clone --branch populates the specified branch correctly, but dies with an error when trying to checkout master.

Calling sync without a master branch dies with an error looking for master. When there are two or more branches, a sync does nothing due to branch detection code, but that is expected.

Using sync --branch to try to update just a particular branch updates no branch, but appears to succeed.

Signed-off-by: Pete Wyckoff <pw@padd.com>
---
 t/t9806-git-p4-options.sh | 53 +++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 49 insertions(+), 4 deletions(-)
diff --git a/t/t9806-git-p4-options.sh b/t/t9806-git-p4-options.sh
index fa40cc8..844aae0 100755
--- a/t/t9806-git-p4-options.sh
+++ b/t/t9806-git-p4-options.sh
@@ -27,14 +27,59 @@ test_expect_success 'clone no --git-dir' '
 	test_must_fail git p4 clone --git-dir=xx //depot
 '
 
-test_expect_success 'clone --branch' '
+test_expect_failure 'clone --branch should checkout master' '
 	git p4 clone --branch=refs/remotes/p4/sb --dest="$git" //depot &&
 	test_when_finished cleanup_git &&
 	(
 		cd "$git" &&
-		git ls-files >files &&
-		test_line_count = 0 files &&
-		test_path_is_file .git/refs/remotes/p4/sb
+		git rev-parse refs/remotes/p4/sb >sb &&
+		git rev-parse refs/heads/master >master &&
+		test_cmp sb master &&
+		git rev-parse HEAD >head &&
+		test_cmp sb head
+	)
+'
+
+test_expect_failure 'sync when branch is not called master should work' '
+	git p4 clone --branch=refs/remotes/p4/sb --dest="$git" //depot@2 &&
+	test_when_finished cleanup_git &&
+	(
+		cd "$git" &&
+		git p4 sync &&
+		git show -s --format=%s refs/remotes/p4/sb >show &&
+		grep "change 3" show
+	)
+'
+
+# engages --detect-branches code, which will do filename filtering so
+# no sync to either b1 or b2
+test_expect_success 'sync when two branches but no master should noop' '
+	test_when_finished cleanup_git &&
+	(
+		cd "$git" &&
+		git init &&
+		git p4 sync --branch=refs/remotes/p4/b1 //depot@2 &&
+		git p4 sync --branch=refs/remotes/p4/b2 //depot@2 &&
+		git p4 sync &&
+		git show -s --format=%s refs/remotes/p4/b1 >show &&
+		grep "Initial import" show &&
+		git show -s --format=%s refs/remotes/p4/b2 >show &&
+		grep "Initial import" show
+	)
+'
+
+test_expect_failure 'sync --branch updates specified branch' '
+	test_when_finished cleanup_git &&
+	(
+		cd "$git" &&
+		git init &&
+		git p4 sync --branch=refs/remotes/p4/b1 //depot@2 &&
+		git p4 sync --branch=refs/remotes/p4/b2 //depot@2 &&
+		git p4 sync --branch=refs/remotes/p4/b2 &&
+		git show -s --format=%s refs/remotes/p4/b1 >show &&
+		grep "Initial import" show &&
+		git show -s --format=%s refs/remotes/p4/b2 >show &&
+		grep "change 3" show
 	)
 '
 
-- 
1.8.1.350.gdbf6fd0
Previous: Pete WyckoffNext: Pete Wyckoff
Message 2 of 15 in “git p4 branch handling fixes”
  1. 00/14 git p4 branch handling fixesPete Wyckoff, Jan 15, 2013
  2. 01/14 git p4: test sync/clone --branch behaviorPete Wyckoff, Jan 15, 2013
  3. 02/14 git p4: rearrange and simplify hasOrigin handlingPete Wyckoff, Jan 15, 2013
  4. 03/14 git p4: add comments to p4BranchesInGitPete Wyckoff, Jan 15, 2013
  5. 04/14 git p4: inline listExistingP4GitBranchesPete Wyckoff, Jan 15, 2013
  6. 05/14 git p4: create p4/HEAD on initial clonePete Wyckoff, Jan 15, 2013
  7. 06/14 git p4: verify expected refs in clone --bare testPete Wyckoff, Jan 15, 2013
  8. 07/14 git p4: clone --branch should checkout masterPete Wyckoff, Jan 15, 2013
  9. 08/14 git p4 doc: fix branch detection examplePete Wyckoff, Jan 15, 2013
  10. 09/14 git p4: allow short ref names to --branchPete Wyckoff, Jan 15, 2013
  11. 10/14 git p4: rearrange self.initialParent usePete Wyckoff, Jan 15, 2013
  12. 11/14 git p4: fail gracefully on sync with no master branchPete Wyckoff, Jan 15, 2013
  13. 12/14 git p4: fix sync --branch when no master branchPete Wyckoff, Jan 15, 2013
  14. 13/14 git p4 test: keep P4CLIENT changes inside subshellsPete Wyckoff, Jan 15, 2013
  15. 14/14 git p4: fix submit when no master branchPete Wyckoff, Jan 15, 2013

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.