diff options
Diffstat (limited to 't/t1507-rev-parse-upstream.sh')
-rwxr-xr-x | t/t1507-rev-parse-upstream.sh | 58 |
1 files changed, 47 insertions, 11 deletions
diff --git a/t/t1507-rev-parse-upstream.sh b/t/t1507-rev-parse-upstream.sh index d6e576192f..1978947c41 100755 --- a/t/t1507-rev-parse-upstream.sh +++ b/t/t1507-rev-parse-upstream.sh @@ -17,6 +17,9 @@ test_expect_success 'setup' ' test_commit 4 && git branch --track my-side origin/side && git branch --track local-master master && + git branch --track fun@ny origin/side && + git branch --track @funny origin/side && + git branch --track funny@ origin/side && git remote add -t master master-only .. && git fetch master-only && git branch bad-upstream && @@ -54,6 +57,28 @@ test_expect_success 'my-side@{upstream} resolves to correct full name' ' test refs/remotes/origin/side = "$(full_name my-side@{u})" ' +test_expect_success 'upstream of branch with @ in middle' ' + full_name fun@ny@{u} >actual && + echo refs/remotes/origin/side >expect && + test_cmp expect actual +' + +test_expect_success 'upstream of branch with @ at start' ' + full_name @funny@{u} >actual && + echo refs/remotes/origin/side >expect && + test_cmp expect actual +' + +test_expect_success 'upstream of branch with @ at end' ' + full_name funny@@{u} >actual && + echo refs/remotes/origin/side >expect && + test_cmp expect actual +' + +test_expect_success 'refs/heads/my-side@{upstream} does not resolve to my-side{upstream}' ' + test_must_fail full_name refs/heads/my-side@{upstream} +' + test_expect_success 'my-side@{u} resolves to correct commit' ' git checkout side && test_commit 5 && @@ -96,7 +121,7 @@ test_expect_success 'merge my-side@{u} records the correct name' ' git branch -D new ;# can fail but is ok git branch -t new my-side@{u} && git merge -s ours new@{u} && - git show -s --pretty=format:%s >actual && + git show -s --pretty=tformat:%s >actual && echo "Merge remote-tracking branch ${sq}origin/side${sq}" >expect && test_cmp expect actual ) @@ -125,8 +150,7 @@ test_expect_success 'branch@{u} works when tracking a local branch' ' test_expect_success 'branch@{u} error message when no upstream' ' cat >expect <<-EOF && - error: No upstream configured for branch ${sq}non-tracking${sq} - fatal: Needed a single revision + fatal: No upstream configured for branch ${sq}non-tracking${sq} EOF error_message non-tracking@{u} 2>actual && test_i18ncmp expect actual @@ -134,8 +158,7 @@ test_expect_success 'branch@{u} error message when no upstream' ' test_expect_success '@{u} error message when no upstream' ' cat >expect <<-EOF && - error: No upstream configured for branch ${sq}master${sq} - fatal: Needed a single revision + fatal: No upstream configured for branch ${sq}master${sq} EOF test_must_fail git rev-parse --verify @{u} 2>actual && test_i18ncmp expect actual @@ -143,8 +166,7 @@ test_expect_success '@{u} error message when no upstream' ' test_expect_success 'branch@{u} error message with misspelt branch' ' cat >expect <<-EOF && - error: No such branch: ${sq}no-such-branch${sq} - fatal: Needed a single revision + fatal: No such branch: ${sq}no-such-branch${sq} EOF error_message no-such-branch@{u} 2>actual && test_i18ncmp expect actual @@ -152,8 +174,7 @@ test_expect_success 'branch@{u} error message with misspelt branch' ' test_expect_success '@{u} error message when not on a branch' ' cat >expect <<-EOF && - error: HEAD does not point to a branch - fatal: Needed a single revision + fatal: HEAD does not point to a branch EOF git checkout HEAD^0 && test_must_fail git rev-parse --verify @{u} 2>actual && @@ -162,8 +183,7 @@ test_expect_success '@{u} error message when not on a branch' ' test_expect_success 'branch@{u} error message if upstream branch not fetched' ' cat >expect <<-EOF && - error: Upstream branch ${sq}refs/heads/side${sq} not stored as a remote-tracking branch - fatal: Needed a single revision + fatal: Upstream branch ${sq}refs/heads/side${sq} not stored as a remote-tracking branch EOF error_message bad-upstream@{u} 2>actual && test_i18ncmp expect actual @@ -211,4 +231,20 @@ test_expect_success 'log -g other@{u}@{now}' ' test_cmp expect actual ' +test_expect_success '@{reflog}-parsing does not look beyond colon' ' + echo content >@{yesterday} && + git add @{yesterday} && + git commit -m "funny reflog file" && + git hash-object @{yesterday} >expect && + git rev-parse HEAD:@{yesterday} >actual +' + +test_expect_success '@{upstream}-parsing does not look beyond colon' ' + echo content >@{upstream} && + git add @{upstream} && + git commit -m "funny upstream file" && + git hash-object @{upstream} >expect && + git rev-parse HEAD:@{upstream} >actual +' + test_done |