Skip to content

Commit 2fd5555

Browse files
ferdinandybgitster
authored andcommitted
t/t5505-remote: test failure of set-head
The test coverage was missing a test for the failure branch of remote set-head auto's output. Add the missing text and while we are at it, correct a small grammatical mistake in the error's output ("setup" is the noun, "set up" is the verb). Signed-off-by: Bence Ferdinandy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 54d820d commit 2fd5555

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

builtin/remote.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1445,7 +1445,7 @@ static int set_head(int argc, const char **argv, const char *prefix)
14451445
if (!refs_ref_exists(get_main_ref_store(the_repository), buf2.buf))
14461446
result |= error(_("Not a valid ref: %s"), buf2.buf);
14471447
else if (refs_update_symref(get_main_ref_store(the_repository), buf.buf, buf2.buf, "remote set-head"))
1448-
result |= error(_("Could not setup %s"), buf.buf);
1448+
result |= error(_("Could not set up %s"), buf.buf);
14491449
else if (opt_a)
14501450
printf("%s/HEAD set to %s\n", argv[0], head_name);
14511451
free(head_name);

t/t5505-remote.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,18 @@ test_expect_success 'set-head --auto' '
432432
)
433433
'
434434

435+
test_expect_success REFFILES 'set-head --auto failure' '
436+
test_when_finished "rm -f test/.git/refs/remotes/origin/HEAD.lock" &&
437+
(
438+
cd test &&
439+
touch .git/refs/remotes/origin/HEAD.lock &&
440+
test_must_fail git remote set-head --auto origin 2>err &&
441+
tail -n1 err >output &&
442+
echo "error: Could not set up refs/remotes/origin/HEAD" >expect &&
443+
test_cmp expect output
444+
)
445+
'
446+
435447
test_expect_success 'set-head --auto has no problem w/multiple HEADs' '
436448
(
437449
cd test &&

0 commit comments

Comments
 (0)