From: Bart Schaefer <schaefer@brasslantern.com>
To: 한현빈 <ironman466@naver.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: [PATCH] Re: Git auto completion does not work for comparing 2 files from 2 different branches
Date: Fri, 30 Sep 2022 20:54:05 -0700 [thread overview]
Message-ID: <CAH+w=7YY9pHWfT6V5Q7RiRe=1jU1fx3JDPATJpS+FmAMRuHK-g@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7ZeXumotN=48bDWdrbfZT4qOufNNGts5+jAM6iO_wyvUQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 254 bytes --]
On Fri, Sep 30, 2022 at 5:54 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> Confirmed this is still the case in 5.9 -- git diff completion always
> assumes you're comparing a branch to the current checkout.
Any reason not to rearrange like so?
[-- Attachment #2: git-diff.txt --]
[-- Type: text/plain, Size: 1869 bytes --]
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index cecb80ac3..6a1c4158a 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -808,18 +808,6 @@ _git-diff () {
# Otherwise, more complex conditions need to be checked.
case $CURRENT in
- (1)
- local files_alt='files::__git_changed-in-working-tree_files'
- if [[ -n ${opt_args[(I)--cached|--staged]} ]]; then
- files_alt='files::__git_changed-in-index_files'
- fi
-
- _alternative \
- 'commit-ranges::__git_commit_ranges' \
- 'blobs-and-trees-in-treeish::__git_blobs_and_trees_in_treeish' \
- $files_alt \
- 'blobs::__git_blobs ' && ret=0
- ;;
(2)
# Check if first argument is something special. In case of committish ranges and committishs offer a full list compatible completions.
if __git_is_committish_range $line[1]; then
@@ -841,10 +829,19 @@ _git-diff () {
elif [[ -n ${opt_args[(I)--cached|--staged]} ]]; then
# Example: git diff --cached file1 <tab>
__git_changed-in-index_files && ret=0
- else
- # Example: git diff file1 <tab>
- __git_changed-in-working-tree_files && ret=0
fi
+ ;&
+ (1)
+ local files_alt='files::__git_changed-in-working-tree_files'
+ if [[ -n ${opt_args[(I)--cached|--staged]} ]]; then
+ files_alt='files::__git_changed-in-index_files'
+ fi
+
+ _alternative \
+ 'commit-ranges::__git_commit_ranges' \
+ 'blobs-and-trees-in-treeish::__git_blobs_and_trees_in_treeish' \
+ $files_alt \
+ 'blobs::__git_blobs ' && ret=0
;;
(*)
if __git_is_committish_range $line[1]; then
prev parent reply other threads:[~2022-10-01 3:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-30 3:44 한현빈
2022-10-01 0:54 ` Bart Schaefer
2022-10-01 3:54 ` Bart Schaefer [this message]
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='CAH+w=7YY9pHWfT6V5Q7RiRe=1jU1fx3JDPATJpS+FmAMRuHK-g@mail.gmail.com' \
--to=schaefer@brasslantern.com \
--cc=ironman466@naver.com \
--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).