about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2015-08-19 21:17:50 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2015-08-19 23:29:49 +0000
commit663fa4092fcc492e49fbf4d396d0b5b0a2325a48 (patch)
treef4f3c9bc1de678e2257baae344aa18aaaa4184a2 /Completion
parenta4c41fff1261c4c0251fe969e7684c582160f93a (diff)
downloadzsh-663fa4092fcc492e49fbf4d396d0b5b0a2325a48.tar.gz
zsh-663fa4092fcc492e49fbf4d396d0b5b0a2325a48.tar.xz
zsh-663fa4092fcc492e49fbf4d396d0b5b0a2325a48.zip
36237: __git_objects: Complete HEAD:foo correctly in worktree subdir
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Unix/Command/_git15
1 files changed, 13 insertions, 2 deletions
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index fc9d7ce9f..e1a38e935 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -5740,7 +5740,7 @@ __git_tree_ishs () {
 __git_objects () {
   compset -P '*:'
   if [[ -n $IPREFIX ]]; then
-    __git_tree_files "$PREFIX" "${IPREFIX%:}"
+    __git_tree_files --root-relative "$PREFIX" "${IPREFIX%:}"
   else
     _alternative \
       'revisions::__git_revisions' \
@@ -5985,12 +5985,23 @@ __git_changed_files () {
     'changed-in-working-tree-files::__git_changed-in-working-tree_files'
 }
 
+#     __git_tree_files [--root-relative] FSPATH TREEISH [TREEISH...] [COMPADD OPTIONS]
+#
+# Complete [presently: a single level of] repository files under FSPATH.
+# FSPATH is interpreted as a directory path within each TREEISH.
+# FSPATH is relative to cwd, unless --root-relative is specified, in
+# which case it is relative to the repository root.
 (( $+functions[__git_tree_files] )) ||
 __git_tree_files () {
   local multi_parts_opts
   local tree Path
   integer at_least_one_tree_added
   local -a tree_files compadd_opts
+  local -a extra_args
+
+  if [[ $1 == --root-relative ]]; then
+    extra_args+=(--full-tree)
+  fi
 
   zparseopts -D -E -a compadd_opts V: J: 1 2 n f X: M: P: S: r: R: q F:
 
@@ -5998,7 +6009,7 @@ __git_tree_files () {
   shift
   (( at_least_one_tree_added = 0 ))
   for tree in $*; do
-    tree_files+=(${(ps:\0:)"$(_call_program tree-files git ls-tree --name-only -z $tree $Path 2>/dev/null)"})
+    tree_files+=(${(ps:\0:)"$(_call_program tree-files git ls-tree $extra_args --name-only -z $tree $Path 2>/dev/null)"})
     __git_command_successful $pipestatus && (( at_least_one_tree_added = 1 ))
   done