]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fetch: add a test to exercise invalid output formats
authorPatrick Steinhardt <ps@pks.im>
Wed, 10 May 2023 12:34:11 +0000 (14:34 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 10 May 2023 17:35:24 +0000 (10:35 -0700)
Add a testcase that exercises the logic when an invalid output format is
passed via the `fetch.output` configuration.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t5574-fetch-output.sh

index f91b654d38653e8bd09c18732c2a6d194f4fb67f..8a344e679099366beaf8e9832b4f98d145ab56c9 100755 (executable)
@@ -7,6 +7,30 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
 . ./test-lib.sh
 
+test_expect_success 'fetch with invalid output format configuration' '
+       test_when_finished "rm -rf clone" &&
+       git clone . clone &&
+
+       test_must_fail git -C clone -c fetch.output fetch origin 2>actual.err &&
+       cat >expect <<-EOF &&
+       error: missing value for ${SQ}fetch.output${SQ}
+       fatal: unable to parse ${SQ}fetch.output${SQ} from command-line config
+       EOF
+       test_cmp expect actual.err &&
+
+       test_must_fail git -C clone -c fetch.output= fetch origin 2>actual.err &&
+       cat >expect <<-EOF &&
+       fatal: invalid value for ${SQ}fetch.output${SQ}: ${SQ}${SQ}
+       EOF
+       test_cmp expect actual.err &&
+
+       test_must_fail git -C clone -c fetch.output=garbage fetch origin 2>actual.err &&
+       cat >expect <<-EOF &&
+       fatal: invalid value for ${SQ}fetch.output${SQ}: ${SQ}garbage${SQ}
+       EOF
+       test_cmp expect actual.err
+'
+
 test_expect_success 'fetch aligned output' '
        git clone . full-output &&
        test_commit looooooooooooong-tag &&