git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / Atom feed
* [PATCH 0/1] submodule foreach: fix recursion of options
@ 2019-06-12 18:10 Morian Sonnet via GitGitGadget
  2019-06-12 18:10 ` [PATCH 1/1] " Morian Sonnet via GitGitGadget
  2019-06-12 20:28 ` [PATCH v2 0/1] " Morian Sonnet via GitGitGadget
  0 siblings, 2 replies; 5+ messages in thread
From: Morian Sonnet via GitGitGadget @ 2019-06-12 18:10 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

During the usage of git in Buildkite we noted that git fails upon calling 
git submodule foreach --recursive git reset --hardafter updating git version
to 2.22.0.

This is due to a problem with the recursive calling of git submodule--helper 
itself, which is fixed in the patch below.

Morian Sonnet (1):
  submodule foreach: fix recursion of options

 builtin/submodule--helper.c  | 1 +
 t/t7407-submodule-foreach.sh | 5 +++++
 2 files changed, 6 insertions(+)


base-commit: b697d92f56511e804b8ba20ccbe7bdc85dc66810
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-263%2Fmomoson%2Fmaster-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-263/momoson/master-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/263
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/1] submodule foreach: fix recursion of options
  2019-06-12 18:10 [PATCH 0/1] submodule foreach: fix recursion of options Morian Sonnet via GitGitGadget
@ 2019-06-12 18:10 ` " Morian Sonnet via GitGitGadget
  2019-06-12 19:35   ` Eric Sunshine
  2019-06-12 20:28 ` [PATCH v2 0/1] " Morian Sonnet via GitGitGadget
  1 sibling, 1 reply; 5+ messages in thread
From: Morian Sonnet via GitGitGadget @ 2019-06-12 18:10 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Morian Sonnet

From: Morian Sonnet <MorianSonnet@googlemail.com>

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@googlemail.com>
---
 builtin/submodule--helper.c  | 1 +
 t/t7407-submodule-foreach.sh | 5 +++++
 2 files changed, 6 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..6110742a7c 100755
--- a/t/t7407-submodule-foreach.sh
+++ b/t/t7407-submodule-foreach.sh
@@ -421,4 +421,9 @@ 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] submodule foreach: fix recursion of options
  2019-06-12 18:10 ` [PATCH 1/1] " Morian Sonnet via GitGitGadget
@ 2019-06-12 19:35   ` Eric Sunshine
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Sunshine @ 2019-06-12 19:35 UTC (permalink / raw)
  To: Morian Sonnet via GitGitGadget; +Cc: Git List, Junio C Hamano, Morian Sonnet

On Wed, Jun 12, 2019 at 2:10 PM Morian Sonnet via GitGitGadget
<gitgitgadget@gmail.com> wrote:
> [...]
> . 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@googlemail.com>
> ---
> diff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh
> @@ -421,4 +421,9 @@ test_expect_success 'option-like arguments passed to foreach commands are not lo
> +test_expect_success 'option-like arguments passed to foreach recurse correctly' '
> +  cd super &&
> +  git submodule foreach --recursive git reset --hard
> +'

Follow the example of the existing tests in this script and do the
'cd' in a subshell so that it doesn't bleed into tests added later
following this one, thus confusing them.

    (
        cd super &&
        git submodule foreach ...
    )

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 0/1] submodule foreach: fix recursion of options
  2019-06-12 18:10 [PATCH 0/1] submodule foreach: fix recursion of options Morian Sonnet via GitGitGadget
  2019-06-12 18:10 ` [PATCH 1/1] " Morian Sonnet via GitGitGadget
@ 2019-06-12 20:28 ` " Morian Sonnet via GitGitGadget
  2019-06-12 20:28   ` [PATCH v2 1/1] " Morian Sonnet via GitGitGadget
  1 sibling, 1 reply; 5+ messages in thread
From: Morian Sonnet via GitGitGadget @ 2019-06-12 20:28 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

During the usage of git in Buildkite we noted that git fails upon calling 
git submodule foreach --recursive git reset --hardafter updating git version
to 2.22.0.

This is due to a problem with the recursive calling of git submodule--helper 
itself, which is fixed in the patch below.

Morian Sonnet (1):
  submodule foreach: fix recursion of options

 builtin/submodule--helper.c  | 1 +
 t/t7407-submodule-foreach.sh | 7 +++++++
 2 files changed, 8 insertions(+)


base-commit: b697d92f56511e804b8ba20ccbe7bdc85dc66810
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-263%2Fmomoson%2Fmaster-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-263/momoson/master-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/263

Range-diff vs v1:

 1:  e766e51777 ! 1:  c46e5bd140 submodule foreach: fix recursion of options
     @@ -65,8 +65,10 @@
       '
       
      +test_expect_success 'option-like arguments passed to foreach recurse correctly' '
     -+  cd super &&
     -+  git submodule foreach --recursive git reset --hard
     ++  (
     ++    cd super &&
     ++    git submodule foreach --recursive git reset --hard
     ++  )
      +'
      +
       test_done

-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/1] submodule foreach: fix recursion of options
  2019-06-12 20:28 ` [PATCH v2 0/1] " Morian Sonnet via GitGitGadget
@ 2019-06-12 20:28   ` " Morian Sonnet via GitGitGadget
  0 siblings, 0 replies; 5+ messages in thread
From: Morian Sonnet via GitGitGadget @ 2019-06-12 20:28 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Morian Sonnet

From: Morian Sonnet <MorianSonnet@googlemail.com>

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@googlemail.com>
---
 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-12 18:10 [PATCH 0/1] submodule foreach: fix recursion of options Morian Sonnet via GitGitGadget
2019-06-12 18:10 ` [PATCH 1/1] " Morian Sonnet via GitGitGadget
2019-06-12 19:35   ` Eric Sunshine
2019-06-12 20:28 ` [PATCH v2 0/1] " Morian Sonnet via GitGitGadget
2019-06-12 20:28   ` [PATCH v2 1/1] " Morian Sonnet via GitGitGadget

git@vger.kernel.org list mirror (unofficial, one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox