git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] completion: fix completion of git <TAB><TAB>
@ 2009-10-09  6:21 Stephen Boyd
  2009-10-09  6:21 ` [PATCHv2 2/2] completion: fix alias listings with newlines Stephen Boyd
  2009-10-09 14:26 ` [PATCH 1/2] completion: fix completion of git <TAB><TAB> Shawn O. Pearce
  0 siblings, 2 replies; 4+ messages in thread
From: Stephen Boyd @ 2009-10-09  6:21 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Junio C Hamano, git, Johannes Sixt

After commit 511a3fc (wrap git's main usage string., 2009-09-12), the
bash completion for git commands includes COMMAND and [ARGS] when it
shouldn't. Fix this by grepping more strictly for a line with git
commands. It's doubtful whether git will ever have commands starting
with anything besides numbers and letters so this should be fine. At
least by being stricter we'll know when we break the completion earlier.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---

 contrib/completion/git-completion.bash |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 88b1b3c..652a47c 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -496,7 +496,7 @@ __git_all_commands ()
 		return
 	fi
 	local i IFS=" "$'\n'
-	for i in $(git help -a|egrep '^ ')
+	for i in $(git help -a|egrep '^  [a-zA-Z0-9]')
 	do
 		case $i in
 		*--*)             : helper pattern;;
-- 
1.6.5.rc3

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

* [PATCHv2 2/2] completion: fix alias listings with newlines
  2009-10-09  6:21 [PATCH 1/2] completion: fix completion of git <TAB><TAB> Stephen Boyd
@ 2009-10-09  6:21 ` Stephen Boyd
  2009-10-09 14:29   ` Shawn O. Pearce
  2009-10-09 14:26 ` [PATCH 1/2] completion: fix completion of git <TAB><TAB> Shawn O. Pearce
  1 sibling, 1 reply; 4+ messages in thread
From: Stephen Boyd @ 2009-10-09  6:21 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Junio C Hamano, git, Johannes Sixt

Aliases with newlines have been a problem since commit 56fc25f (Bash
completion support for remotes in .git/config., 2006-11-05). The chance
of the problem occurring has been slim at best, until commit 518ef8f
(completion: Replace config --list with --get-regexp, 2009-09-11)
removed the case statement introduced by commit 56fc25f. Before removing
the case statement, most aliases with newlines would work unless they
were specially crafted as follows

[alias]
	foo = "log -1 --pretty='format:%s\nalias.error=broken'"

After removing the case statement, a more benign alias like

[alias]
	whowhat = "log -1 --pretty='format:%an <%ae>\n%s'"
	wont-complete = ...

would cause the completion to break badly.

For now, revert the removal of the case statement until someone comes up
with a better way to get keys from git-config.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---

This is an alternate fix to my previous 1/3 patch.

Hannes has convinced me to go this route. I don't really see a problem, it
basically reverts to broken behavior that nobody's complained about in 3
years. At least it's less broken?

 contrib/completion/git-completion.bash |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 652a47c..e482c8d 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -602,8 +602,12 @@ __git_aliases ()
 {
 	local i IFS=$'\n'
 	for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do
-		i="${i#alias.}"
-		echo "${i/ */}"
+		case "$i" in
+		alias.*)
+			i="${i#alias.}"
+			echo "${i/ */}"
+			;;
+		esac
 	done
 }
 
-- 
1.6.5.rc3

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

* Re: [PATCH 1/2] completion: fix completion of git <TAB><TAB>
  2009-10-09  6:21 [PATCH 1/2] completion: fix completion of git <TAB><TAB> Stephen Boyd
  2009-10-09  6:21 ` [PATCHv2 2/2] completion: fix alias listings with newlines Stephen Boyd
@ 2009-10-09 14:26 ` Shawn O. Pearce
  1 sibling, 0 replies; 4+ messages in thread
From: Shawn O. Pearce @ 2009-10-09 14:26 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: Junio C Hamano, git, Johannes Sixt

Stephen Boyd <bebarino@gmail.com> wrote:
> After commit 511a3fc (wrap git's main usage string., 2009-09-12), the
> bash completion for git commands includes COMMAND and [ARGS] when it
> shouldn't. Fix this by grepping more strictly for a line with git
> commands. It's doubtful whether git will ever have commands starting
> with anything besides numbers and letters so this should be fine. At
> least by being stricter we'll know when we break the completion earlier.
> 
> Signed-off-by: Stephen Boyd <bebarino@gmail.com>

Acked-by: Shawn O. Pearce <spearce@spearce.org>

-- 
Shawn.

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

* Re: [PATCHv2 2/2] completion: fix alias listings with newlines
  2009-10-09  6:21 ` [PATCHv2 2/2] completion: fix alias listings with newlines Stephen Boyd
@ 2009-10-09 14:29   ` Shawn O. Pearce
  0 siblings, 0 replies; 4+ messages in thread
From: Shawn O. Pearce @ 2009-10-09 14:29 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: Junio C Hamano, git, Johannes Sixt

Stephen Boyd <bebarino@gmail.com> wrote:
> Aliases with newlines have been a problem since commit 56fc25f (Bash
> completion support for remotes in .git/config., 2006-11-05). The chance
> of the problem occurring has been slim at best, until commit 518ef8f
> (completion: Replace config --list with --get-regexp, 2009-09-11)
> removed the case statement introduced by commit 56fc25f. Before removing
> the case statement, most aliases with newlines would work unless they
> were specially crafted as follows
...
> Hannes has convinced me to go this route. I don't really see a problem, it
> basically reverts to broken behavior that nobody's complained about in 3
> years. At least it's less broken?

Yay.  Given that we have no better solution easily available,
I like the idea of just reverting to the behavior we have had
for the past 3 years.  Thanks.

Acked-by: Shawn O. Pearce <spearce@spearce.org>
 
-- 
Shawn.

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

end of thread, other threads:[~2009-10-09 14:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-09  6:21 [PATCH 1/2] completion: fix completion of git <TAB><TAB> Stephen Boyd
2009-10-09  6:21 ` [PATCHv2 2/2] completion: fix alias listings with newlines Stephen Boyd
2009-10-09 14:29   ` Shawn O. Pearce
2009-10-09 14:26 ` [PATCH 1/2] completion: fix completion of git <TAB><TAB> Shawn O. Pearce

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).