]> git.ipfire.org Git - thirdparty/git.git/blame - t/t1514-rev-parse-push.sh
Sync with Git 2.45.1
[thirdparty/git.git] / t / t1514-rev-parse-push.sh
CommitLineData
adfe5d04
JK
1#!/bin/sh
2
3test_description='test <branch>@{push} syntax'
06d53148 4GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
5export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
80d32e84 7TEST_PASSES_SANITIZE_LEAK=true
adfe5d04
JK
8. ./test-lib.sh
9
10resolve () {
11 echo "$2" >expect &&
12 git rev-parse --symbolic-full-name "$1" >actual &&
13 test_cmp expect actual
14}
15
16test_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 &&
06d53148
JS
23 git branch --set-upstream-to=origin/main main &&
24 git branch --track topic origin/main &&
adfe5d04
JK
25 git push origin topic &&
26 git push other topic
27'
28
29test_expect_success '@{push} with default=nothing' '
30 test_config push.default nothing &&
06d53148
JS
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}
adfe5d04
JK
34'
35
36test_expect_success '@{push} with default=simple' '
37 test_config push.default simple &&
06d53148
JS
38 resolve main@{push} refs/remotes/origin/main &&
39 resolve main@{PUSH} refs/remotes/origin/main &&
40 resolve main@{pUSh} refs/remotes/origin/main
adfe5d04
JK
41'
42
43test_expect_success 'triangular @{push} fails with default=simple' '
44 test_config push.default simple &&
45 test_must_fail git rev-parse topic@{push}
46'
47
48test_expect_success '@{push} with default=current' '
49 test_config push.default current &&
50 resolve topic@{push} refs/remotes/origin/topic
51'
52
53test_expect_success '@{push} with default=matching' '
54 test_config push.default matching &&
55 resolve topic@{push} refs/remotes/origin/topic
56'
57
58test_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
62'
63
64test_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
69'
70
b10731f4
KM
71test_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}
75'
76
adfe5d04 77test_done