From: Daniel Hahler <genml+zsh-workers@thequod.de>
To: zsh-workers@zsh.org
Subject: [PATCH 1/2] completion: git: split diff options for stages (--theirs, --ours etc)
Date: Fri, 8 May 2015 16:46:44 +0200 [thread overview]
Message-ID: <1431096405-16016-1-git-send-email-genml+zsh-workers@thequod.de> (raw)
In-Reply-To: <f9059726c9c756ffcaf3ec45b6c27c2e8999376b.1382290245.git.oystwa@gmail.com>
From: Daniel Hahler <git@thequod.de>
This adds __git_setup_diff_stage_options and uses it with
_git-diff-files and _git-diff explicitly, removing it from the common
diff options.
For example, 'git show' should not complete '--theirs'.
---
Completion/Unix/Command/_git | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 979e3e7..c9074ca 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -714,12 +714,14 @@ _git-diff () {
local curcontext=$curcontext state line ret=1
declare -A opt_args
- local -a diff_options
+ local -a diff_options diff_stage_options
__git_setup_diff_options
+ __git_setup_diff_stage_options
_arguments -w -C -s \
$* \
$diff_options \
+ $diff_stage_options \
'(--cached --staged)'{--cached,--staged}'[show diff between index and named commit]' \
'(-)--[start file arguments]' \
'*:: :->from-to-file' && ret=0
@@ -4341,11 +4343,13 @@ _git-cat-file () {
(( $+functions[_git-diff-files] )) ||
_git-diff-files () {
- declare -a revision_options
+ local -a revision_options diff_stage_options
__git_setup_revision_options
+ __git_setup_diff_stage_options
_arguments -w -S -s \
$revision_options \
+ $diff_stage_options \
': :__git_changed-in-working-tree_files' \
': :__git_changed-in-working-tree_files' \
'*: :__git_changed-in-working-tree_files'
@@ -6214,14 +6218,20 @@ __git_setup_diff_options () {
'(--no-prefix)--dst-prefix=[use given prefix for destination]:prefix'
'(--src-prefix --dst-prefix)--no-prefix[do not show any source or destination prefix]'
+ '(-c,--cc)'{-b,--cc}'[combined diff format for merge commits]'
+
+ # TODO: --output is undocumented.
+ '--output[undocumented]:undocumented')
+}
+
+(( $+functions[__git_setup_diff_stage_options] )) ||
+__git_setup_diff_stage_options () {
+ diff_stage_options=(
'(-0 -1 -2 -3 --base --ours --theirs -c --cc --no-index)'{-1,--base}'[diff against "base" version]'
'(-0 -1 -2 -3 --base --ours --theirs -c --cc --no-index)'{-2,--ours}'[diff against "our branch" version]'
'(-0 -1 -2 -3 --base --ours --theirs -c --cc --no-index)'{-3,--theirs}'[diff against "their branch" version]'
'(-0 -1 -2 -3 --base --ours --theirs -c --cc --no-index)-0[omit diff output for unmerged entries]'
- '(-0 -1 -2 -3 --base --ours --theirs -c --cc --no-index)'{-c,--cc}'[compare "our branch", "their branch" and working tree files]'
-
- # TODO: --output is undocumented.
- '--output[undocumented]:undocumented')
+ )
}
(( $+functions[__git_setup_revision_options] )) ||
--
2.4.0.dirty
next prev parent reply other threads:[~2015-05-08 14:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-20 17:40 [PATCH 0/7] Various fixes to Git completion Øystein Walle
2013-10-20 17:40 ` [PATCH 1/7] _git: Add missing column.* config variables Øystein Walle
2013-10-20 17:41 ` [PATCH 2/7] _git: Make git-show accept diff arguments Øystein Walle
2015-05-08 14:46 ` Daniel Hahler [this message]
2015-05-08 14:46 ` [PATCH 2/2] completion: git: do not add diff options twice Daniel Hahler
2015-05-16 22:55 ` [PATCH 1/2] completion: git: split diff options for stages (--theirs, --ours etc) Daniel Shahaf
2013-10-20 17:41 ` [PATCH 3/7] _git: re-order the last two git-blame arguments Øystein Walle
2013-10-20 17:41 ` [PATCH 4/7] _git: Remove unsupported -q option from diff options Øystein Walle
2013-10-20 17:41 ` [PATCH 5/7] _git: fix wrong default value Øystein Walle
2013-10-20 17:41 ` [PATCH 6/7] _git: fix a few "undocumented" options Øystein Walle
2013-10-20 17:41 ` [PATCH 7/7] _git: revert: add '-e,--edit' Øystein Walle
2013-10-21 10:28 ` [PATCH 0/7] Various fixes to Git completion Frank Terbeck
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=1431096405-16016-1-git-send-email-genml+zsh-workers@thequod.de \
--to=genml+zsh-workers@thequod.de \
--cc=zsh-workers@zsh.org \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).