Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Zsh git filename completion with “--git-dir=… --work-tree=…”: not a git repository
- X-seq: zsh-workers 41523
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: "Tom M." <boojum@xxxxxxxxxxxxxxxxxxx>, zsh-workers@xxxxxxx
- Subject: Re: Zsh git filename completion with “--git-dir=… --work-tree=…”: not a git repository
- Date: Thu, 10 Aug 2017 17:14:16 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=s8ypYK CNxTRfbnfm2q8TQeroJxEQp1UFijOwRVwYVOQ=; b=VomE1mDvc/ymbd7Y2RzReg u2EULReMQETptoJ+3yUxNbT8JVWSTYbxUcK5Cmk7W1mgz7HiJ78fOBa7sbdr6hGW 9O2szt7RkIh2mrMYFadFSGLzKV5kTtO5nkEo9hDn4FL9Y+oNJxAAPNMvuDqPgiZ2 O7isyvdR1BeYUH3xgj8Z7msUp0A9vIgsJzCQ55tLHij6UAvCQxzmSjwHq5LohU+1 2P3trn51+63kq5P/5X/2z0kyP6/v0ztAiF59OcFrI47VXWGlpjvOOa6UehxMYNGb TCKPfUbzsjFID0m5iQu9Ix7yuuA5IbXlIDMBf1LyF6oYW9J+ZlUbJoRK7sPeXlEQ ==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=s8ypYK CNxTRfbnfm2q8TQeroJxEQp1UFijOwRVwYVOQ=; b=egRGEmHwl3p4RHB1zqjucZ RBXWjkrWdn9FL2FvcvU6iHy1XfF5vVekJThSCuc0I7cX+ae8d2EnA+KEvrKyVmsc A3ZAFqIV8A2pAg+Rpun1Um79uQNcJJgszqWX7fKBMbYkYGAEsCyqsiFAOen+5404 A4RudX5vxN0uplWaqEnFt/hfLPnF1dLEQlxaoNpAKfOuAcQqFqXDfjwSqmhpOMWq aJIp9ojTMhdeB8oNY7zSpYUE0ss0hxEZx5poz3QrJEBxdmn55U1WlUPRCybwyeXn Ug+FG+6RFEh218jYJJnZvFLJkh28zgaYTPkiQ7t+rcdZizC0PeBYP5MIPw8VNEIQ ==
- In-reply-to: <CACfAdfa3-KTa6UJAEhkkjjVcxqa_8JdJweRE6ukTLmnAsj+8CA@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CACfAdfZ8xpPTZm2bKvYFoeUWgWDbYHwGRCU8+mLvkAV5YrOnig@mail.gmail.com> <CACfAdfa3-KTa6UJAEhkkjjVcxqa_8JdJweRE6ukTLmnAsj+8CA@mail.gmail.com>
Tom M. wrote on Thu, 10 Aug 2017 14:15 +0100:
> % dof --work-tree=$HOME add [Tab]
> ---- not a git repository
Could you try the following patch. For me, it fixes «git add
--git-dir=$HOME/src/zsh/.git --work-tree=$HOME/src/zsh <TAB>».
@workers: Is ${(e)} the right thing to do in this context? Without that
modifier, GIT_WORK_TREE would be set to '$HOME/src/zsh' literally (with the
dollar sign).
Supporting «GIT_DIR=/foo git bar <TAB>» would require a separate patch.
Cheers,
Daniel
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 518e6d198..45a0fa622 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -6609,20 +6609,33 @@ __git_files_relative () {
(( $+functions[__git_files] )) ||
__git_files () {
local compadd_opts opts tag description gitcdup gitprefix files expl
+ local pref
zparseopts -D -E -a compadd_opts V: J: 1 2 n f X: M: P: S: r: R: q F:
zparseopts -D -E -a opts -- -cached -deleted -modified -others -ignored -unmerged -killed x+: --exclude+:
tag=$1 description=$2; shift 2
- gitcdup=$(_call_program gitcdup git rev-parse --show-cdup 2>/dev/null)
- __git_command_successful $pipestatus || return 1
+ case $(_call_program gitinworktree git rev-parse --is-inside-work-tree 2>/dev/null) in
+ (true)
+ gitcdup=$(_call_program gitcdup git rev-parse --show-cdup 2>/dev/null)
+ __git_command_successful $pipestatus || return 1
- gitprefix=$(_call_program gitprefix git rev-parse --show-prefix 2>/dev/null)
- __git_command_successful $pipestatus || return 1
+ gitprefix=$(_call_program gitprefix git rev-parse --show-prefix 2>/dev/null)
+ __git_command_successful $pipestatus || return 1
+
+ local pref=$gitcdup$gitprefix$PREFIX
+ ;;
+ (false)
+ local pref=
+ ;;
+ (*)
+ # XXX what to do?
+ return 1
+ ;;
+ esac
# TODO: --directory should probably be added to $opts when --others is given.
- local pref=$gitcdup$gitprefix$PREFIX
# First allow ls-files to pattern-match in case of remote repository
files=(${(0)"$(_call_program files git ls-files -z --exclude-standard ${(q)opts} -- ${(q)${pref:+$pref\\\*}} 2>/dev/null)"})
@@ -7585,7 +7598,8 @@ _git() {
;;
(option-or-argument)
curcontext=${curcontext%:*:*}:git-$words[1]:
- (( $+opt_args[--git-dir] )) && local -x GIT_DIR=$opt_args[--git-dir]
+ (( $+opt_args[--git-dir] )) && local -x GIT_DIR=${(e)opt_args[--git-dir]}
+ (( $+opt_args[--work-tree] )) && local -x GIT_WORK_TREE=${(e)opt_args[--work-tree]}
if ! _call_function ret _git-$words[1]; then
if zstyle -T :completion:$curcontext: use-fallback; then
_default && ret=0
Messages sorted by:
Reverse Date,
Date,
Thread,
Author