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 <bence@ferdinandy.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Bence Ferdinandy committed Nov 22, 2024 at 13:28 UTC 2fd55558950bdfe43fd28ca17b50691427842c35
2 files changed +13 -1
builtin/remote.c
+1 -1
@@ -1445,7 +1445,7 @@ static int set_head(int argc, const char **argv, const char *prefix)
1445 if (!refs_ref_exists(get_main_ref_store(the_repository), buf2.buf))
1446 result |= error(_("Not a valid ref: %s"), buf2.buf);
1447 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);
1449 else if (opt_a)
1450 printf("%s/HEAD set to %s\n", argv[0], head_name);
1451 free(head_name);
t/t5505-remote.sh
+12
@@ -432,6 +432,18 @@ test_expect_success 'set-head --auto' '
432 )
433 '
434
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 +
447 test_expect_success 'set-head --auto has no problem w/multiple HEADs' '
448 (
449 cd test &&