3 test_description
='test <branch>@{upstream} syntax'
8 test_expect_success
'setup' '
11 git checkout -b side &&
13 git checkout master &&
18 git branch --track my-side origin/side)
24 git rev-parse
--symbolic-full-name "$@")
29 git show
-s --pretty=format
:%s
"$@")
32 test_expect_success
'@{upstream} resolves to correct full name' '
33 test refs/remotes/origin/master = "$(full_name @{upstream})"
36 test_expect_success
'@{u} resolves to correct full name' '
37 test refs/remotes/origin/master = "$(full_name @{u})"
40 test_expect_success
'my-side@{upstream} resolves to correct full name' '
41 test refs/remotes/origin/side = "$(full_name my-side@{u})"
44 test_expect_success
'my-side@{u} resolves to correct commit' '
47 (cd clone && git fetch) &&
48 test 2 = "$(commit_subject my-side)" &&
49 test 5 = "$(commit_subject my-side@{u})"
52 test_expect_success
'not-tracking@{u} fails' '
53 test_must_fail full_name non-tracking@{u} &&
54 (cd clone && git checkout --no-track -b non-tracking) &&
55 test_must_fail full_name non-tracking@{u}
58 test_expect_success
'<branch>@{u}@{1} resolves correctly' '
60 (cd clone && git fetch) &&
61 test 5 = $(commit_subject my-side@{u}@{1})
64 test_expect_success
'@{u} without specifying branch fails on a detached HEAD' '
65 git checkout HEAD^0 &&
66 test_must_fail git rev-parse @{u}
69 test_expect_success
'checkout -b new my-side@{u} forks from the same' '
72 git checkout -b new my-side@{u} &&
73 git rev-parse --symbolic-full-name my-side@{u} >expect &&
74 git rev-parse --symbolic-full-name new@{u} >actual &&
75 test_cmp expect actual
79 test_expect_success
'merge my-side@{u} records the correct name' '
83 git checkout master || exit
84 git branch -D new ;# can fail but is ok
85 git branch -t new my-side@{u} &&
86 git merge -s ours new@{u} &&
87 git show -s --pretty=format:%s >actual &&
88 echo "Merge remote branch ${sq}origin/side${sq}" >expect &&
89 test_cmp expect actual
93 test_expect_success
'branch -d other@{u}' '
94 git checkout -t -b other master &&
96 git for-each-ref refs/heads/master >actual &&
98 test_cmp expect actual
101 test_expect_success
'checkout other@{u}' '
102 git branch -f master HEAD &&
103 git checkout -t -b another master &&
105 git symbolic-ref HEAD >actual &&
106 echo refs/heads/master >expect &&
107 test_cmp expect actual