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

Re: [PATCH v1] checkout: optionally speed up "git checkout -b foo"

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 26, 2018, 15:04 UTC
Message-ID
<xmqqeffqrqb3.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<960c32c0-5b10-6854-73c9-392814dddbb3@gmail.com>
Ben Peart <peartben@gmail.com> writes:

[jc: it was a bit surprising that Eric covered all the bits I covered while we were writing without peeking each other's ;-)]

Show 7 quoted lines
>> This long list of special-case checks doesn't leave me too enthused,
>> however, that aside, this approach seems backward. Rather than erring
>> on the side of safety by falling back to the merging behavior, it errs
>> in the other direction, ...
>
> I'm not thrilled with the long list either (the plethora of comments
> probably makes it appear worse than it is) but I don't see how...

If there were a simple and futureproof way to tell the option parsing loop to notice any feature other than "-b newbranch" was used, then such a whitelisting may be a viable way, but there is not, and the whitelist condition can become (over time---we are talking about futureproofing and not "a filter that happens to match today's feature set") just as complex as this blacklisting function is (e.g. feature A and feature B when used alone may be compatible with the optimization but not when used both), so if we were to use this optimization, I think this long list of special-case checks is the best we could do.

Show 7 quoted lines
>>      if (!skip_worktree_merge(...))
>>          ret = merge_working_tree(...);
>>
>
> I personally agree, it was moved to its current location per feedback
> the first time around.  Perhaps with the addition of the config
> setting it will be better received moved out to the caller.

Sounds sensible. I am still not enthused by the configuration variable that is underdocumented. You already said that we know that this optimization does a wrong thing when sparse checkout is used---any other cases? I do not think of any myself, and if that is true, I am wondering if it makes more sense to "do we have sparse configuration?" as part of the blacklist condition. That way, the users do not have to set anything and they will get an optimization benefit from an obvious change to skip "read-tree -m HEAD HEAD" that ought to be a no-op.

Thanks.
Previous: Ben PeartNext: Eric Sunshine
Message 4 of 32 in “checkout: optionally speed up "git checkout -b foo"”
  1. checkout: optionally speed up "git checkout -b foo"Ben Peart, Jul 24, 2018
  2. Eric SunshineJul 24, 2018
  3. Ben PeartJul 24, 2018
  4. Junio C HamanoJul 26, 2018
  5. Eric SunshineJul 26, 2018
  6. Eric SunshineJul 26, 2018
  7. Junio C HamanoJul 24, 2018
  8. Ben PeartJul 24, 2018
  9. checkout: optimize "git checkout -b <new_branch>"Ben Peart, Jul 31, 2018
  10. Junio C HamanoJul 31, 2018
  11. Duy NguyenAug 1, 2018
  12. Ben PeartAug 2, 2018
  13. Duy NguyenAug 3, 2018
  14. Ben PeartAug 6, 2018
  15. Ben PeartAug 15, 2018
  16. Duy NguyenAug 5, 2018
  17. checkout: optimize "git checkout -b <new_branch>"Ben Peart, Aug 16, 2018
  18. Duy NguyenAug 16, 2018
  19. Ben PeartAug 17, 2018
  20. Elijah NewrenAug 19, 2018
  21. Ben PeartAug 20, 2018
  22. Elijah NewrenAug 20, 2018
  23. Duy NguyenAug 21, 2018
  24. Elijah NewrenAug 30, 2018
  25. Duy NguyenSep 4, 2018
  26. Junio C HamanoAug 20, 2018
  27. config doc: add missing list separator for checkout.optimizeNewBranchÆvar Arnfjörð Bjarmason, Sep 18, 2018
  28. Taylor BlauSep 18, 2018
  29. Jeff KingSep 18, 2018
  30. Taylor BlauSep 18, 2018
  31. Jeff KingSep 18, 2018
  32. Ævar Arnfjörð BjarmasonSep 19, 2018

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.