git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Cantrell <david@cantrell.org.uk>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] tab completion of filenames for 'git restore'
Date: Mon, 14 Mar 2022 23:45:33 +0000	[thread overview]
Message-ID: <2ae04989-156c-63a2-c191-67f97bb6c7b9@cantrell.org.uk> (raw)
In-Reply-To: <xmqqlexel59r.fsf@gitster.g>

On 13/03/2022 06:45, Junio C Hamano wrote:
> "David Cantrell via GitGitGadget" <gitgitgadget@gmail.com> writes:
>>      Improved bash tab completion for 'git restore' - adds support for
>>      auto-completing filenames
>>      
>>      This adds tab-completion of filenames to the bash completions for git
>>      restore.
> Two questions
> 
>   - "restore" is a castrated half "checkout"; shouldn't the latter
>     also be getting the same feature?

`git checkout <tab>` already completes to a list of branches and tags, 
which is I think more useful in that case.

>   - is "complete_index_file --committable" the right thing to use?
> 
>     It boils down to running "diff-index HEAD", which means path with
>     differences from the HEAD commit is listed.  By default "restore"
>     checks out the contents of the given path from the index to the
>     working tree, so after "edit F && git add F", "diff-index HEAD"
>     may show F in its output (i.e. F is "committable"), but "restore
>     F" would be a no-op.  Which feels a bit iffy.

I'd not thought of that. --modified is better.

>> @@ -2883,14 +2883,21 @@ _git_restore ()
>>   	case "$cur" in
>>   	--conflict=*)
>>   		__gitcomp "diff3 merge zdiff3" "" "${cur##--conflict=}"
>> +		return
>>   		;;
>>   	--source=*)
>>   		__git_complete_refs --cur="${cur##--source=}"
>> +		return
>>   		;;
>> ...
> Do you need to sprinkle return's?  Instead you could just add
> another case arm, like
> 
> +	*)
> +		... whatever you want to do when
> +		... $cur is not a --dashed-option
> +		;;

Liberal sprinkling of return like that seems to be the norm for the rest 
of the file so I stuck with it.

-- 
David Cantrell

  reply	other threads:[~2022-03-15  0:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-11 21:07 [PATCH] tab completion of filenames for 'git restore' David Cantrell via GitGitGadget
2022-03-13  6:45 ` Junio C Hamano
2022-03-14 23:45   ` David Cantrell [this message]
2022-03-15 10:23     ` Junio C Hamano
2022-03-15  0:52 ` [PATCH v2 0/2] Improved bash tab completion for 'git restore' - adds support for auto-completing filenames David Cantrell via GitGitGadget
2022-03-15  0:52   ` [PATCH v2 1/2] tab completion of filenames for 'git restore' David Cantrell via GitGitGadget
2022-03-15  0:52   ` [PATCH v2 2/2] if a file has been staged we don't want to list it David Cantrell via GitGitGadget
2022-03-16 11:45     ` Bagas Sanjaya
2022-03-15 11:23   ` [PATCH v2 0/2] Improved bash tab completion for 'git restore' - adds support for auto-completing filenames Junio C Hamano
2022-03-15 16:27     ` Junio C Hamano
2022-03-15 22:13   ` [PATCH v3] tab completion of filenames for 'git restore' David Cantrell via GitGitGadget
2022-03-16  0:44     ` Junio C Hamano
2022-03-17 22:16       ` David Cantrell

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=2ae04989-156c-63a2-c191-67f97bb6c7b9@cantrell.org.uk \
    --to=david@cantrell.org.uk \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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.
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).