]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t/t5505-remote: test failure of set-head
authorBence Ferdinandy <bence@ferdinandy.com>
Fri, 22 Nov 2024 12:28:43 +0000 (13:28 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 25 Nov 2024 02:46:34 +0000 (11:46 +0900)
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>
builtin/remote.c
t/t5505-remote.sh

index 76670ddd8b44e5b118c76522613c445ad92c5364..8a182439f21cc1f5b521d63dbff0500166dc4211 100644 (file)
@@ -1445,7 +1445,7 @@ static int set_head(int argc, const char **argv, const char *prefix)
                if (!refs_ref_exists(get_main_ref_store(the_repository), buf2.buf))
                        result |= error(_("Not a valid ref: %s"), buf2.buf);
                else if (refs_update_symref(get_main_ref_store(the_repository), buf.buf, buf2.buf, "remote set-head"))
-                       result |= error(_("Could not setup %s"), buf.buf);
+                       result |= error(_("Could not set up %s"), buf.buf);
                else if (opt_a)
                        printf("%s/HEAD set to %s\n", argv[0], head_name);
                free(head_name);
index 9b50276646c27890fd27bb6d85b6ea269d906903..61e3ecc1af3136a818553e6e8f844b322187bbf5 100755 (executable)
@@ -432,6 +432,18 @@ test_expect_success 'set-head --auto' '
        )
 '
 
+test_expect_success REFFILES 'set-head --auto failure' '
+       test_when_finished "rm -f test/.git/refs/remotes/origin/HEAD.lock" &&
+       (
+               cd test &&
+               touch .git/refs/remotes/origin/HEAD.lock &&
+               test_must_fail git remote set-head --auto origin 2>err &&
+               tail -n1 err >output &&
+               echo "error: Could not set up refs/remotes/origin/HEAD" >expect &&
+               test_cmp expect output
+       )
+'
+
 test_expect_success 'set-head --auto has no problem w/multiple HEADs' '
        (
                cd test &&