Merge branch 'jk/repack-leakfix'
[git.git] / t / t1514-rev-parse-push.sh
bloba835a196aa81be9e7aa79f38c3977a03b71b5336
1 #!/bin/sh
3 test_description='test <branch>@{push} syntax'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 TEST_PASSES_SANITIZE_LEAK=true
8 . ./test-lib.sh
10 resolve () {
11 echo "$2" >expect &&
12 git rev-parse --symbolic-full-name "$1" >actual &&
13 test_cmp expect actual
16 test_expect_success 'setup' '
17 git init --bare parent.git &&
18 git init --bare other.git &&
19 git remote add origin parent.git &&
20 git remote add other other.git &&
21 test_commit base &&
22 git push origin HEAD &&
23 git branch --set-upstream-to=origin/main main &&
24 git branch --track topic origin/main &&
25 git push origin topic &&
26 git push other topic
29 test_expect_success '@{push} with default=nothing' '
30 test_config push.default nothing &&
31 test_must_fail git rev-parse main@{push} &&
32 test_must_fail git rev-parse main@{PUSH} &&
33 test_must_fail git rev-parse main@{PuSH}
36 test_expect_success '@{push} with default=simple' '
37 test_config push.default simple &&
38 resolve main@{push} refs/remotes/origin/main &&
39 resolve main@{PUSH} refs/remotes/origin/main &&
40 resolve main@{pUSh} refs/remotes/origin/main
43 test_expect_success 'triangular @{push} fails with default=simple' '
44 test_config push.default simple &&
45 test_must_fail git rev-parse topic@{push}
48 test_expect_success '@{push} with default=current' '
49 test_config push.default current &&
50 resolve topic@{push} refs/remotes/origin/topic
53 test_expect_success '@{push} with default=matching' '
54 test_config push.default matching &&
55 resolve topic@{push} refs/remotes/origin/topic
58 test_expect_success '@{push} with pushremote defined' '
59 test_config push.default current &&
60 test_config branch.topic.pushremote other &&
61 resolve topic@{push} refs/remotes/other/topic
64 test_expect_success '@{push} with push refspecs' '
65 test_config push.default nothing &&
66 test_config remote.origin.push refs/heads/*:refs/heads/magic/* &&
67 git push &&
68 resolve topic@{push} refs/remotes/origin/magic/topic
71 test_expect_success 'resolving @{push} fails with a detached HEAD' '
72 git checkout HEAD^0 &&
73 test_when_finished "git checkout -" &&
74 test_must_fail git rev-parse @{push}
77 test_done