From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Morian Sonnet <moriansonnet@gmail.com>
Cc: sunshine@sunshineco.us, MorianSonnet@googlemail.com,
gitster@pobox.com, gitgitgadget@gmail.com, git@vger.kernel.org
Subject: Re: [PATCH v2 1/1] submodule foreach: fix recursion of options
Date: Mon, 24 Jun 2019 12:49:14 +0200 (CEST) [thread overview]
Message-ID: <nycvar.QRO.7.76.6.1906241241080.44@tvgsbejvaqbjf.bet> (raw)
In-Reply-To: <201906221054.x5MAspEQ003711@linux-5.fritz.box>
Hi Morian,
On Sat, 22 Jun 2019, Morian Sonnet wrote:
> Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
>
> > On Tue, 18 Jun 2019, Morian Sonnet wrote:
> >
> > > "Morian Sonnet via GitGitGadget" <gitgitgadget@gmail.com> wrote:
> > >
> > > > 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.
> >
> > This is a good explanation, even if the format is not exactly close to the
> > existing commit messages ;-) If you look e.g. at
> > https://github.com/git/git/commit/e5a329a279c7, you will see what I mean:
> > there is much more "prose" (and less bullet points) going on.
>
> Ok, I see the differences. Shall I adapt the commit description?
Well, I would if I were you ;-)
> My test so far was designed to not actually check whether git reset
> --hard has shown any effect.
Right, but the test case's title suggested that...
> Taking the test "test "foreach --quiet --recursive"" and the test
> "option-like arguments passed to foreach commands are not lost" for
> example, I suggest the following:
>
> git -C clone2 submodule foreach --recursive "echo be --hard" > expected &&
> git -C clone2 submodule foreach --recursive echo be --hard > actual &&
> grep -sq -e "--hard" expected &&
Please without the `-sq`.
> test_cmp expected actual
Sounds good to me, especially with this suggestion:
> As final comment: One could change the flag --hard to something which
> will definetely never be an option flag for both, echo and git submodule
> foreach, e.g. --this-will-never-be-an-option.
Personally, I'd go for `echo --an-option`, and yes, you are absolutely
right, the intention of your bug fix is not so much to fix the recursive
`git reset --hard` as it is to fix _any_ recursive command with
command-line options.
To be honest, I had missed that `git submodule foreach --recursive`
executes commands even in uninitialized submodules... I could even see how
some users might consider that behavior a bug... are you sure this is the
case? Is this `echo` really executed even in `nested2`?
Ciao,
Johannes
next prev parent reply other threads:[~2019-06-24 10:49 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
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
2019-06-18 15:15 ` Morian Sonnet
2019-06-19 18:19 ` Johannes Schindelin
2019-06-22 10:54 ` Morian Sonnet
2019-06-24 10:49 ` Johannes Schindelin [this message]
2019-06-24 15:40 ` Morian Sonnet
2019-06-24 15:40 ` [PATCH] " Morian Sonnet
2019-06-24 15:47 ` Morian Sonnet
2019-06-24 15:47 ` [PATCH] " Morian Sonnet
2019-06-24 17:47 ` Johannes Schindelin
2019-06-24 18:16 ` Junio C Hamano
2019-06-24 20:26 ` Morian Sonnet
2019-06-24 20:26 ` [PATCH] " Morian Sonnet
2019-06-25 11:18 ` Duy Nguyen
2019-06-25 18:18 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=nycvar.QRO.7.76.6.1906241241080.44@tvgsbejvaqbjf.bet \
--to=johannes.schindelin@gmx.de \
--cc=MorianSonnet@googlemail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=moriansonnet@gmail.com \
--cc=sunshine@sunshineco.us \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).