t0001: replace "test [-d|-f]" with test_path_is_* functions
cover t0001: replace "test [-d|-f]" with test_path_is_* functions
As a microproject, I found that the "test [-d|-f]" in t0001 test script can be replaced by appropriate helper functions.
Shaoxuan Yuan (1):
t0001-init.sh use test_path_is_* functions
t/t0001-init.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
2.25.1
PATCH 1/1 t0001: replace "test [-d|-f]" with test_path_is_* functions
--- t/t0001-init.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
t/t0001-init.sh +1 -1
@@ -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
Signature · 1 line
2.25.1
Hi Shaoxuan,
t/t0001-init.sh TEST_PASSES_SANITIZE_LEAK=true · line 12
Quoted 13 lines · Shaoxuan Yuan
t/t0001-init.sh +1
-1@@ -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
Quoted 11 lines · Taylor Blau
t/t0001-init.sh TEST_PASSES_SANITIZE_LEAK=true · line 12
Quoted 5 lines
t/t0001-init.sh +1
-1- 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 elseLooks very reasonable to me. Indeed, this line comes from
6adcca3fe8(Fix initialization of a bare repository, 2007-08-27) which predates2caf20c52b(test-lib: user-friendly alternatives to test [-d|-f|-e], 2010-08-10) when these helpers were originally introduced.
Quoted 4 lines
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.
I had the same thought.
Since the first "$GIT_DIR must be a directory" matters only when the caller is crazy enough to have a bare repository at the root of the filesystem and to think that it is a good idea to say "" is the "$GIT_DIR" (in which case, "test -d ''" would fail, even though the tests for /config and /refs are checking the right thing), I do not see much downside from omitting the first one, but I think that is something we need to do _outside_ the topic of this change, which is purely "modernize, using the helpers we already have, without changing what we do".
Quoted 21 lines · Junio C Hamano
Quoted 11 lines · Taylor Blau
t/t0001-init.sh TEST_PASSES_SANITIZE_LEAK=true · line 12
Quoted 5 lines
t/t0001-init.sh +1
-1- 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 elseLooks very reasonable to me. Indeed, this line comes from
6adcca3fe8(Fix initialization of a bare repository, 2007-08-27) which predates2caf20c52b(test-lib: user-friendly alternatives to test [-d|-f|-e], 2010-08-10) when these helpers were originally introduced.Quoted 4 lines
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.I had the same thought.
Quoted 10 lines
Since the first "$GIT_DIR must be a directory" matters only when the caller is crazy enough to have a bare repository at the root of the filesystem and to think that it is a good idea to say "" is the "$GIT_DIR" (in which case, "test -d ''" would fail, even though the tests for /config and /refs are checking the right thing), I do not see much downside from omitting the first one, but I think that is something we need to do _outside_ the topic of this change, which is purely "modernize, using the helpers we already have, without changing what we do"
Yes I feel the same way, one patch for one thing :)
Hi Junio,
Since I didn't see this change in seen or next, do you plan to apply it?
--
Thanks,
Shaoxuan
Quoted 32 lines · Junio C Hamano
Quoted 11 lines · Taylor Blau
t/t0001-init.sh TEST_PASSES_SANITIZE_LEAK=true · line 12
Quoted 5 lines
t/t0001-init.sh +1
-1- 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 elseLooks very reasonable to me. Indeed, this line comes from
6adcca3fe8(Fix initialization of a bare repository, 2007-08-27) which predates2caf20c52b(test-lib: user-friendly alternatives to test [-d|-f|-e], 2010-08-10) when these helpers were originally introduced.Quoted 4 lines
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.I had the same thought.
Since the first "$GIT_DIR must be a directory" matters only when the caller is crazy enough to have a bare repository at the root of the filesystem and to think that it is a good idea to say "" is the "$GIT_DIR" (in which case, "test -d ''" would fail, even though the tests for /config and /refs are checking the right thing), I do not see much downside from omitting the first one, but I think that is something we need to do _outside_ the topic of this change, which is purely "modernize, using the helpers we already have, without changing what we do".
Quoted 1 line · Shaoxuan Yuan
Since I didn't see this change in seen or next, do you plan to apply it?
I actually wasn't, as my understanding of it was primarily your practice.
Quoted 7 lines · Junio C Hamano
Quoted 1 line · Shaoxuan Yuan
Since I didn't see this change in seen or next, do you plan to apply it?
I actually wasn't, as my understanding of it was primarily your practice.
Understood, thanks for the reply.
--
Thanks,
Shaoxuan
Quoted 10 lines · Shaoxuan Yuan
Quoted 7 lines · Junio C Hamano
Quoted 1 line · Shaoxuan Yuan
Since I didn't see this change in seen or next, do you plan to apply it?
I actually wasn't, as my understanding of it was primarily your practice.
Understood, thanks for the reply.
FWIW, I have the posted patch plus the following SQUASH??? fix-up parked in the 'seen' branch. As the script is quiescent right now, I do not mind merging it down, now we spent more time on it ;-)
t/t0001-init.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
t/t0001-init.sh +2 -1
@@ -6,7 +6,8 @@ TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh check_config () { - if test_path_is_dir "$1" && test_path_is_file "$1/config" && test_path_is_dir "$1/refs" + if test_path_is_dir "$1" && + test_path_is_file "$1/config" && test_path_is_dir "$1/refs" then : happy else
Signature · 1 line
2.35.1-102-g2b9c120970
Hi Junio,
Quoted 1 line · Junio C Hamano
FWIW, I have the posted patch plus the following SQUASH??? fix-up
I'm not so sure what does "SQUASH???" mean especially the three question marks, i.e. is it just an incidental text or a commit message convention?
Is it for the convenience of grepping through the
"git log" outputs (cause I found the commit 50d631c71c right away by grepping through the "git log" output)?
Quoted 11 lines
parked in the 'seen' branch. As the script is quiescent right now, I do not mind merging it down, now we spent more time on it ;-)
t/t0001-init.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)t/t0001-init.sh +0
-0
t/t0001-init.sh TEST_PASSES_SANITIZE_LEAK=true · line 13
Quoted 9 lines
t/t0001-init.sh +2
-1@@ -6,7 +6,8 @@ TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh check_config () { - if test_path_is_dir "$1" && test_path_is_file "$1/config" && test_path_is_dir "$1/refs" + if test_path_is_dir "$1" && + test_path_is_file "$1/config" && test_path_is_dir "$1/refs" then : happy else
Yeah, I think wrapping it around is a good idea :-)
Quoted 3 lines
--
2.35.1-102-g2b9c120970
Signature · 2 lines
Thanks & Regards, Shaoxuan
Quoted 9 lines · Shaoxuan Yuan
Quoted 1 line · Junio C Hamano
FWIW, I have the posted patch plus the following SQUASH??? fix-up
I'm not so sure what does "SQUASH???" mean especially the three question marks, i.e. is it just an incidental text or a commit message convention?
Is it for the convenience of grepping through the
"git log" outputs (cause I found the commit50d631c71cright away by grepping through the "git log" output)?
It is primarily to remind me not to merge the branch down to 'next' without dealing with it.
Quoted 1 line
Yeah, I think wrapping it around is a good idea :-)
Then will squash it in and merge it down.
Thanks.
Quoted 6 lines · Shaoxuan Yuan
Quoted 1 line · Junio C Hamano
FWIW, I have the posted patch plus the following SQUASH??? fix-up
I'm not so sure what does "SQUASH???" mean especially the three question marks, i.e. is it just an incidental text or a commit message convention?
It means that you might want to squash the fix-up commit or a similar commit into your commit (or one of your commits in case of a commit/patch series), and then resubmit a new version.
Quoted 3 lines
Is it for the convenience of grepping through the
"git log" outputs (cause I found the commit50d631c71cright away by grepping through the "git log" output)?
It is for convenience that it's named "SQUASH???" as everyone (who is familiar with the mailing list) then knows what needs to be done on the proposed commit(s).
Quoted 2 lines
Quoted 2 lines
parked in the 'seen' branch. As the script is quiescent right now, I do not mind merging it down, now we spent more time on it ;-)
Alternatively as Junio says he is ok with merging that down, you might just accept his offer and he will squash the "SQUASH???" commit for you before merging the result into the "next" branch.
Quoted 13 lines · Christian Couder
Quoted 6 lines · Shaoxuan Yuan
Quoted 1 line · Junio C Hamano
FWIW, I have the posted patch plus the following SQUASH??? fix-up
I'm not so sure what does "SQUASH???" mean especially the three question marks, i.e. is it just an incidental text or a commit message convention?
It means that you might want to squash the fix-up commit or a similar commit into your commit (or one of your commits in case of a commit/patch series), and then resubmit a new version.
Quoted 7 lines
Quoted 3 lines
Is it for the convenience of grepping through the
"git log" outputs (cause I found the commit50d631c71cright away by grepping through the "git log" output)?It is for convenience that it's named "SQUASH???" as everyone (who is familiar with the mailing list) then knows what needs to be done on the proposed commit(s).
Yeah, now I see :)
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
parked in the 'seen' branch. As the script is quiescent right now, I do not mind merging it down, now we spent more time on it ;-)
Alternatively as Junio says he is ok with merging that down, you might just accept his offer and he will squash the "SQUASH???" commit for you before merging the result into the "next" branch.
Yeah, I saw the squashed version in the latest "What's cooking in git.git". Thanks for the help and suggestions :)
Signature · 2 lines
Thanks & Regards, Shaoxuan