* [PATCH] git-submodule: fix expansion of depth for cmd_update @ 2019-08-22 20:31 Jacob Keller 2019-08-22 21:01 ` Junio C Hamano 0 siblings, 1 reply; 3+ messages in thread From: Jacob Keller @ 2019-08-22 20:31 UTC (permalink / raw) To: git; +Cc: Jacob Keller From: Jacob Keller <jacob.keller@gmail.com> The depth variable already contains "--depth=", so expanding it with an additional --depth when invoking the update-clone git submodule--helper is incorrect. Signed-off-by: Jacob Keller <jacob.keller@gmail.com> --- I'm *reasonably* sure this is correct, but I am not sure how to test it. It's possible that it expands to "--depth --depth=N" and somehow this gets handled properly? git-submodule.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-submodule.sh b/git-submodule.sh index c7f58c5756f7..4e7fc8bf3652 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -547,7 +547,7 @@ cmd_update() ${update:+--update "$update"} \ ${reference:+"$reference"} \ ${dissociate:+"--dissociate"} \ - ${depth:+--depth "$depth"} \ + ${depth:+"$depth"} \ $recommend_shallow \ $jobs \ -- \ -- 2.23.0.245.gf157bbb9169d ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] git-submodule: fix expansion of depth for cmd_update 2019-08-22 20:31 [PATCH] git-submodule: fix expansion of depth for cmd_update Jacob Keller @ 2019-08-22 21:01 ` Junio C Hamano 2019-08-22 22:38 ` Keller, Jacob E 0 siblings, 1 reply; 3+ messages in thread From: Junio C Hamano @ 2019-08-22 21:01 UTC (permalink / raw) To: Jacob Keller; +Cc: git, Jacob Keller Jacob Keller <jacob.e.keller@intel.com> writes: > From: Jacob Keller <jacob.keller@gmail.com> > > The depth variable already contains "--depth=", so expanding it with an > additional --depth when invoking the update-clone git submodule--helper > is incorrect. > > Signed-off-by: Jacob Keller <jacob.keller@gmail.com> > --- > > I'm *reasonably* sure this is correct, but I am not sure how to test it. > It's possible that it expands to "--depth --depth=N" and somehow this gets > handled properly? I agree with your eyeballing of all the assignments to the variable, and other references to $depth take either one of these two forms: git submodule--helper ... ${depth:+"$depth"} ... git submodule--helper ... $depth ... As long as "git submodule ... --depth <depth> ..." gets called with <depth> that does not have $IFS, either would work fine, but the former is correct even when <depth> has problematic characters in it and your patch uses that form, too). However. The command line parser for update_clone() stuffs --depth as a string to suc.depth, and then the machinery ends up calling prepare_to_clone_next_submodule() with such an instance of suc (struct submodule_update_clone). Then that function just pushes the suc->depth to an argv array used to spawn a "submodule--helper clone". So passing "--depth --depth=23" would be "correct", sadly, in that codepath (I am not saying other codepaths would not call the same prepare_to_clone_next_submodule() with "--depth 23", as I didn't check, and if there is such a codepath, it would break). We may need to clean the mess up X-<. > diff --git a/git-submodule.sh b/git-submodule.sh > index c7f58c5756f7..4e7fc8bf3652 100755 > --- a/git-submodule.sh > +++ b/git-submodule.sh > @@ -547,7 +547,7 @@ cmd_update() > ${update:+--update "$update"} \ > ${reference:+"$reference"} \ > ${dissociate:+"--dissociate"} \ > - ${depth:+--depth "$depth"} \ > + ${depth:+"$depth"} \ > $recommend_shallow \ > $jobs \ > -- \ ^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] git-submodule: fix expansion of depth for cmd_update 2019-08-22 21:01 ` Junio C Hamano @ 2019-08-22 22:38 ` Keller, Jacob E 0 siblings, 0 replies; 3+ messages in thread From: Keller, Jacob E @ 2019-08-22 22:38 UTC (permalink / raw) To: Junio C Hamano; +Cc: git@vger.kernel.org, Jacob Keller > -----Original Message----- > From: git-owner@vger.kernel.org [mailto:git-owner@vger.kernel.org] On Behalf Of > Junio C Hamano > Sent: Thursday, August 22, 2019 2:01 PM > To: Keller, Jacob E <jacob.e.keller@intel.com> > Cc: git@vger.kernel.org; Jacob Keller <jacob.keller@gmail.com> > Subject: Re: [PATCH] git-submodule: fix expansion of depth for cmd_update > > Jacob Keller <jacob.e.keller@intel.com> writes: > > > From: Jacob Keller <jacob.keller@gmail.com> > > > > The depth variable already contains "--depth=", so expanding it with an > > additional --depth when invoking the update-clone git submodule--helper > > is incorrect. > > > > Signed-off-by: Jacob Keller <jacob.keller@gmail.com> > > --- > > > > I'm *reasonably* sure this is correct, but I am not sure how to test it. > > It's possible that it expands to "--depth --depth=N" and somehow this gets > > handled properly? > > I agree with your eyeballing of all the assignments to the variable, > and other references to $depth take either one of these two forms: > > git submodule--helper ... ${depth:+"$depth"} ... > git submodule--helper ... $depth ... > > As long as "git submodule ... --depth <depth> ..." gets called with > <depth> that does not have $IFS, either would work fine, but the > former is correct even when <depth> has problematic characters in it > and your patch uses that form, too). > > However. > > The command line parser for update_clone() stuffs --depth as a > string to suc.depth, and then the machinery ends up calling > prepare_to_clone_next_submodule() with such an instance of suc > (struct submodule_update_clone). Then that function just pushes the > suc->depth to an argv array used to spawn a "submodule--helper clone". > > So passing "--depth --depth=23" would be "correct", sadly, in that > codepath (I am not saying other codepaths would not call the same > prepare_to_clone_next_submodule() with "--depth 23", as I didn't > check, and if there is such a codepath, it would break). > Ok, so it's technically correct, but weird. I had trouble understanding it. > We may need to clean the mess up X-<. > Yea, I got confused looking at this code. Though if I recall, we were working towards rewriting it in C anyways (which is what the submodule--helper is doing). Thanks, Jake > > diff --git a/git-submodule.sh b/git-submodule.sh > > index c7f58c5756f7..4e7fc8bf3652 100755 > > --- a/git-submodule.sh > > +++ b/git-submodule.sh > > @@ -547,7 +547,7 @@ cmd_update() > > ${update:+--update "$update"} \ > > ${reference:+"$reference"} \ > > ${dissociate:+"--dissociate"} \ > > - ${depth:+--depth "$depth"} \ > > + ${depth:+"$depth"} \ > > $recommend_shallow \ > > $jobs \ > > -- \ ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-08-22 22:38 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-08-22 20:31 [PATCH] git-submodule: fix expansion of depth for cmd_update Jacob Keller 2019-08-22 21:01 ` Junio C Hamano 2019-08-22 22:38 ` Keller, Jacob E
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).