From: SZEDER Gábor <hidden> Date: 2016-06-15 22:49:45
Users can have their own pretty format aliases since 8028184 (pretty:
add aliases for pretty formats, 2010-05-02), so let's offer those
after '--pretty=', too.
Similar to the completion of aliases, this will invoke 'git config'
each time pretty aliases needs to be completed, so changes in pretty.*
configuration will be reflected immediately.
Signed-off-by: SZEDER Gábor <redacted>
---
contrib/completion/git-completion.bash | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:49:45
SZEDER Gábor wrote:
Users can have their own pretty format aliases since 8028184 (pretty:
add aliases for pretty formats, 2010-05-02), so let's offer those
after '--pretty=', too.
Similar to the completion of aliases, this will invoke 'git config'
each time pretty aliases needs to be completed, so changes in pretty.*
configuration will be reflected immediately.
Does this apply to
git log --format=
git show --pretty=
git show --format=
too?
From: SZEDER Gábor <hidden> Date: 2016-06-15 22:49:45
Users can have their own pretty format aliases since 8028184 (pretty:
add aliases for pretty formats, 2010-05-02), so let's offer those
after '--pretty=' and '--format=' for 'log' and 'show', too.
Similar to the completion of aliases, this will invoke 'git config'
each time pretty aliases needs to be completed, so changes in pretty.*
configuration will be reflected immediately.
Signed-off-by: SZEDER Gábor <redacted>
---
On Sun, Oct 10, 2010 at 04:44:11PM -0500, Jonathan Nieder wrote:
Does this apply to
git log --format=
git show --pretty=
git show --format=
too?
If you look at this new __git_pretty_aliases() function and the old
__git_aliases(), then you'll see that it's quite a code duplication.
So, how about the following two patches instead?
From: SZEDER Gábor <hidden> Date: 2016-06-15 22:49:47
Users can have their own pretty format aliases since 8028184 (pretty:
add aliases for pretty formats, 2010-05-02), so let's offer those
after '--pretty=' and '--format=' for 'log' and 'show', too.
Signed-off-by: SZEDER Gábor <redacted>
---
contrib/completion/git-completion.bash | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
From: SZEDER Gábor <hidden> Date: 2016-06-15 22:49:47
Currently there are three completion functions that perform similar
queries to 'git config' to get config variable names. These are the
completion of aliases, remotes, and remote groups for 'git remote
update'. Since the following patch is about to add yet another
similar 'git config'-querying completion function to support pretty
aliases, it's time to introduce a unified helper function first to
avoid redundant code.
We took care that the resulting helper function still copes well with
newlines in config variable values and that it works with 'set -u'
(see commits e0d7805 (completion: fix alias listings with newlines,
2009-10-08) and 25a31f8 (bash-completion: Support running when set -u
is enabled, 2009-01-15) for details).
Signed-off-by: SZEDER Gábor <redacted>
---
contrib/completion/git-completion.bash | 28 +++++++++++-----------------
1 files changed, 11 insertions(+), 17 deletions(-)
@@ -750,14 +747,16 @@ __git_compute_porcelain_commands ():${__git_porcelain_commands:=$(__git_list_porcelain_commands)}}-__git_aliases()+# returns all config variables within a given section with an optional+# suffix, with both the section name and the suffix removed+__git_get_config_variables(){-localiIFS=$'\n'-foriin$(git--git-dir="$(__gitdir)"config--get-regexp"alias\..*"2>/dev/null);do+localsection="$1"suffix="${2-}"iIFS=$'\n'+foriin$(git--git-dir="$(__gitdir)"config--get-regexp"$section\..*${suffix:+\.$suffix}"2>/dev/null);docase"$i"in-alias.*)-i="${i#alias.}"-echo"${i/ */}"+$section.*)+i="${i#$section.}"+echo"${i/${suffix:+.$suffix} */}";;esacdone
Ok, so __git_get_config_variables $category $var means something like
git config --get-regexp '$category[.].*[.]$var' |
cut -d. -f2
quoted hunk
@@ -750,14 +747,16 @@ __git_compute_porcelain_commands () : ${__git_porcelain_commands:=$(__git_list_porcelain_commands)} }-__git_aliases ()+# returns all config variables within a given section with an optional+# suffix, with both the section name and the suffix removed+__git_get_config_variables () {- local i IFS=$'\n'- for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do+ local section="$1" suffix="${2-}" i IFS=$'\n'+ for i in $(git --git-dir="$(__gitdir)" config --get-regexp "$section\..*${suffix:+\.$suffix}" 2>/dev/null); do
Would it be possible to shorten this line? e.g.
for i in $(
git --git-dir="$(__gitdir)" ...
); do
or
while read -r setting
do
...
done < <(
git --git-dir="$(__gitdir)" ...
)
or
local ... IFS=$'\n'
set -- $(git ... )
for i do
...
done
Ok, so __git_get_config_variables $category $var means something like
git config --get-regexp '$category[.].*[.]$var' |
cut -d. -f2
Almost. Considering the current invocations of
__git_get_config_variables() introduced in this patch, yes, they do
the same. But "cut -d. -f2" will behave differently when $category
contains a dot, or when neither $category nor $var contain a dot, but
the config variable contains more than two (does git have any such
config variables?).
quoted
@@ -750,14 +747,16 @@ __git_compute_porcelain_commands () : ${__git_porcelain_commands:=$(__git_list_porcelain_commands)} }-__git_aliases ()+# returns all config variables within a given section with an optional+# suffix, with both the section name and the suffix removed+__git_get_config_variables () {- local i IFS=$'\n'- for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do+ local section="$1" suffix="${2-}" i IFS=$'\n'+ for i in $(git --git-dir="$(__gitdir)" config --get-regexp "$section\..*${suffix:+\.$suffix}" 2>/dev/null); do
Would it be possible to shorten this line? e.g.
for i in $(
git --git-dir="$(__gitdir)" ...
); do
or
while read -r setting
do
...
done < <(
git --git-dir="$(__gitdir)" ...
)
or
local ... IFS=$'\n'
set -- $(git ... )
for i do
...
done
Well, yes, of course. But the original line was already too long, and
neither of your proposals in itself would make it short enough to fit
80 characters. Besides, the latter two changes the loop itself, not
just what the body of the loop does and what it is looping on.
Maybe we could just split the line in two in the middle, like
for i in $(git --git-dir="$(__gitdir)" config --get-regexp \
$section\..*${suffix:+\.$suffix}" 2>/dev/null); do
Still doesn't look pretty, but maybe a bit better.
Best,
Gábor