Skip to content

Commit b441717

Browse files
Denton-Lgitster
authored andcommitted
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 28fb843 (Introduce <branch>@{upstream} notation, 2009-09-10), the `git -C` option wasn't available yet (since it was introduced in 44e1e4d (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9291e63 commit b441717

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

t/t1507-rev-parse-upstream.sh

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ test_expect_success 'setup' '
2828
)
2929
'
3030

31-
full_name () {
32-
(cd clone &&
33-
git rev-parse --symbolic-full-name "$@")
34-
}
35-
3631
commit_subject () {
3732
(cd clone &&
3833
git show -s --pretty=tformat:%s "$@")
@@ -45,50 +40,50 @@ error_message () {
4540

4641
test_expect_success '@{upstream} resolves to correct full name' '
4742
echo refs/remotes/origin/master >expect &&
48-
full_name @{upstream} >actual &&
43+
git -C clone rev-parse --symbolic-full-name @{upstream} >actual &&
4944
test_cmp expect actual &&
50-
full_name @{UPSTREAM} >actual &&
45+
git -C clone rev-parse --symbolic-full-name @{UPSTREAM} >actual &&
5146
test_cmp expect actual &&
52-
full_name @{UpSTReam} >actual &&
47+
git -C clone rev-parse --symbolic-full-name @{UpSTReam} >actual &&
5348
test_cmp expect actual
5449
'
5550

5651
test_expect_success '@{u} resolves to correct full name' '
5752
echo refs/remotes/origin/master >expect &&
58-
full_name @{u} >actual &&
53+
git -C clone rev-parse --symbolic-full-name @{u} >actual &&
5954
test_cmp expect actual &&
60-
full_name @{U} >actual &&
55+
git -C clone rev-parse --symbolic-full-name @{U} >actual &&
6156
test_cmp expect actual
6257
'
6358

6459
test_expect_success 'my-side@{upstream} resolves to correct full name' '
6560
echo refs/remotes/origin/side >expect &&
66-
full_name my-side@{u} >actual &&
61+
git -C clone rev-parse --symbolic-full-name my-side@{u} >actual &&
6762
test_cmp expect actual
6863
'
6964

7065
test_expect_success 'upstream of branch with @ in middle' '
71-
full_name fun@ny@{u} >actual &&
66+
git -C clone rev-parse --symbolic-full-name fun@ny@{u} >actual &&
7267
echo refs/remotes/origin/side >expect &&
7368
test_cmp expect actual &&
74-
full_name fun@ny@{U} >actual &&
69+
git -C clone rev-parse --symbolic-full-name fun@ny@{U} >actual &&
7570
test_cmp expect actual
7671
'
7772

7873
test_expect_success 'upstream of branch with @ at start' '
79-
full_name @funny@{u} >actual &&
74+
git -C clone rev-parse --symbolic-full-name @funny@{u} >actual &&
8075
echo refs/remotes/origin/side >expect &&
8176
test_cmp expect actual
8277
'
8378

8479
test_expect_success 'upstream of branch with @ at end' '
85-
full_name funny@@{u} >actual &&
80+
git -C clone rev-parse --symbolic-full-name funny@@{u} >actual &&
8681
echo refs/remotes/origin/side >expect &&
8782
test_cmp expect actual
8883
'
8984

9085
test_expect_success 'refs/heads/my-side@{upstream} does not resolve to my-side{upstream}' '
91-
test_must_fail full_name refs/heads/my-side@{upstream}
86+
test_must_fail git -C clone rev-parse --symbolic-full-name refs/heads/my-side@{upstream}
9287
'
9388

9489
test_expect_success 'my-side@{u} resolves to correct commit' '
@@ -103,9 +98,9 @@ test_expect_success 'my-side@{u} resolves to correct commit' '
10398
'
10499

105100
test_expect_success 'not-tracking@{u} fails' '
106-
test_must_fail full_name non-tracking@{u} &&
101+
test_must_fail git -C clone rev-parse --symbolic-full-name non-tracking@{u} &&
107102
(cd clone && git checkout --no-track -b non-tracking) &&
108-
test_must_fail full_name non-tracking@{u}
103+
test_must_fail git -C clone rev-parse --symbolic-full-name non-tracking@{u}
109104
'
110105

111106
test_expect_success '<branch>@{u}@{1} resolves correctly' '
@@ -165,7 +160,7 @@ test_expect_success 'checkout other@{u}' '
165160

166161
test_expect_success 'branch@{u} works when tracking a local branch' '
167162
echo refs/heads/master >expect &&
168-
full_name local-master@{u} >actual &&
163+
git -C clone rev-parse --symbolic-full-name local-master@{u} >actual &&
169164
test_cmp expect actual
170165
'
171166

@@ -221,7 +216,7 @@ test_expect_success 'pull works when tracking a local branch' '
221216
# makes sense if the previous one succeeded
222217
test_expect_success '@{u} works when tracking a local branch' '
223218
echo refs/heads/master >expect &&
224-
full_name @{u} >actual &&
219+
git -C clone rev-parse --symbolic-full-name @{u} >actual &&
225220
test_cmp expect actual
226221
'
227222

0 commit comments

Comments
 (0)