From: Junio C Hamano Date: Wed, 29 Apr 2020 19:24:48 GMT Subject: Re: [PATCH 4/4] lib-submodule-update: pass OVERWRITING_FAIL Message-ID: In-Reply-To: <22eacd20a8213c3281974a6c103fd2d00c95efaa.1588162842.git.liu.denton@gmail.com> Denton Liu writes: > We are using `test_must_fail $command`. However, $command is not > necessarily a git command; it could be a test helper function. > > In an effort to stop using test_must_fail with non-git commands, instead > of invoking `test_must_fail $command`, run > `OVERWRITING_FAIL=test_must_fail $command` instead. Increase the > granularity of the test helper functions by specifically choosing the > individual git invocation which is designed to fail. Sorry, but I do not know why this is a good idea. > test_submodule_switch_common () { > + OVERWRITING_FAIL= > command="$1" > ######################### Appearing submodule ######################### > # Switching to a commit letting a submodule appear creates empty dir ... > @@ -443,7 +446,7 @@ test_submodule_switch_common () { > ( > cd submodule_update && > git branch -t replace_sub1_with_directory origin/replace_sub1_with_directory && > - test_must_fail $command replace_sub1_with_directory && > + OVERWRITING_FAIL=test_must_fail $command replace_sub1_with_directory && Here, $command may or may not be a git command and more importantly, it could be a shell function, right? Then we need to take it into account that VAR=VAL shell_function args... will not work, no? Some shells do not make this a single-shot environment variable assignment that will not persist once the single function invocation returns.