]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t7500: fix GIT_EDITOR shell snippet
authorJunio C Hamano <gitster@pobox.com>
Mon, 6 Oct 2025 20:07:18 +0000 (13:07 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 7 Oct 2025 17:05:40 +0000 (10:05 -0700)
2140b140 (commit: error out for missing commit message template,
2011-02-25) defined

    GIT_EDITOR="echo hello >\"\$1\""

for these two tests, with the intention that 'hello' would be
written in the given file, but as Phillip Wood points out,
GIT_EDITOR is invoked by shell after getting expanded to

    sh -c 'echo hello >"$1" "$@"' 'echo hello >"$1"' path/to/file

which is not what we want.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7500-commit-template-squash-signoff.sh

index 05cda50186f0eef938cdb3a750bfe1b5d1af7f39..4922543256bdd5fbe5b16f36bf81a624c9ae746f 100755 (executable)
@@ -31,7 +31,7 @@ test_expect_success 'nonexistent template file should return error' '
        echo changes >> foo &&
        git add foo &&
        (
-               GIT_EDITOR="echo hello >\"\$1\"" &&
+               GIT_EDITOR="echo hello >" &&
                export GIT_EDITOR &&
                test_must_fail git commit --template "$PWD"/notexist
        )
@@ -40,7 +40,7 @@ test_expect_success 'nonexistent template file should return error' '
 test_expect_success 'nonexistent template file in config should return error' '
        test_config commit.template "$PWD"/notexist &&
        (
-               GIT_EDITOR="echo hello >\"\$1\"" &&
+               GIT_EDITOR="echo hello >" &&
                export GIT_EDITOR &&
                test_must_fail git commit --allow-empty
        )