From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"SZEDER Gábor" <szeder.dev@gmail.com>,
"Jay Soffian" <jaysoffian@gmail.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH] completion: expand "push --delete <remote> <ref>" for refs on that <remote>
Date: Tue, 18 Apr 2017 13:31:52 +0000 [thread overview]
Message-ID: <20170418133152.3262-1-avarab@gmail.com> (raw)
Change the completion of "push --delete <remote> <ref>" to complete
refs on that <remote>, not all refs. Before this e.g. cloning git.git
and doing "git push --delete origin p<TAB>" will complete nothing,
whereas origin/p<TAB> will uselessly complete origin/pu.
Now p<TAB> will complete as "pu". The completion of giving --delete
later, e.g. "git push origin --delete p<TAB>" remains unchanged, this
is a bug, but is a general existing limitation of the bash completion,
and not how git-push is documented, so I'm not fixing that case.
I looked over t9902-completion.sh but couldn't quickly find out how to
add a test for this, but all the existing tests pass, and all my
manual testing of "git push --delete <remote> ..." does the right
thing now.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
contrib/completion/git-completion.bash | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 1150164d5c..2e5b3ed776 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -701,7 +701,7 @@ __git_complete_revlist ()
__git_complete_remote_or_refspec ()
{
local cur_="$cur" cmd="${words[1]}"
- local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
+ local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0 delete=0
if [ "$cmd" = "remote" ]; then
((c++))
fi
@@ -709,6 +709,7 @@ __git_complete_remote_or_refspec ()
i="${words[c]}"
case "$i" in
--mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
+ --delete) delete=1 ;;
--all)
case "$cmd" in
push) no_complete_refspec=1 ;;
@@ -761,7 +762,9 @@ __git_complete_remote_or_refspec ()
fi
;;
push)
- if [ $lhs = 1 ]; then
+ if [ $delete = 1 ]; then
+ __git_complete_refs --remote="$remote" --pfx="$pfx" --cur="$cur_"
+ elif [ $lhs = 1 ]; then
__git_complete_refs --pfx="$pfx" --cur="$cur_"
else
__git_complete_refs --remote="$remote" --pfx="$pfx" --cur="$cur_"
--
2.11.0
next reply other threads:[~2017-04-18 13:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-18 13:31 Ævar Arnfjörð Bjarmason [this message]
2017-04-19 3:45 ` [PATCH] completion: expand "push --delete <remote> <ref>" for refs on that <remote> Junio C Hamano
2017-04-21 12:28 ` SZEDER Gábor
2017-04-22 17:55 ` [PATCH v2] " Ævar Arnfjörð Bjarmason
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170418133152.3262-1-avarab@gmail.com \
--to=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jaysoffian@gmail.com \
--cc=szeder.dev@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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).