* [PATCH 1/3] completion: fix alias listings with newlines
@ 2009-10-07 8:48 Stephen Boyd
2009-10-07 8:48 ` [PATCH 2/3] completion: update am, commit, and log Stephen Boyd
2009-10-07 9:33 ` [PATCH 1/3] completion: fix alias listings with newlines Johannes Sixt
0 siblings, 2 replies; 15+ messages in thread
From: Stephen Boyd @ 2009-10-07 8:48 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Junio C Hamano, git
Since commit 518ef8f (completion: Replace config --list with
--get-regexp, 2009-09-11) an alias config value containing a newline
would break the completion of aliases. Instead of setting the IFS to the
newline, use git-config's null termination to separate aliases with the
null character.
An example .gitconfig causing the breakage.
[alias]
whowhat = "log -1 --pretty='format:%an <%ae>\n%s'"
wont-complete = ...
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---
This is the best I can come up with. I'm not sure about using the
d option of read though.
contrib/completion/git-completion.bash | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 2c2a0d4..332be99 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -600,10 +600,10 @@ __git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
__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/ */}"
+ local i
+ git --git-dir="$(__gitdir)" config -z --get-regexp "alias\..*" 2>/dev/null |
+ while IFS= read -rd '' i; do
+ echo ${i#alias.} | cut -d' ' -f1
done
}
--
1.6.5.rc2.17.gdbc1b
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 2/3] completion: update am, commit, and log
2009-10-07 8:48 [PATCH 1/3] completion: fix alias listings with newlines Stephen Boyd
@ 2009-10-07 8:48 ` Stephen Boyd
2009-10-07 8:48 ` [PATCH 3/3] completion: add dirstat and friends to diff options Stephen Boyd
2009-10-07 19:45 ` [PATCH 2/3] completion: update am, commit, and log Junio C Hamano
2009-10-07 9:33 ` [PATCH 1/3] completion: fix alias listings with newlines Johannes Sixt
1 sibling, 2 replies; 15+ messages in thread
From: Stephen Boyd @ 2009-10-07 8:48 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Junio C Hamano, git
git am learned --scissors, git commit learned --dry-run and git log
learned --decorate=long|short recently.
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---
contrib/completion/git-completion.bash | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 332be99..2ab8c5e 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -668,7 +668,7 @@ _git_am ()
--3way --committer-date-is-author-date --ignore-date
--ignore-whitespace --ignore-space-change
--interactive --keep --no-utf8 --signoff --utf8
- --whitespace=
+ --whitespace= --scissors
"
return
esac
@@ -894,6 +894,7 @@ _git_commit ()
__gitcomp "
--all --author= --signoff --verify --no-verify
--edit --amend --include --only --interactive
+ --dry-run
"
return
esac
@@ -1179,6 +1180,10 @@ _git_log ()
__gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
return
;;
+ --decorate=*)
+ __gitcomp "long short" "" "${cur##--decorate=}"
+ return
+ ;;
--*)
__gitcomp "
$__git_log_common_options
@@ -1191,7 +1196,7 @@ _git_log ()
--pretty= --format= --oneline
--cherry-pick
--graph
- --decorate
+ --decorate --decorate=
--walk-reflogs
--parents --children
$merge
--
1.6.5.rc2.17.gdbc1b
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 3/3] completion: add dirstat and friends to diff options
2009-10-07 8:48 ` [PATCH 2/3] completion: update am, commit, and log Stephen Boyd
@ 2009-10-07 8:48 ` Stephen Boyd
2009-10-07 19:45 ` Junio C Hamano
[not found] ` <20091007205059.GA16235@neumann>
2009-10-07 19:45 ` [PATCH 2/3] completion: update am, commit, and log Junio C Hamano
1 sibling, 2 replies; 15+ messages in thread
From: Stephen Boyd @ 2009-10-07 8:48 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Junio C Hamano, git
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---
I sent this a while back, no response. If no response again I'll drop.
contrib/completion/git-completion.bash | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 2ab8c5e..a5fe1df 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -927,6 +927,8 @@ __git_diff_common_options="--stat --numstat --shortstat --summary
--inter-hunk-context=
--patience
--raw
+ --dirstat --dirstat= --dirstat-by-file
+ --dirstat-by-file= --cumulative
"
_git_diff ()
--
1.6.5.rc2.17.gdbc1b
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] completion: fix alias listings with newlines
2009-10-07 8:48 [PATCH 1/3] completion: fix alias listings with newlines Stephen Boyd
2009-10-07 8:48 ` [PATCH 2/3] completion: update am, commit, and log Stephen Boyd
@ 2009-10-07 9:33 ` Johannes Sixt
2009-10-07 18:55 ` Stephen Boyd
1 sibling, 1 reply; 15+ messages in thread
From: Johannes Sixt @ 2009-10-07 9:33 UTC (permalink / raw)
To: Stephen Boyd; +Cc: Shawn O. Pearce, Junio C Hamano, git
Stephen Boyd schrieb:
> __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/ */}"
> + local i
> + git --git-dir="$(__gitdir)" config -z --get-regexp "alias\..*" 2>/dev/null |
> + while IFS= read -rd '' i; do
> + echo ${i#alias.} | cut -d' ' -f1
> done
> }
Is it necessary to change the body of the loop? Your version spawns two
processes on each iteration, while the original spawned no processes.
You can avoid the pipeline (i.e. yet another process) using a "here-string":
local i aliases=$(git --git-dir="$(__gitdir)" config -z \
--get-regexp "alias\..*" 2>/dev/null)
while IFS= read -rd '' i; do
i="${i#alias.}"
echo "${i/ */}" # could be: echo "${i%% *}"
done <<< "$aliases"
but I don't know how well bash handles variable values with embedded NULs.
-- Hannes
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] completion: fix alias listings with newlines
2009-10-07 9:33 ` [PATCH 1/3] completion: fix alias listings with newlines Johannes Sixt
@ 2009-10-07 18:55 ` Stephen Boyd
2009-10-08 4:29 ` Shawn O. Pearce
0 siblings, 1 reply; 15+ messages in thread
From: Stephen Boyd @ 2009-10-07 18:55 UTC (permalink / raw)
To: Johannes Sixt; +Cc: Shawn O. Pearce, Junio C Hamano, git
Johannes Sixt wrote:
> Is it necessary to change the body of the loop? Your version spawns two
> processes on each iteration, while the original spawned no processes.
>
> You can avoid the pipeline (i.e. yet another process) using a "here-string":
>
> local i aliases=$(git --git-dir="$(__gitdir)" config -z \
> --get-regexp "alias\..*" 2>/dev/null)
> while IFS= read -rd '' i; do
> i="${i#alias.}"
> echo "${i/ */}" # could be: echo "${i%% *}"
> done <<< "$aliases"
>
> but I don't know how well bash handles variable values with embedded NULs.
I can't get the above snippet to work, but maybe I'm doing something wrong.
I had a problem with the newline between the key and the value. bash
gives me the whole line in the loop, but when I try to trim it $i is
treated as two values. I couldn't figure out any other way to do it,
besides piping $i to cut or tr.
Maybe a better solution would be to add --keys-only or something to
git-config?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/3] completion: update am, commit, and log
2009-10-07 8:48 ` [PATCH 2/3] completion: update am, commit, and log Stephen Boyd
2009-10-07 8:48 ` [PATCH 3/3] completion: add dirstat and friends to diff options Stephen Boyd
@ 2009-10-07 19:45 ` Junio C Hamano
1 sibling, 0 replies; 15+ messages in thread
From: Junio C Hamano @ 2009-10-07 19:45 UTC (permalink / raw)
To: Stephen Boyd; +Cc: Shawn O. Pearce, Junio C Hamano, git
Stephen Boyd <bebarino@gmail.com> writes:
> git am learned --scissors, git commit learned --dry-run and git log
> learned --decorate=long|short recently.
>
> Signed-off-by: Stephen Boyd <bebarino@gmail.com>
No objection from me, but I am not a completion expert ;-)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] completion: add dirstat and friends to diff options
2009-10-07 8:48 ` [PATCH 3/3] completion: add dirstat and friends to diff options Stephen Boyd
@ 2009-10-07 19:45 ` Junio C Hamano
[not found] ` <20091007205059.GA16235@neumann>
1 sibling, 0 replies; 15+ messages in thread
From: Junio C Hamano @ 2009-10-07 19:45 UTC (permalink / raw)
To: Stephen Boyd; +Cc: Shawn O. Pearce, Junio C Hamano, git
Stephen Boyd <bebarino@gmail.com> writes:
> Signed-off-by: Stephen Boyd <bebarino@gmail.com>
No objection from me, but I am not a completion expert ;-)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] completion: add dirstat and friends to diff options
[not found] ` <20091007205059.GA16235@neumann>
@ 2009-10-07 23:07 ` Junio C Hamano
[not found] ` <20091007233442.GJ6055@neumann>
2009-10-08 4:32 ` Shawn O. Pearce
0 siblings, 2 replies; 15+ messages in thread
From: Junio C Hamano @ 2009-10-07 23:07 UTC (permalink / raw)
To: SZEDER Gábor; +Cc: Stephen Boyd, Shawn O. Pearce, Junio C Hamano, git
SZEDER Gábor <szeder@ira.uka.de> writes:
> On Wed, Oct 07, 2009 at 01:48:51AM -0700, Stephen Boyd wrote:
>> + --dirstat --dirstat= --dirstat-by-file
>> + --dirstat-by-file= --cumulative
>
> I'm a bit puzzled by having both --dirstat and --dirstat=, and
> --dirstat-by-file and --dirstat-by-file=. How do we complete similar
> long options, where an argument and hence the = char is optional?
A similar example in "git init" completion (--shared vs --shared=) already
exists, no?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] completion: add dirstat and friends to diff options
[not found] ` <20091007233442.GJ6055@neumann>
@ 2009-10-08 0:11 ` Stephen Boyd
0 siblings, 0 replies; 15+ messages in thread
From: Stephen Boyd @ 2009-10-08 0:11 UTC (permalink / raw)
To: SZEDER Gábor; +Cc: Junio C Hamano, Shawn O. Pearce, git
SZEDER Gábor wrote:
> But there are no git log --stat=, --color-words= and --decorate=, but
> only --stat, --color-words and --decorate, and there are git log
> --pretty= and --format=, but no --pretty and --format. I have not
> looked at other commands yet.
>
I guess this is because nobody has added these. Feel free to send a
follow up patch.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] completion: fix alias listings with newlines
2009-10-07 18:55 ` Stephen Boyd
@ 2009-10-08 4:29 ` Shawn O. Pearce
2009-10-08 7:34 ` Stephen Boyd
0 siblings, 1 reply; 15+ messages in thread
From: Shawn O. Pearce @ 2009-10-08 4:29 UTC (permalink / raw)
To: Stephen Boyd; +Cc: Johannes Sixt, Junio C Hamano, git
Stephen Boyd <bebarino@gmail.com> wrote:
> Johannes Sixt wrote:
> > Is it necessary to change the body of the loop? Your version spawns two
> > processes on each iteration, while the original spawned no processes.
Yes, we should try to avoid spawning a process here, it fires on
each completion attempt if I recall.
> Maybe a better solution would be to add --keys-only or something to
> git-config?
Or a format string with a language based escape like for-each-ref
supports? Might make it easier to use git config in scripts if we
can write things like:
git config --format='$data{%(key)}=%(value);' --perl
--
Shawn.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] completion: add dirstat and friends to diff options
2009-10-07 23:07 ` Junio C Hamano
[not found] ` <20091007233442.GJ6055@neumann>
@ 2009-10-08 4:32 ` Shawn O. Pearce
1 sibling, 0 replies; 15+ messages in thread
From: Shawn O. Pearce @ 2009-10-08 4:32 UTC (permalink / raw)
To: Junio C Hamano; +Cc: SZEDER G??bor, Stephen Boyd, git
Junio C Hamano <gitster@pobox.com> wrote:
> SZEDER G??bor <szeder@ira.uka.de> writes:
>
> > On Wed, Oct 07, 2009 at 01:48:51AM -0700, Stephen Boyd wrote:
> >> + --dirstat --dirstat= --dirstat-by-file
> >> + --dirstat-by-file= --cumulative
> >
> > I'm a bit puzzled by having both --dirstat and --dirstat=, and
> > --dirstat-by-file and --dirstat-by-file=. How do we complete similar
> > long options, where an argument and hence the = char is optional?
>
> A similar example in "git init" completion (--shared vs --shared=) already
> exists, no?
I'm not sure why this is. It may just be historical accident,
completing --shared vs. --shared= is ambiguous so you would need
to type out the = anyway before trying to complete a value.
IIRC --shared= came about after --shared and its possible we just
added the new option and didn't notice the duplicate.
--
Shawn.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] completion: fix alias listings with newlines
2009-10-08 4:29 ` Shawn O. Pearce
@ 2009-10-08 7:34 ` Stephen Boyd
2009-10-08 7:54 ` Johannes Sixt
0 siblings, 1 reply; 15+ messages in thread
From: Stephen Boyd @ 2009-10-08 7:34 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Johannes Sixt, Junio C Hamano, git
Shawn O. Pearce wrote:
>
> Yes, we should try to avoid spawning a process here, it fires on
> each completion attempt if I recall.
>
Ok. It looks like it fires on every completion with no command (i.e. git
<TAB><TAB>). I don't particularly like my solution anyways, and this has
existed for a long time (56fc25f maybe?) with no one noticing. A fix for
it is probably not too pressing.
I found another problem, [ARGS] and COMMAND show up in git <TAB><TAB>.
Looks like it's due to the wrapping of git's usage string.
>
> Or a format string with a language based escape like for-each-ref
> supports? Might make it easier to use git config in scripts if we
> can write things like:
>
> git config --format='$data{%(key)}=%(value);' --perl
This sounds reasonable, but also like more work ;-)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] completion: fix alias listings with newlines
2009-10-08 7:34 ` Stephen Boyd
@ 2009-10-08 7:54 ` Johannes Sixt
2009-10-08 8:01 ` Stephen Boyd
0 siblings, 1 reply; 15+ messages in thread
From: Johannes Sixt @ 2009-10-08 7:54 UTC (permalink / raw)
To: Stephen Boyd; +Cc: Shawn O. Pearce, Junio C Hamano, git
Stephen Boyd schrieb:
> Shawn O. Pearce wrote:
>> Or a format string with a language based escape like for-each-ref
>> supports? Might make it easier to use git config in scripts if we
>> can write things like:
>>
>> git config --format='$data{%(key)}=%(value);' --perl
>
> This sounds reasonable, but also like more work ;-)
OTOH, you can simply revert the hunk from 518ef8f (completion: Replace
config --list with --get-regexp, 2009-09-11) that applies here, or even
only reinstate the case statement in the loop body without changing
anything else.
-- Hannes
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] completion: fix alias listings with newlines
2009-10-08 7:54 ` Johannes Sixt
@ 2009-10-08 8:01 ` Stephen Boyd
2009-10-08 8:10 ` Johannes Sixt
0 siblings, 1 reply; 15+ messages in thread
From: Stephen Boyd @ 2009-10-08 8:01 UTC (permalink / raw)
To: Johannes Sixt; +Cc: Shawn O. Pearce, Junio C Hamano, git
Johannes Sixt wrote:
>
> OTOH, you can simply revert the hunk from 518ef8f (completion: Replace
> config --list with --get-regexp, 2009-09-11) that applies here, or even
> only reinstate the case statement in the loop body without changing
> anything else.
I'm not opposed to the idea, but then it wouldn't work with something like
[alias]
whowhat = "log --format="%an\nalias.broken=foo'"
although that actually happening is probably rare, it can still happen.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] completion: fix alias listings with newlines
2009-10-08 8:01 ` Stephen Boyd
@ 2009-10-08 8:10 ` Johannes Sixt
0 siblings, 0 replies; 15+ messages in thread
From: Johannes Sixt @ 2009-10-08 8:10 UTC (permalink / raw)
To: Stephen Boyd; +Cc: Shawn O. Pearce, Junio C Hamano, git
Stephen Boyd schrieb:
> Johannes Sixt wrote:
>> OTOH, you can simply revert the hunk from 518ef8f (completion: Replace
>> config --list with --get-regexp, 2009-09-11) that applies here, or even
>> only reinstate the case statement in the loop body without changing
>> anything else.
>
> I'm not opposed to the idea, but then it wouldn't work with something like
>
> [alias]
> whowhat = "log --format="%an\nalias.broken=foo'"
>
> although that actually happening is probably rare, it can still happen.
I'd ignore this case, but *you* write the patch, *you* get to draw the line ;)
-- Hannes
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2009-10-08 8:14 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-07 8:48 [PATCH 1/3] completion: fix alias listings with newlines Stephen Boyd
2009-10-07 8:48 ` [PATCH 2/3] completion: update am, commit, and log Stephen Boyd
2009-10-07 8:48 ` [PATCH 3/3] completion: add dirstat and friends to diff options Stephen Boyd
2009-10-07 19:45 ` Junio C Hamano
[not found] ` <20091007205059.GA16235@neumann>
2009-10-07 23:07 ` Junio C Hamano
[not found] ` <20091007233442.GJ6055@neumann>
2009-10-08 0:11 ` Stephen Boyd
2009-10-08 4:32 ` Shawn O. Pearce
2009-10-07 19:45 ` [PATCH 2/3] completion: update am, commit, and log Junio C Hamano
2009-10-07 9:33 ` [PATCH 1/3] completion: fix alias listings with newlines Johannes Sixt
2009-10-07 18:55 ` Stephen Boyd
2009-10-08 4:29 ` Shawn O. Pearce
2009-10-08 7:34 ` Stephen Boyd
2009-10-08 7:54 ` Johannes Sixt
2009-10-08 8:01 ` Stephen Boyd
2009-10-08 8:10 ` Johannes Sixt
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).