* [PATCH 00/11] Completion fixes and improvements
@ 2016-05-20 4:58 Felipe Contreras
2016-05-20 4:58 ` [PATCH 01/11] completion: add missing fetch options Felipe Contreras
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: Felipe Contreras @ 2016-05-20 4:58 UTC (permalink / raw)
To: git; +Cc: Felipe Contreras
Hi,
Here's a bunch of patches I've been using for a long time. I don't recall if
I've sent some of these before.
Here they are in case anybody is interested.
Cheers.
Felipe Contreras (11):
completion: add missing fetch options
completion: bash: remove old wrappers
completion: bash: remove zsh wrapper
completion: zsh: don't hide ourselves
completion: remove zsh hack
completion: zsh: trivial cleanups
completion: bash: cleanup cygwin check
completion: zsh: improve main function selection
completion: zsh: fix for directories with spaces
completion: prompt: fix for Zsh
Revert "Update documentation occurrences of filename .sh"
contrib/completion/git-completion.bash | 86 +++-------------------------------
contrib/completion/git-completion.zsh | 26 ++++------
contrib/completion/git-prompt.sh | 8 ++--
3 files changed, 20 insertions(+), 100 deletions(-)
--
2.8.0+fc1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 01/11] completion: add missing fetch options
2016-05-20 4:58 [PATCH 00/11] Completion fixes and improvements Felipe Contreras
@ 2016-05-20 4:58 ` Felipe Contreras
2016-05-20 4:58 ` [PATCH 02/11] completion: bash: remove old wrappers Felipe Contreras
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Felipe Contreras @ 2016-05-20 4:58 UTC (permalink / raw)
To: git; +Cc: Felipe Contreras
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
contrib/completion/git-completion.bash | 2 ++
1 file changed, 2 insertions(+)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index e3918c8..ecdf742 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1225,6 +1225,8 @@ __git_fetch_recurse_submodules="yes on-demand no"
__git_fetch_options="
--quiet --verbose --append --upload-pack --force --keep --depth=
--tags --no-tags --all --prune --dry-run --recurse-submodules=
+ --no-recurse-submodules --unshallow --update-shallow --multiple
+ --submodule-prefix= --update-head-ok --progress
"
_git_fetch ()
--
2.8.0+fc1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 02/11] completion: bash: remove old wrappers
2016-05-20 4:58 [PATCH 00/11] Completion fixes and improvements Felipe Contreras
2016-05-20 4:58 ` [PATCH 01/11] completion: add missing fetch options Felipe Contreras
@ 2016-05-20 4:58 ` Felipe Contreras
2016-05-20 4:58 ` [PATCH 03/11] completion: bash: remove zsh wrapper Felipe Contreras
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Felipe Contreras @ 2016-05-20 4:58 UTC (permalink / raw)
To: git; +Cc: Felipe Contreras
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
contrib/completion/git-completion.bash | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index ecdf742..5e2e590 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2754,18 +2754,6 @@ __git_complete ()
|| complete -o default -o nospace -F $wrapper $1
}
-# wrapper for backwards compatibility
-_git ()
-{
- __git_wrap__git_main
-}
-
-# wrapper for backwards compatibility
-_gitk ()
-{
- __git_wrap__gitk_main
-}
-
__git_complete git __git_main
__git_complete gitk __gitk_main
--
2.8.0+fc1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 03/11] completion: bash: remove zsh wrapper
2016-05-20 4:58 [PATCH 00/11] Completion fixes and improvements Felipe Contreras
2016-05-20 4:58 ` [PATCH 01/11] completion: add missing fetch options Felipe Contreras
2016-05-20 4:58 ` [PATCH 02/11] completion: bash: remove old wrappers Felipe Contreras
@ 2016-05-20 4:58 ` Felipe Contreras
2016-05-20 4:58 ` [PATCH 04/11] completion: zsh: don't hide ourselves Felipe Contreras
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Felipe Contreras @ 2016-05-20 4:58 UTC (permalink / raw)
To: git; +Cc: Felipe Contreras
It has been deprecated for more than three years. It's time to move on.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
contrib/completion/git-completion.bash | 64 ----------------------------------
1 file changed, 64 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 5e2e590..9cbae6f 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2672,70 +2672,6 @@ __gitk_main ()
__git_complete_revlist
}
-if [[ -n ${ZSH_VERSION-} ]]; then
- echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2
-
- autoload -U +X compinit && compinit
-
- __gitcomp ()
- {
- emulate -L zsh
-
- local cur_="${3-$cur}"
-
- case "$cur_" in
- --*=)
- ;;
- *)
- local c IFS=$' \t\n'
- local -a array
- for c in ${=1}; do
- c="$c${4-}"
- case $c in
- --*=*|*.) ;;
- *) c="$c " ;;
- esac
- array[${#array[@]}+1]="$c"
- done
- compset -P '*[=:]'
- compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
- ;;
- esac
- }
-
- __gitcomp_nl ()
- {
- emulate -L zsh
-
- local IFS=$'\n'
- compset -P '*[=:]'
- compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
- }
-
- __gitcomp_file ()
- {
- emulate -L zsh
-
- local IFS=$'\n'
- compset -P '*[=:]'
- compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
- }
-
- _git ()
- {
- local _ret=1 cur cword prev
- cur=${words[CURRENT]}
- prev=${words[CURRENT-1]}
- let cword=CURRENT-1
- emulate ksh -c __${service}_main
- let _ret && _default && _ret=0
- return _ret
- }
-
- compdef _git git gitk
- return
-fi
-
__git_func_wrap ()
{
local cur words cword prev
--
2.8.0+fc1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 04/11] completion: zsh: don't hide ourselves
2016-05-20 4:58 [PATCH 00/11] Completion fixes and improvements Felipe Contreras
` (2 preceding siblings ...)
2016-05-20 4:58 ` [PATCH 03/11] completion: bash: remove zsh wrapper Felipe Contreras
@ 2016-05-20 4:58 ` Felipe Contreras
2016-05-20 4:58 ` [PATCH 05/11] completion: remove zsh hack Felipe Contreras
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Felipe Contreras @ 2016-05-20 4:58 UTC (permalink / raw)
To: git; +Cc: Felipe Contreras
There's no need to hide the fact that we are on zsh any more.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
contrib/completion/git-completion.zsh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index e255413..475705a 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -39,7 +39,7 @@ if [ -z "$script" ]; then
test -f $e && script="$e" && break
done
fi
-ZSH_VERSION='' . "$script"
+. "$script"
__gitcomp ()
{
--
2.8.0+fc1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 05/11] completion: remove zsh hack
2016-05-20 4:58 [PATCH 00/11] Completion fixes and improvements Felipe Contreras
` (3 preceding siblings ...)
2016-05-20 4:58 ` [PATCH 04/11] completion: zsh: don't hide ourselves Felipe Contreras
@ 2016-05-20 4:58 ` Felipe Contreras
2016-05-20 4:58 ` [PATCH 06/11] completion: zsh: trivial cleanups Felipe Contreras
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Felipe Contreras @ 2016-05-20 4:58 UTC (permalink / raw)
To: git; +Cc: Felipe Contreras
We don't want to override the 'complete()' function in zsh, which can be
used by bashcomp.
Reported-by: Mark Lodato <lodato@google.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
contrib/completion/git-completion.bash | 1 +
contrib/completion/git-completion.zsh | 6 ------
2 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 9cbae6f..6c338ae 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2684,6 +2684,7 @@ __git_func_wrap ()
# This is NOT a public function; use at your own risk.
__git_complete ()
{
+ test -n "$ZSH_VERSION" && return
local wrapper="__git_wrap${2}"
eval "$wrapper () { __git_func_wrap $2 ; }"
complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 475705a..e10df7d 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -16,12 +16,6 @@
#
# fpath=(~/.zsh $fpath)
-complete ()
-{
- # do nothing
- return 0
-}
-
zstyle -T ':completion:*:*:git:*' tag-order && \
zstyle ':completion:*:*:git:*' tag-order 'common-commands'
--
2.8.0+fc1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 06/11] completion: zsh: trivial cleanups
2016-05-20 4:58 [PATCH 00/11] Completion fixes and improvements Felipe Contreras
` (4 preceding siblings ...)
2016-05-20 4:58 ` [PATCH 05/11] completion: remove zsh hack Felipe Contreras
@ 2016-05-20 4:58 ` Felipe Contreras
2016-05-20 4:58 ` [PATCH 07/11] completion: bash: cleanup cygwin check Felipe Contreras
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Felipe Contreras @ 2016-05-20 4:58 UTC (permalink / raw)
To: git; +Cc: Felipe Contreras
We don't need to override IFS, zsh has a native way of splitting by new
lines: the expansion flag (f).
Also, we don't need to split files by ':' or '='; that's only for words.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
contrib/completion/git-completion.zsh | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index e10df7d..317b8eb 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -65,26 +65,22 @@ __gitcomp_nl ()
{
emulate -L zsh
- local IFS=$'\n'
compset -P '*[=:]'
- compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
+ compadd -Q -S "${4- }" -p "${2-}" -- ${(f)1} && _ret=0
}
__gitcomp_nl_append ()
{
emulate -L zsh
- local IFS=$'\n'
- compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
+ compadd -Q -S "${4- }" -p "${2-}" -- ${(f)1} && _ret=0
}
__gitcomp_file ()
{
emulate -L zsh
- local IFS=$'\n'
- compset -P '*[=:]'
- compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
+ compadd -Q -p "${2-}" -f -- ${(f)1} && _ret=0
}
__git_zsh_bash_func ()
--
2.8.0+fc1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 07/11] completion: bash: cleanup cygwin check
2016-05-20 4:58 [PATCH 00/11] Completion fixes and improvements Felipe Contreras
` (5 preceding siblings ...)
2016-05-20 4:58 ` [PATCH 06/11] completion: zsh: trivial cleanups Felipe Contreras
@ 2016-05-20 4:58 ` Felipe Contreras
2016-05-20 4:58 ` [PATCH 08/11] completion: zsh: improve main function selection Felipe Contreras
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Felipe Contreras @ 2016-05-20 4:58 UTC (permalink / raw)
To: git; +Cc: Felipe Contreras
Avoid Yoda conditions, use test, and cleaner statement.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
contrib/completion/git-completion.bash | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 6c338ae..398f3a7 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2698,6 +2698,5 @@ __git_complete gitk __gitk_main
# when the user has tab-completed the executable name and consequently
# included the '.exe' suffix.
#
-if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
+test "$(uname -o 2>/dev/null)" = "Cygwin" &&
__git_complete git.exe __git_main
-fi
--
2.8.0+fc1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 08/11] completion: zsh: improve main function selection
2016-05-20 4:58 [PATCH 00/11] Completion fixes and improvements Felipe Contreras
` (6 preceding siblings ...)
2016-05-20 4:58 ` [PATCH 07/11] completion: bash: cleanup cygwin check Felipe Contreras
@ 2016-05-20 4:58 ` Felipe Contreras
2016-05-20 4:58 ` [PATCH 09/11] completion: zsh: fix for directories with spaces Felipe Contreras
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Felipe Contreras @ 2016-05-20 4:58 UTC (permalink / raw)
To: git; +Cc: Felipe Contreras
Sometimes we want to use the function directly (e.g. _git_checkout), for
example when zsh has the option 'complete_aliases', this way, we can do
something like:
compdef _git gco=git_checkout
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
contrib/completion/git-completion.zsh | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 317b8eb..1f786cc 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -204,8 +204,10 @@ _git ()
if (( $+functions[__${service}_zsh_main] )); then
__${service}_zsh_main
- else
+ elif (( $+functions[__${service}_main] )); then
emulate ksh -c __${service}_main
+ elif (( $+functions[_${service}] )); then
+ emulate ksh -c _${service}
fi
let _ret && _default && _ret=0
--
2.8.0+fc1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 09/11] completion: zsh: fix for directories with spaces
2016-05-20 4:58 [PATCH 00/11] Completion fixes and improvements Felipe Contreras
` (7 preceding siblings ...)
2016-05-20 4:58 ` [PATCH 08/11] completion: zsh: improve main function selection Felipe Contreras
@ 2016-05-20 4:58 ` Felipe Contreras
2016-05-20 4:58 ` [PATCH 10/11] completion: prompt: fix for Zsh Felipe Contreras
2016-05-20 4:58 ` [PATCH 11/11] Revert "Update documentation occurrences of filename .sh" Felipe Contreras
10 siblings, 0 replies; 12+ messages in thread
From: Felipe Contreras @ 2016-05-20 4:58 UTC (permalink / raw)
To: git; +Cc: Felipe Contreras
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
contrib/completion/git-completion.zsh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 1f786cc..28eaaed 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -24,7 +24,7 @@ if [ -z "$script" ]; then
local -a locations
local e
locations=(
- $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
+ "$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash
'/etc/bash_completion.d/git' # fedora, old debian
'/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
'/usr/share/bash-completion/git' # gentoo
--
2.8.0+fc1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 10/11] completion: prompt: fix for Zsh
2016-05-20 4:58 [PATCH 00/11] Completion fixes and improvements Felipe Contreras
` (8 preceding siblings ...)
2016-05-20 4:58 ` [PATCH 09/11] completion: zsh: fix for directories with spaces Felipe Contreras
@ 2016-05-20 4:58 ` Felipe Contreras
2016-05-20 4:58 ` [PATCH 11/11] Revert "Update documentation occurrences of filename .sh" Felipe Contreras
10 siblings, 0 replies; 12+ messages in thread
From: Felipe Contreras @ 2016-05-20 4:58 UTC (permalink / raw)
To: git; +Cc: Felipe Contreras
We can add colour in Zsh without the need of pcmode.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
contrib/completion/git-prompt.sh | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 64219e6..0da14ee 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -502,9 +502,11 @@ __git_ps1 ()
local z="${GIT_PS1_STATESEPARATOR-" "}"
- # NO color option unless in PROMPT_COMMAND mode
- if [ $pcmode = yes ] && [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
- __git_ps1_colorize_gitstring
+ # NO color option unless in PROMPT_COMMAND mode or it's Zsh
+ if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
+ if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then
+ __git_ps1_colorize_gitstring
+ fi
fi
b=${b##refs/heads/}
--
2.8.0+fc1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 11/11] Revert "Update documentation occurrences of filename .sh"
2016-05-20 4:58 [PATCH 00/11] Completion fixes and improvements Felipe Contreras
` (9 preceding siblings ...)
2016-05-20 4:58 ` [PATCH 10/11] completion: prompt: fix for Zsh Felipe Contreras
@ 2016-05-20 4:58 ` Felipe Contreras
10 siblings, 0 replies; 12+ messages in thread
From: Felipe Contreras @ 2016-05-20 4:58 UTC (permalink / raw)
To: git; +Cc: Felipe Contreras
The original code was correct: the example location ~/.git-completion.sh
is correct, because it's not only used by Bash. And zstyle command in
Zsh should use that same location; the Bash script.
This reverts commit 0e5ed7cca3c51c821c2bb0465617e75d994f432f.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
contrib/completion/git-completion.bash | 4 ++--
contrib/completion/git-completion.zsh | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 398f3a7..3224ae1 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -17,9 +17,9 @@
#
# To use these routines:
#
-# 1) Copy this file to somewhere (e.g. ~/.git-completion.bash).
+# 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
# 2) Add the following line to your .bashrc/.zshrc:
-# source ~/.git-completion.bash
+# source ~/.git-completion.sh
# 3) Consider changing your PS1 to also show the current branch,
# see git-prompt.sh for details.
#
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 28eaaed..6075111 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -9,7 +9,7 @@
#
# If your script is somewhere else, you can configure it on your ~/.zshrc:
#
-# zstyle ':completion:*:*:git:*' script ~/.git-completion.zsh
+# zstyle ':completion:*:*:git:*' script ~/.git-completion.sh
#
# The recommended way to install this script is to copy to '~/.zsh/_git', and
# then add the following to your ~/.zshrc file:
--
2.8.0+fc1
^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2016-05-20 4:59 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-20 4:58 [PATCH 00/11] Completion fixes and improvements Felipe Contreras
2016-05-20 4:58 ` [PATCH 01/11] completion: add missing fetch options Felipe Contreras
2016-05-20 4:58 ` [PATCH 02/11] completion: bash: remove old wrappers Felipe Contreras
2016-05-20 4:58 ` [PATCH 03/11] completion: bash: remove zsh wrapper Felipe Contreras
2016-05-20 4:58 ` [PATCH 04/11] completion: zsh: don't hide ourselves Felipe Contreras
2016-05-20 4:58 ` [PATCH 05/11] completion: remove zsh hack Felipe Contreras
2016-05-20 4:58 ` [PATCH 06/11] completion: zsh: trivial cleanups Felipe Contreras
2016-05-20 4:58 ` [PATCH 07/11] completion: bash: cleanup cygwin check Felipe Contreras
2016-05-20 4:58 ` [PATCH 08/11] completion: zsh: improve main function selection Felipe Contreras
2016-05-20 4:58 ` [PATCH 09/11] completion: zsh: fix for directories with spaces Felipe Contreras
2016-05-20 4:58 ` [PATCH 10/11] completion: prompt: fix for Zsh Felipe Contreras
2016-05-20 4:58 ` [PATCH 11/11] Revert "Update documentation occurrences of filename .sh" Felipe Contreras
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).