Thread (3 messages) 3 messages, 2 authors, 2022-01-21

Re: [GSoC] [PATCH 1/1] t0001: replace "test [-d|-f]" with test_path_is_* functions

From: Taylor Blau <hidden>
Date: 2022-01-21 18:47:08

Hi Shaoxuan,

On Fri, Jan 21, 2022 at 06:21:09PM +0800, Shaoxuan Yuan wrote:
quoted hunk ↗ jump to hunk
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 3235ab4d53..c72a28d3a5 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -6,7 +6,7 @@ TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh

 check_config () {
-	if test -d "$1" && test -f "$1/config" && test -d "$1/refs"
+	if test_path_is_dir "$1" && test_path_is_file "$1/config" && test_path_is_dir "$1/refs"
 	then
 		: happy
 	else
Looks very reasonable to me. Indeed, this line comes from 6adcca3fe8
(Fix initialization of a bare repository, 2007-08-27) which predates
2caf20c52b (test-lib: user-friendly alternatives to test [-d|-f|-e],
2010-08-10) when these helpers were originally introduced.

I thought that we could probably just shorten this to calling
"test_path_is_file" twice: once for "$1/config" and a second time for
"$1/refs", but that assumes "$1" is non-empty. And to ensure that you'd
need another check, which amounts to the same amount of code overall.

So the fix here looks good to me, and thanks for your contribution!

Thanks,
Taylor
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help