3 test_description
='check the consisitency of behavior of --all and --branches'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK
=true
17 echo "delete ${arg}" >>deletes
19 git
-C $dir update-ref
--stdin < deletes
22 test_expect_success
'setup bare remote' '
23 git init --bare remote-1 &&
24 git -C remote-1 config gc.auto 0 &&
26 git push remote-1 HEAD
29 test_expect_success
'setup different types of references' '
31 update refs/heads/branch-1 HEAD
32 update refs/heads/branch-2 HEAD
35 git tag -a -m "annotated" annotated-1 HEAD &&
36 git tag -a -m "annotated" annotated-2 HEAD &&
37 git update-ref --stdin < refs
40 test_expect_success
'--all and --branches have the same behavior' '
41 test_when_finished "delete_refs remote-1 \
43 refs/heads/branch-2" &&
44 git push remote-1 --all &&
45 commit=$(git rev-parse HEAD) &&
47 $commit refs/heads/branch-1
48 $commit refs/heads/branch-2
49 $commit refs/heads/main
52 git -C remote-1 show-ref --heads >actual.all &&
53 delete_refs remote-1 refs/heads/branch-1 refs/heads/branch-2 &&
54 git push remote-1 --branches &&
55 git -C remote-1 show-ref --heads >actual.branches &&
56 test_cmp actual.all actual.branches &&
57 test_cmp expect actual.all
60 test_expect_success
'--all or --branches can not be combined with refspecs' '
61 test_must_fail git push remote-1 --all main >actual.all 2>&1 &&
62 test_must_fail git push remote-1 --branches main >actual.branches 2>&1 &&
63 test_cmp actual.all actual.branches &&
64 grep "be combined with refspecs" actual.all
67 test_expect_success
'--all or --branches can not be combined with --mirror' '
68 test_must_fail git push remote-1 --all --mirror >actual.all 2>&1 &&
69 test_must_fail git push remote-1 --branches --mirror >actual.branches 2>&1 &&
70 test_cmp actual.all actual.branches &&
71 grep "cannot be used together" actual.all
74 test_expect_success
'--all or --branches can not be combined with --tags' '
75 test_must_fail git push remote-1 --all --tags >actual.all 2>&1 &&
76 test_must_fail git push remote-1 --branches --tags >actual.branches 2>&1 &&
77 test_cmp actual.all actual.branches &&
78 grep "cannot be used together" actual.all
82 test_expect_success
'--all or --branches can not be combined with --delete' '
83 test_must_fail git push remote-1 --all --delete >actual.all 2>&1 &&
84 test_must_fail git push remote-1 --branches --delete >actual.branches 2>&1 &&
85 test_cmp actual.all actual.branches &&
86 grep "cannot be used together" actual.all
89 test_expect_success
'--all or --branches combines with --follow-tags have same behavior' '
90 test_when_finished "delete_refs remote-1 \
93 refs/tags/annotated-1 \
94 refs/tags/annotated-2" &&
95 git push remote-1 --all --follow-tags &&
96 git -C remote-1 show-ref > actual.all &&
98 $commit refs/heads/branch-1
99 $commit refs/heads/branch-2
100 $commit refs/heads/main
101 $(git rev-parse annotated-1) refs/tags/annotated-1
102 $(git rev-parse annotated-2) refs/tags/annotated-2
105 delete_refs remote-1 \
106 refs/heads/branch-1 \
107 refs/heads/branch-2 \
108 refs/tags/annotated-1 \
109 refs/tags/annotated-2 &&
110 git push remote-1 --branches --follow-tags &&
111 git -C remote-1 show-ref >actual.branches &&
112 test_cmp actual.all actual.branches &&
113 test_cmp expect actual.all