From 26ef8872f1ccb095ef7d263edac1e844d6516bfd Mon Sep 17 00:00:00 2001 From: Jonas Brandstötter Date: Tue, 22 Jul 2025 21:09:22 +0200 Subject: t7510: add test cases for non-absolute gpg program MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These cases cover scenarios where `gpg.program` is set as a program in `$PATH` or as a path relative to the user's home directory. Signed-off-by: Jonas Brandstötter Signed-off-by: Junio C Hamano --- t/t7510-signed-commit.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh index 39677e859a..95d2ebe277 100755 --- a/t/t7510-signed-commit.sh +++ b/t/t7510-signed-commit.sh @@ -449,7 +449,17 @@ test_expect_success 'custom `gpg.program`' ' test_must_fail env LET_GPG_PROGRAM_FAIL=1 \ git commit -S --allow-empty -m must-fail 2>err && - grep zOMG err + grep zOMG err && + + # `gpg.program` starts with `~`, the path should be interpreted to be relative to `$HOME` + test_config gpg.program "~/fake-gpg" && + env HOME="$(pwd)" \ + git commit -S --allow-empty -m signed-commit && + + # `gpg.program` does not specify an absolute path, it should find a program in `$PATH` + test_config gpg.program "fake-gpg" && + env PATH="$(pwd):$PATH" \ + git commit -S --allow-empty -m signed-commit ' test_done -- cgit v1.3 From c26ecaf069080c6f9f98925530394a5b4c53e325 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 25 Jul 2025 01:13:09 -0400 Subject: t7510: use $PWD instead of $(pwd) inside PATH On Windows, $(pwd) will give us a Windows-style path like "D:/foo". Putting that into $PATH confuses anybody parsing that variable, since colon is a separator character in $PATH. Instead, we should use the Unix-style value we get from $PWD ("/d/foo"). This is similar to the cases fixed by 71dd50472d (t0021, t5615: use $PWD instead of $(pwd) in PATH-like shell variables, 2016-11-11). Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t7510-signed-commit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh index 95d2ebe277..1201c85ba6 100755 --- a/t/t7510-signed-commit.sh +++ b/t/t7510-signed-commit.sh @@ -458,7 +458,7 @@ test_expect_success 'custom `gpg.program`' ' # `gpg.program` does not specify an absolute path, it should find a program in `$PATH` test_config gpg.program "fake-gpg" && - env PATH="$(pwd):$PATH" \ + env PATH="$PWD:$PATH" \ git commit -S --allow-empty -m signed-commit ' -- cgit v1.3