Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-01-24 00:52:27 +0300
committerJunio C Hamano <gitster@pobox.com>2024-01-24 00:52:28 +0300
commit1c11c74eb3b492a69989705114c29133e517184f (patch)
treee6e9d201f8874653e37f200cd6aea6553ced8e17 /contrib
parent407f05103c874197ee86b448d4b01544c9f6bf3d (diff)
parent306f468cc02ac1c42515ab95a0bd05c0dc963bed (diff)
Merge branch 'bk/complete-dirname-for-am-and-format-patch' into seen
Command line completion support (in contrib/) has been updated for a few commands to complete directory names where a directory name is expected. * bk/complete-dirname-for-am-and-format-patch: completion: dir-type optargs for am, format-patch
Diffstat (limited to 'contrib')
-rw-r--r--contrib/completion/git-completion.bash37
1 files changed, 37 insertions, 0 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 5d09e3d317..23c0b795ce 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1392,6 +1392,29 @@ __git_count_arguments ()
printf "%d" $c
}
+# Complete actual dir (not pathspec), respecting any -C options.
+#
+# Usage: __git_complete_refs [<option>]...
+# --cur=<word>: The current dir to be completed. Defaults to the current word.
+__git_complete_dir ()
+{
+ local cur_="$cur"
+
+ while test $# != 0; do
+ case "$1" in
+ --cur=*) cur_="${1##--cur=}" ;;
+ *) return 1 ;;
+ esac
+ shift
+ done
+
+ # This rev-parse invocation amounts to a pwd which respects -C options
+ local context_dir=$(__git rev-parse --show-toplevel --show-prefix 2>/dev/null | paste -s -d '/' 2>/dev/null)
+ [ -d "$context_dir" ] || return 1
+
+ COMPREPLY=$(cd "$context_dir" 2>/dev/null && compgen -d -- "$cur_")
+}
+
__git_whitespacelist="nowarn warn error error-all fix"
__git_patchformat="mbox stgit stgit-series hg mboxrd"
__git_showcurrentpatch="diff raw"
@@ -1410,6 +1433,10 @@ _git_am ()
__gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
return
;;
+ --directory=*)
+ __git_complete_dir --cur="${cur##--directory=}"
+ return
+ ;;
--patch-format=*)
__gitcomp "$__git_patchformat" "" "${cur##--patch-format=}"
return
@@ -2090,7 +2117,17 @@ __git_format_patch_extra_options="
_git_format_patch ()
{
+ case "$prev,$cur" in
+ -o,*)
+ __git_complete_dir
+ return
+ ;;
+ esac
case "$cur" in
+ --output-directory=*)
+ __git_complete_dir --cur="${cur##--output-directory=}"
+ return
+ ;;
--thread=*)
__gitcomp "
deep shallow