git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fixes handling of --reference argument.
@ 2012-10-25  4:52 szager
  2012-10-25  8:36 ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: szager @ 2012-10-25  4:52 UTC (permalink / raw)
  To: git

Signed-off-by: Stefan Zager <szager@google.com>
---
 git-submodule.sh |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index ab6b110..dcceb43 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -270,7 +270,6 @@ cmd_add()
 			;;
 		--reference=*)
 			reference="$1"
-			shift
 			;;
 		--)
 			shift
-- 
1.7.7.3

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

* Re: [PATCH] Fixes handling of --reference argument.
  2012-10-25  4:52 [PATCH] Fixes handling of --reference argument szager
@ 2012-10-25  8:36 ` Jeff King
  2012-10-25 10:45   ` W. Trevor King
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff King @ 2012-10-25  8:36 UTC (permalink / raw)
  To: szager; +Cc: git

On Wed, Oct 24, 2012 at 09:52:52PM -0700, szager@google.com wrote:

> Signed-off-by: Stefan Zager <szager@google.com>
> ---
>  git-submodule.sh |    1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)
> 
> diff --git a/git-submodule.sh b/git-submodule.sh
> index ab6b110..dcceb43 100755
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
> @@ -270,7 +270,6 @@ cmd_add()
>  			;;
>  		--reference=*)
>  			reference="$1"
> -			shift
>  			;;

Is that right? We'll unconditionally do a "shift" at the end of the
loop. If it were a two-part argument like "--reference foo", the extra
shift would make sense, but for "--reference=*", no extra shift should
be neccessary. Am I missing something?

-Peff

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

* Re: [PATCH] Fixes handling of --reference argument.
  2012-10-25  8:36 ` Jeff King
@ 2012-10-25 10:45   ` W. Trevor King
  2012-10-25 21:32     ` Jens Lehmann
  0 siblings, 1 reply; 5+ messages in thread
From: W. Trevor King @ 2012-10-25 10:45 UTC (permalink / raw)
  To: Jeff King; +Cc: szager, git

[-- Attachment #1: Type: text/plain, Size: 994 bytes --]

On Thu, Oct 25, 2012 at 04:36:26AM -0400, Jeff King wrote:
> On Wed, Oct 24, 2012 at 09:52:52PM -0700, szager@google.com wrote:
> > diff --git a/git-submodule.sh b/git-submodule.sh
> > index ab6b110..dcceb43 100755
> > --- a/git-submodule.sh
> > +++ b/git-submodule.sh
> > @@ -270,7 +270,6 @@ cmd_add()
> >  			;;
> >  		--reference=*)
> >  			reference="$1"
> > -			shift
> >  			;;
> 
> Is that right? We'll unconditionally do a "shift" at the end of the
> loop. If it were a two-part argument like "--reference foo", the extra
> shift would make sense, but for "--reference=*", no extra shift should
> be neccessary. Am I missing something?

Both the patch and Jeff's analysis are right.  You only need an
in-case shift if you consume "$2", or you're on ‘--’ and you're
breaking before the end-of-case shift.

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] Fixes handling of --reference argument.
  2012-10-25 10:45   ` W. Trevor King
@ 2012-10-25 21:32     ` Jens Lehmann
  2012-10-26  0:39       ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: Jens Lehmann @ 2012-10-25 21:32 UTC (permalink / raw)
  To: W. Trevor King; +Cc: Jeff King, szager, git

Am 25.10.2012 12:45, schrieb W. Trevor King:
> On Thu, Oct 25, 2012 at 04:36:26AM -0400, Jeff King wrote:
>> On Wed, Oct 24, 2012 at 09:52:52PM -0700, szager@google.com wrote:
>>> diff --git a/git-submodule.sh b/git-submodule.sh
>>> index ab6b110..dcceb43 100755
>>> --- a/git-submodule.sh
>>> +++ b/git-submodule.sh
>>> @@ -270,7 +270,6 @@ cmd_add()
>>>  			;;
>>>  		--reference=*)
>>>  			reference="$1"
>>> -			shift
>>>  			;;
>>
>> Is that right? We'll unconditionally do a "shift" at the end of the
>> loop. If it were a two-part argument like "--reference foo", the extra
>> shift would make sense, but for "--reference=*", no extra shift should
>> be neccessary. Am I missing something?
> 
> Both the patch and Jeff's analysis are right.  You only need an
> in-case shift if you consume "$2", or you're on ‘--’ and you're
> breaking before the end-of-case shift.

Right you are. The shift there is wrong, as there is no extra argument
to consume for "--reference=<repo>" (opposed to "--reference <repo>",
also see cmd_update() where this is done right).

So tested and Acked-By me, but me thinks the subject should read:

   [PATCH] submodule add: Fix handling of the --reference=<repo> option

and the commit message should begin with:

   Doing a shift there is wrong because there is no extra argument
   to consume when "--reference=<repo>" is used (note the '=' instead
   of a space).

Peff, is it ok for you to squash that in or do you want Stefan to resend?

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

* Re: [PATCH] Fixes handling of --reference argument.
  2012-10-25 21:32     ` Jens Lehmann
@ 2012-10-26  0:39       ` Jeff King
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff King @ 2012-10-26  0:39 UTC (permalink / raw)
  To: Jens Lehmann; +Cc: W. Trevor King, szager, git

On Thu, Oct 25, 2012 at 11:32:29PM +0200, Jens Lehmann wrote:

> >>> @@ -270,7 +270,6 @@ cmd_add()
> >>>  			;;
> >>>  		--reference=*)
> >>>  			reference="$1"
> >>> -			shift
> >>>  			;;
> >>
> >> Is that right? We'll unconditionally do a "shift" at the end of the
> >> loop. If it were a two-part argument like "--reference foo", the extra
> >> shift would make sense, but for "--reference=*", no extra shift should
> >> be neccessary. Am I missing something?
> > 
> > Both the patch and Jeff's analysis are right.  You only need an
> > in-case shift if you consume "$2", or you're on ‘--’ and you're
> > breaking before the end-of-case shift.
> 
> Right you are. The shift there is wrong, as there is no extra argument
> to consume for "--reference=<repo>" (opposed to "--reference <repo>",
> also see cmd_update() where this is done right).

Oh, the problem is that I'm an idiot, and for some reason read it as
_adding_ the bogus shift, not removing it. Patch is clearly correct.

> So tested and Acked-By me, but me thinks the subject should read:
> 
>    [PATCH] submodule add: Fix handling of the --reference=<repo> option
> 
> and the commit message should begin with:
> 
>    Doing a shift there is wrong because there is no extra argument
>    to consume when "--reference=<repo>" is used (note the '=' instead
>    of a space).

Yeah, I think it makes sense to explain why it is wrong in the commit
message (I'll blame that for my lack of common sense above :) ).

> Peff, is it ok for you to squash that in or do you want Stefan to resend?

I can squash it in. Thanks all.

-Peff

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

end of thread, other threads:[~2012-10-26  0:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-25  4:52 [PATCH] Fixes handling of --reference argument szager
2012-10-25  8:36 ` Jeff King
2012-10-25 10:45   ` W. Trevor King
2012-10-25 21:32     ` Jens Lehmann
2012-10-26  0:39       ` Jeff King

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 NNTP newsgroup(s).