Re: [PATCH v2 1/1] submodule foreach: fix recursion of options

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Morian Sonnet via GitGitGadget" <gitgitgadget@xxxxxxxxx> wrote:

I fixed the problem with the test case. Please take another look.

> From: Morian Sonnet <MorianSonnet@xxxxxxxxxxxxxx>
>
> Calling
>
>     git submodule foreach --recursive git reset --hard
>
> leads to an error stating that the option --hard is unknown to
> submodule--helper.
>
> Reasons:
>
> . Above call is internally translated into
>
>     git submodule--helper foreach --recursive -- git reset --hard
>
> . After calling
>
>     git reset --hard
>
>   inside the first first level submodule,
>
>     git --super-prefix <submodulepath> submodule--helper \
>       foreach --recursive git reset --hard
>
>   is called. Note the missing --.
>
> . Due to the removal of PARSE_OPT_KEEP_UNKNOWN in commit a282f5a906 the
>   option --hard is not passed to
>
>     git reset
>
>   anymore, but leads to git submodule--helper complaining about an
>   unknown option.
>
> Fix:
>
> . Add -- before the command to execute, such that now correctly
>
>     git --super-prefix <submodulepath> submodule--helper \
>       foreach --recursive -- git reset --hard
>
>   is called.
>
> Signed-off-by: Morian Sonnet <moriansonnet@xxxxxxxxxxxxxx>
> ---
>  builtin/submodule--helper.c  | 1 +
>  t/t7407-submodule-foreach.sh | 7 +++++++
>  2 files changed, 8 insertions(+)
>
> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
> index 0bf4aa088e..afaf0819c9 100644
> --- a/builtin/submodule--helper.c
> +++ b/builtin/submodule--helper.c
> @@ -540,6 +540,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
>  		if (info->quiet)
>  			argv_array_push(&cpr.args, "--quiet");
>  
> +		argv_array_push(&cpr.args, "--");
>  		argv_array_pushv(&cpr.args, info->argv);
>  
>  		if (run_command(&cpr))
> diff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh
> index 706ae762e0..c554589e6f 100755
> --- a/t/t7407-submodule-foreach.sh
> +++ b/t/t7407-submodule-foreach.sh
> @@ -421,4 +421,11 @@ test_expect_success 'option-like arguments passed to foreach commands are not lo
>  	test_cmp expected actual
>  '
>  
> +test_expect_success 'option-like arguments passed to foreach recurse correctly' '
> +  (
> +    cd super &&
> +    git submodule foreach --recursive git reset --hard
> +  )
> +'
> +
>  test_done
> -- 
> gitgitgadget



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux