git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] checkout: learn to respect checkout.guess

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 6, 2020, 18:41 UTC
Message-ID
<xmqqtuv75ha8.fsf@gitster.c.googlers.com>
In-Reply-To
<20201006080730.GA2419589@generichostname>
Denton Liu <liu.denton@gmail.com> writes:
Show 22 quoted lines
> Hi Junio,
>
> On Sun, Oct 04, 2020 at 10:46:14AM -0700, Junio C Hamano wrote:
>> Denton Liu <liu.denton@gmail.com> writes:
>> 
>> > The current behavior of git checkout/switch is that --guess is currently
>> > enabled by default. However, some users may not wish for this to happen
>> > automatically. Instead of forcing users to specify --no-guess manually
>> > each time, teach these commands the checkout.guess configuration
>> > variable that gives users the option to set a default behavior.
>> >
>> > Teach the completion script to recognize the new config variable and
>> > disable DWIM logic if it is set to false.
>> >
>> > Signed-off-by: Denton Liu <liu.denton@gmail.com>
>> > ---
>> 
>> Asking for input from Dscho on how to futureproof the tests along
>> the same line as js/default-branch-name-part-2 topic.
>
> Perhaps we could extract lists that are repeated often into common files
> so that they only need to be changed in one place? Something like this:

or we can feed a prefix that is not 'm' so that master, main, or maint branches are not involved at all in the completion?

Show 28 quoted lines
>
> -- >8 --
> diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
> index 7b7bc6e4bd..86da44231d 100755
> --- a/t/t9902-completion.sh
> +++ b/t/t9902-completion.sh
> @@ -1240,8 +1240,8 @@ test_expect_success '__git_complete_fetch_refspecs - fully qualified & prefix' '
>  	test_cmp expected out
>  '
>  
> -test_expect_success 'git switch - with no options, complete local branches and unique remote branch names for DWIM logic' '
> -	test_completion "git switch " <<-\EOF
> +test_expect_success 'prepare expect files for DWIM tests' '
> +	cat >local-and-unique-remote <<-\EOF &&
>  	branch-in-other Z
>  	master Z
>  	master-in-other Z
> @@ -1249,6 +1249,10 @@ test_expect_success 'git switch - with no options, complete local branches and u
>  	EOF
>  '
>  
> +test_expect_success 'git switch - with no options, complete local branches and unique remote branch names for DWIM logic' '
> +	test_completion "git switch " <local-and-unique-remote
> +'
> +
>  test_expect_success 'git checkout - completes refs and unique remote branches for DWIM' '
>  	test_completion "git checkout " <<-\EOF
>  	HEAD Z
Previous: Denton LiuNext: Johannes Schindelin
Message 6 of 14 in “checkout: learn the checkout.guess config variable”
  1. 0/2 checkout: learn the checkout.guess config variableDenton Liu, Oct 4, 2020
  2. 1/2 Documentation/config/checkout: replace sq with backticksDenton Liu, Oct 4, 2020
  3. 2/2 checkout: learn to respect checkout.guessDenton Liu, Oct 4, 2020
  4. Junio C HamanoOct 4, 2020
  5. Denton LiuOct 6, 2020
  6. Junio C HamanoOct 6, 2020
  7. Johannes SchindelinOct 6, 2020
  8. 0/2 checkout: learn the checkout.guess config variableDenton Liu, Oct 7, 2020
  9. 1/2 Documentation/config/checkout: replace sq with backticksDenton Liu, Oct 7, 2020
  10. 2/2 checkout: learn to respect checkout.guessDenton Liu, Oct 7, 2020
  11. Junio C HamanoOct 7, 2020
  12. 0/2 checkout: learn the checkout.guess config variableDenton Liu, Oct 8, 2020
  13. 1/2 Documentation/config/checkout: replace sq with backticksDenton Liu, Oct 8, 2020
  14. 2/2 checkout: learn to respect checkout.guessDenton Liu, Oct 8, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.