From: Junio C Hamano <gitster@pobox.com>
To: Brandon Turner <bt@brandonturner.net>
Cc: "Øystein Walle" <oystwa@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH v4] completion: ignore chpwd_functions when cding on zsh
Date: Thu, 09 Oct 2014 13:45:21 -0700 [thread overview]
Message-ID: <xmqqk34955we.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1412881298-64117-1-git-send-email-bt@brandonturner.net> (Brandon Turner's message of "Thu, 9 Oct 2014 14:01:38 -0500")
Brandon Turner <bt@brandonturner.net> writes:
> As Øystein pointed out, on zsh we can use "cd -q" to ignore
> chpwd_functions.
>
> Junio - from my testing, unsetting CDPATH is sufficient on zsh.
Let's do this instead, though.
Bugs are mine; as I do not use zsh myself, some testing is very much
appreciated.
Thanks.
-- >8 --
Subject: [PATCH] completion: use "git -C $there" instead of (cd $there && git ...)
We have had "git -C $there" to first go to a different directory
and run a Git command without changing the arguments for quite some
time. Use it instead of (cd $there && git ...) in the completion
script.
This allows us to lose the work-around for misfeatures of modern
interactive-minded shells that make "cd" unusable in scripts (e.g.
end users' $CDPATH taking us to unexpected places in any POSIX
shell, and chpwd functions spewing unwanted output in zsh).
Based on Øystein Walle's idea, which was raised during the
discussion on the solution by Brandon Turner for a problem zsh users
had with RVM which mucks with chpwd_functions in users' environments
(https://github.com/wayneeseguin/rvm/issues/3076).
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
contrib/completion/git-completion.bash | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index dba3c15..42f7308 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -263,16 +263,12 @@ __gitcomp_file ()
# argument, and using the options specified in the second argument.
__git_ls_files_helper ()
{
- (
- test -n "${CDPATH+set}" && unset CDPATH
- cd "$1"
- if [ "$2" == "--committable" ]; then
- git diff-index --name-only --relative HEAD
- else
- # NOTE: $2 is not quoted in order to support multiple options
- git ls-files --exclude-standard $2
- fi
- ) 2>/dev/null
+ if [ "$2" == "--committable" ]; then
+ git -C "$1" diff-index --name-only --relative HEAD
+ else
+ # NOTE: $2 is not quoted in order to support multiple options
+ git -C "$1" ls-files --exclude-standard $2
+ fi 2>/dev/null
}
--
2.1.2-464-g5e996a3
next prev parent reply other threads:[~2014-10-09 20:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-08 3:53 [PATCH] completion: ignore chpwd_functions when cding Brandon Turner
2014-10-08 18:12 ` Junio C Hamano
2014-10-08 21:49 ` [PATCH v2] " Brandon Turner
2014-10-08 21:49 ` [PATCH v3] completion: ignore chpwd_functions when cding on zsh Brandon Turner
2014-10-09 7:34 ` Øystein Walle
2014-10-09 18:10 ` Junio C Hamano
2014-10-09 19:01 ` [PATCH v4] " Brandon Turner
2014-10-09 19:47 ` Øystein Walle
2014-10-09 20:01 ` Junio C Hamano
2014-10-09 20:45 ` Junio C Hamano [this message]
2014-10-09 22:04 ` Brandon Turner
2014-10-09 22:11 ` Junio C Hamano
2014-10-09 22:30 ` Brandon Turner
2014-10-16 18:10 ` Øystein Walle
2014-10-09 19:21 ` [PATCH v3] " Øystein Walle
2014-10-08 21:50 ` [PATCH] completion: ignore chpwd_functions when cding Brandon Turner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqk34955we.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=bt@brandonturner.net \
--cc=git@vger.kernel.org \
--cc=oystwa@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.