From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27624 invoked by alias); 30 Jun 2011 09:21:41 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 29527 Received: (qmail 29487 invoked from network); 30 Jun 2011 09:21:39 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at bewatermyfriend.org does not designate permitted sender hosts) From: Frank Terbeck To: zsh workers Cc: Nikolai Weibull , Mikael Magnusson , =?UTF-8?q?Johan=20Sundstr=C3=B6m?= Subject: PATCH: (5/3) _git: Make file-completion fallback optional Date: Thu, 30 Jun 2011 11:17:56 +0200 Message-Id: <1309425476-26763-1-git-send-email-ft@bewatermyfriend.org> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1309379833-31315-1-git-send-email-ft@bewatermyfriend.org> References: <1309379833-31315-1-git-send-email-ft@bewatermyfriend.org> X-Df-Sender: 430444 Jonas asserted that not everyone may like _git to fall back to file name completion for sub-commands it doesn't know. This makes that behaviour configurable. See the comment on top of _git for details. The default is to *use* the fallbacke, since I am convinced that is the least surprising way to do handle these situations. But if you really dislike the fallback, now you can have it your way. With an indicator as to *why* nothing is being completed even. --- Completion/Unix/Command/_git | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index a1856df..3fa1a73 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -17,6 +17,16 @@ # # You could even create a function _git-foo() to handle specific completion # for that command. +# +# When git does not know a given sub-command (say `bar'), it falls back to +# completing file names for all arguments to that sub command. I.e.: +# +# % git bar +# +# ...will complete file names. If you do *not* want that fallback to be used, +# use the `use-fallback' style like this: +# +# % zstyle ':completion:*:*:git*:*' use-fallback false # TODO: There is still undocumented configurability in here. @@ -6035,9 +6045,11 @@ _git() { if (( ${+functions[_git-$words[1]]} )); then _git-$words[1] - else + elif zstyle -T ":completion:${curcontext}:" use-fallback; then _path_files ret=$? + else + _message 'Unknown sub-command' fi ;; esac -- 1.7.6