summaryrefslogtreecommitdiff
path: root/t/t1507-rev-parse-upstream.sh
diff options
context:
space:
mode:
authorDenton Liu <liu.denton@gmail.com>2019-12-20 18:16:02 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-12-20 19:30:45 (GMT)
commitb44171725646880db07cbee6446e15b4afaa1930 (patch)
tree45aa573c98f021a7bd5b866e74b421eda1ad61fe /t/t1507-rev-parse-upstream.sh
parent9291e6329ef3333f9447b0b4cdec0607e00c39cf (diff)
downloadgit-b44171725646880db07cbee6446e15b4afaa1930.zip
git-b44171725646880db07cbee6446e15b4afaa1930.tar.gz
git-b44171725646880db07cbee6446e15b4afaa1930.tar.bz2
t1507: inline full_name()
Before, we were running `test_must_fail full_name`. However, `test_must_fail` should only be used on git commands. Inline full_name() so that we can use test_must_fail on the git command directly. When full_name() was introduced in 28fb84382b (Introduce <branch>@{upstream} notation, 2009-09-10), the `git -C` option wasn't available yet (since it was introduced in 44e1e4d67d (git: run in a directory given with -C option, 2013-09-09)). As a result, the helper function removed the need to manually cd each time. However, since `git -C` is available now, we can just use that instead and inline full_name(). An alternate approach was taken where we taught full_name() to accept an optional `!` arg to trigger test_must_fail behavior. However, this added more unnecessary complexity than inlining so we inline instead. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1507-rev-parse-upstream.sh')
-rwxr-xr-xt/t1507-rev-parse-upstream.sh35
1 files changed, 15 insertions, 20 deletions
diff --git a/t/t1507-rev-parse-upstream.sh b/t/t1507-rev-parse-upstream.sh
index f68b77e..dfc0d96 100755
--- a/t/t1507-rev-parse-upstream.sh
+++ b/t/t1507-rev-parse-upstream.sh
@@ -28,11 +28,6 @@ test_expect_success 'setup' '
)
'
-full_name () {
- (cd clone &&
- git rev-parse --symbolic-full-name "$@")
-}
-
commit_subject () {
(cd clone &&
git show -s --pretty=tformat:%s "$@")
@@ -45,50 +40,50 @@ error_message () {
test_expect_success '@{upstream} resolves to correct full name' '
echo refs/remotes/origin/master >expect &&
- full_name @{upstream} >actual &&
+ git -C clone rev-parse --symbolic-full-name @{upstream} >actual &&
test_cmp expect actual &&
- full_name @{UPSTREAM} >actual &&
+ git -C clone rev-parse --symbolic-full-name @{UPSTREAM} >actual &&
test_cmp expect actual &&
- full_name @{UpSTReam} >actual &&
+ git -C clone rev-parse --symbolic-full-name @{UpSTReam} >actual &&
test_cmp expect actual
'
test_expect_success '@{u} resolves to correct full name' '
echo refs/remotes/origin/master >expect &&
- full_name @{u} >actual &&
+ git -C clone rev-parse --symbolic-full-name @{u} >actual &&
test_cmp expect actual &&
- full_name @{U} >actual &&
+ git -C clone rev-parse --symbolic-full-name @{U} >actual &&
test_cmp expect actual
'
test_expect_success 'my-side@{upstream} resolves to correct full name' '
echo refs/remotes/origin/side >expect &&
- full_name my-side@{u} >actual &&
+ git -C clone rev-parse --symbolic-full-name my-side@{u} >actual &&
test_cmp expect actual
'
test_expect_success 'upstream of branch with @ in middle' '
- full_name fun@ny@{u} >actual &&
+ git -C clone rev-parse --symbolic-full-name fun@ny@{u} >actual &&
echo refs/remotes/origin/side >expect &&
test_cmp expect actual &&
- full_name fun@ny@{U} >actual &&
+ git -C clone rev-parse --symbolic-full-name fun@ny@{U} >actual &&
test_cmp expect actual
'
test_expect_success 'upstream of branch with @ at start' '
- full_name @funny@{u} >actual &&
+ git -C clone rev-parse --symbolic-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 &&
+ git -C clone rev-parse --symbolic-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_must_fail git -C clone rev-parse --symbolic-full-name refs/heads/my-side@{upstream}
'
test_expect_success 'my-side@{u} resolves to correct commit' '
@@ -103,9 +98,9 @@ test_expect_success 'my-side@{u} resolves to correct commit' '
'
test_expect_success 'not-tracking@{u} fails' '
- test_must_fail full_name non-tracking@{u} &&
+ test_must_fail git -C clone rev-parse --symbolic-full-name non-tracking@{u} &&
(cd clone && git checkout --no-track -b non-tracking) &&
- test_must_fail full_name non-tracking@{u}
+ test_must_fail git -C clone rev-parse --symbolic-full-name non-tracking@{u}
'
test_expect_success '<branch>@{u}@{1} resolves correctly' '
@@ -165,7 +160,7 @@ test_expect_success 'checkout other@{u}' '
test_expect_success 'branch@{u} works when tracking a local branch' '
echo refs/heads/master >expect &&
- full_name local-master@{u} >actual &&
+ git -C clone rev-parse --symbolic-full-name local-master@{u} >actual &&
test_cmp expect actual
'
@@ -221,7 +216,7 @@ test_expect_success 'pull works when tracking a local branch' '
# makes sense if the previous one succeeded
test_expect_success '@{u} works when tracking a local branch' '
echo refs/heads/master >expect &&
- full_name @{u} >actual &&
+ git -C clone rev-parse --symbolic-full-name @{u} >actual &&
test_cmp expect actual
'