Skip to content

Commit 46738bd

Browse files
Pete Wyckoffgitster
authored andcommitted
git p4: test sync/clone --branch behavior
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e4f59a3 commit 46738bd

File tree

1 file changed

+49
-4
lines changed

1 file changed

+49
-4
lines changed

t/t9806-git-p4-options.sh

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,59 @@ test_expect_success 'clone no --git-dir' '
2727
test_must_fail git p4 clone --git-dir=xx //depot
2828
'
2929

30-
test_expect_success 'clone --branch' '
30+
test_expect_failure 'clone --branch should checkout master' '
3131
git p4 clone --branch=refs/remotes/p4/sb --dest="$git" //depot &&
3232
test_when_finished cleanup_git &&
3333
(
3434
cd "$git" &&
35-
git ls-files >files &&
36-
test_line_count = 0 files &&
37-
test_path_is_file .git/refs/remotes/p4/sb
35+
git rev-parse refs/remotes/p4/sb >sb &&
36+
git rev-parse refs/heads/master >master &&
37+
test_cmp sb master &&
38+
git rev-parse HEAD >head &&
39+
test_cmp sb head
40+
)
41+
'
42+
43+
test_expect_failure 'sync when branch is not called master should work' '
44+
git p4 clone --branch=refs/remotes/p4/sb --dest="$git" //depot@2 &&
45+
test_when_finished cleanup_git &&
46+
(
47+
cd "$git" &&
48+
git p4 sync &&
49+
git show -s --format=%s refs/remotes/p4/sb >show &&
50+
grep "change 3" show
51+
)
52+
'
53+
54+
# engages --detect-branches code, which will do filename filtering so
55+
# no sync to either b1 or b2
56+
test_expect_success 'sync when two branches but no master should noop' '
57+
test_when_finished cleanup_git &&
58+
(
59+
cd "$git" &&
60+
git init &&
61+
git p4 sync --branch=refs/remotes/p4/b1 //depot@2 &&
62+
git p4 sync --branch=refs/remotes/p4/b2 //depot@2 &&
63+
git p4 sync &&
64+
git show -s --format=%s refs/remotes/p4/b1 >show &&
65+
grep "Initial import" show &&
66+
git show -s --format=%s refs/remotes/p4/b2 >show &&
67+
grep "Initial import" show
68+
)
69+
'
70+
71+
test_expect_failure 'sync --branch updates specified branch' '
72+
test_when_finished cleanup_git &&
73+
(
74+
cd "$git" &&
75+
git init &&
76+
git p4 sync --branch=refs/remotes/p4/b1 //depot@2 &&
77+
git p4 sync --branch=refs/remotes/p4/b2 //depot@2 &&
78+
git p4 sync --branch=refs/remotes/p4/b2 &&
79+
git show -s --format=%s refs/remotes/p4/b1 >show &&
80+
grep "Initial import" show &&
81+
git show -s --format=%s refs/remotes/p4/b2 >show &&
82+
grep "change 3" show
3883
)
3984
'
4085

0 commit comments

Comments
 (0)