Re: [PATCH] bash: offer only paths after '--'

4 messages, 3 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] bash: offer only paths after '--'

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:44:54

SZEDER Gábor [off-list ref] writes:
Hope that I got the commit message right (;
It was very readable.  Thanks.
+__git_has_doubledash ()
+{
+	local c=1
+	while [ $c -lt $COMP_CWORD ]; do
+		if [ "--" = "${COMP_WORDS[c]}" ]; then
+			return 0
+		fi
+		c=$((++c))
This assignment is somewhat curious, although it should work as expected
either way ;-)

Shawn?

Re: [PATCH] bash: offer only paths after '--'

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:44:54

Junio C Hamano [off-list ref] wrote:
SZEDER Gábor [off-list ref] writes:
quoted
Hope that I got the commit message right (;
It was very readable.  Thanks.
Acked-by: Shawn O. Pearce <redacted>
quoted
+__git_has_doubledash ()
+{
+	local c=1
+	while [ $c -lt $COMP_CWORD ]; do
+		if [ "--" = "${COMP_WORDS[c]}" ]; then
+			return 0
+		fi
+		c=$((++c))
This assignment is somewhat curious, although it should work as expected
either way ;-)
I agree, its damned odd.  But we already do this in the same
sort of loop inside of _git_branch() (see around line 541 in
next).  This new patch is only sticking with our current set
of conventions in the script, so I say its fine.

-- 
Shawn.

Re: [PATCH] bash: offer only paths after '--'

From: SZEDER Gábor <hidden>
Date: 2016-06-15 22:44:54

On Tue, Jul 08, 2008 at 11:18:37PM +0000, Shawn O. Pearce wrote:
Junio C Hamano [off-list ref] wrote:
quoted
SZEDER Gábor [off-list ref] writes:
quoted
+		c=$((++c))
This assignment is somewhat curious, although it should work as expected
either way ;-)
I agree, its damned odd.  But we already do this in the same
sort of loop inside of _git_branch() (see around line 541 in
next).  This new patch is only sticking with our current set
of conventions in the script, so I say its fine.
Well, according to

  git blame contrib/completion/git-completion.bash  |grep '++'

you started this convention back in 2006, I just copied and modified
your code (;

Maybe an old C++ "heritage"?  In C++ it matters for class types (e.g.
iterators), because the postfix operator might be slower than the
prefix.

Best,
Gábor

Re: [PATCH] bash: offer only paths after '--'

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:44:54

SZEDER GGGbor [off-list ref] wrote:
On Tue, Jul 08, 2008 at 11:18:37PM +0000, Shawn O. Pearce wrote:
quoted
Junio C Hamano [off-list ref] wrote:
quoted
SZEDER Gábor [off-list ref] writes:
quoted
+		c=$((++c))
This assignment is somewhat curious, although it should work as expected
either way ;-)
Well, according to

  git blame contrib/completion/git-completion.bash  |grep '++'

you started this convention back in 2006, I just copied and modified
your code (;
Yea, I don't doubt it was me that did this.
 
Maybe an old C++ "heritage"?  In C++ it matters for class types (e.g.
iterators), because the postfix operator might be slower than the
prefix.
Unlikely, but maybe.  I'm not really a C++ programmer.  I tend to
avoid C++ when/if I am given the chance to do so.

-- 
Shawn.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help