From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28344 invoked by alias); 24 Jan 2018 20:53:43 -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: List-Unsubscribe: X-Seq: 42324 Received: (qmail 5251 invoked by uid 1010); 24 Jan 2018 20:53:43 -0000 X-Qmail-Scanner-Diagnostics: from hahler.de by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(188.40.33.212):SA:0(-1.9/5.0):. Processed in 8.183938 secs); 24 Jan 2018 20:53:43 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_PASS,T_DKIM_INVALID,T_RP_MATCHES_RCVD autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: daniel@hahler.de X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=thequod.de; h= x-mailer:message-id:date:date:subject:subject:from:from:received :received:received; s=postfix2; t=1516826590; bh=sM9IwIDyQ1EQC4j hkfUdwJVZBTDfNi4N2T2Weilq+eU=; b=edhKmBX7217K/QTIsRlKq5SzKyuw6HC CIEe3j4LGrsdX60Pig0oroZk1AwvhSqM+LFj6T+/WyDbpnmRp3DYrK+w12yrsUVh PH2rgy2keHWj83836aJTA8cMmDEN1HDr1CyVSLOFobicSbd7DqOCmp2IChK1paS9 GQlke0D6v4NM= From: Daniel Hahler To: zsh-workers@zsh.org Subject: [PATCH] Completion/Unix/Command/_git: handle mutually exclusive options Date: Wed, 24 Jan 2018 21:43:08 +0100 Message-Id: <20180124204308.25481-1-genml+zsh-workers@thequod.de> X-Mailer: git-send-email 2.16.1 From: Daniel Hahler Currently `git show --stat -p` is not considered a valid completion and prevents further completions like `--no-abbrev`. It is a valid use case however to use `--stat` with `-p` (and there is a synonym `--patch-with-stat` for it even). This patch changes `__git_setup_diff_options` to only handle mutually exclusive arguments reported by Git in a special way. --- Completion/Unix/Command/_git | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 30ca80835..2d6f3e292 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -7028,14 +7028,15 @@ __git_setup_log_options () { (( $+functions[__git_setup_diff_options] )) || __git_setup_diff_options () { - local diff_types='(-p -u --patch -U --unified --raw --patch-with-raw --stat --numstat --shortstat --dirstat --dirstat-by-file --summary --patch-with-stat --name-only --name-status --cumulative -s --no-patch)' + # According to Git: "fatal: --name-only, --name-status, --check and -s are mutually exclusive" + local exclusive_diff_options='(--name-only --name-status --check -s --no-patch)' diff_options=( - $diff_types{-p,-u,--patch}'[generate diff in patch format]' - $diff_types{-U,--unified=}'[generate diff with given lines of context]: :__git_guard_number lines' - $diff_types'--raw[generate default raw diff output]' - $diff_types'--patch-with-raw[generate patch but also keep the default raw diff output]' - $diff_types{-s,--no-patch}'[suppress diff output]' + {-p,-u,--patch}'[generate diff in patch format]' + {-U,--unified=}'[generate diff with given lines of context]: :__git_guard_number lines' + '--raw[generate default raw diff output]' + '--patch-with-raw[generate patch but also keep the default raw diff output]' + $exclusive_diff_options{-s,--no-patch}'[suppress diff output]' '(--minimal --patience --histogram --diff-algorithm)--minimal[spend extra time to make sure the smallest possible diff is produced]' '(--minimal --patience --histogram --diff-algorithm)--patience[generate diffs with patience algorithm]' '(--minimal --patience --histogram --diff-algorithm)--histogram[generate diffs with histogram algorithm]' @@ -7044,16 +7045,16 @@ __git_setup_diff_options () { minimal\:"spend extra time to make sure the smallest possible diff is produced" patience\:"generate diffs with patience algorithm" histogram\:"generate diffs with histogram algorithm"))' - $diff_types'--stat=-[generate diffstat instead of patch]:: :__git_guard_diff-stat-width' - $diff_types'--numstat[generate more machine-friendly diffstat]' - $diff_types'--shortstat[generate summary diffstat]' - $diff_types'--dirstat=-[generate dirstat by amount of changes]:: :__git_guard_number limit' - $diff_types'--dirstat-by-file=-[generate dirstat by number of files]:: :__git_guard_number limit' - $diff_types'--summary[generate condensed summary of extended header information]' - $diff_types'--patch-with-stat[generate patch and prepend its diffstat]' + '--stat=-[generate diffstat instead of patch]:: :__git_guard_diff-stat-width' + '--numstat[generate more machine-friendly diffstat]' + '--shortstat[generate summary diffstat]' + '--dirstat=-[generate dirstat by amount of changes]:: :__git_guard_number limit' + '--dirstat-by-file=-[generate dirstat by number of files]:: :__git_guard_number limit' + '--summary[generate condensed summary of extended header information]' + '--patch-with-stat[generate patch and prepend its diffstat]' '-z[use NUL termination on output]' - $diff_types'--name-only[show only names of changed files]' - $diff_types'--name-status[show only names and status of changed files]' + $exclusive_diff_options'--name-only[show only names of changed files]' + $exclusive_diff_options'--name-status[show only names and status of changed files]' '--submodule=-[select output format for submodule differences]::format:((short\:"show pairs of commit names" log\:"list commits like git submodule does" diff\:"show differences"))' @@ -7066,7 +7067,7 @@ __git_setup_diff_options () { '--word-diff-regex=-[specify what constitutes a word]:word regex' '(--color --no-color )--color-words=-[show colored-word diff]::word regex' '--no-renames[turn off rename detection]' - '--check[warn if changes introduce trailing whitespace or space/tab indents]' + $exclusive_diff_options'--check[warn if changes introduce trailing whitespace or space/tab indents]' '--full-index[show full object name of pre- and post-image blob]' '(--full-index)--binary[in addition to --full-index, output binary diffs for git-apply]' '--abbrev=[set minimum SHA1 display-length]: :__git_guard_number length' -- 2.16.1