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

Re: [PATCH 2/5] parse_branchname_arg(): introduce expect_commit_only

From
AMAlexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Date
Dec 19, 2019, 18:03 UTC
Message-ID
<713f8aea-cdd6-3fcd-8e9f-c9b909454ef5@syntevo.com>
In-Reply-To
<xmqqfthhe92v.fsf@gitster-ct.c.googlers.com>
On 18.12.2019 20:18, Junio C Hamano wrote:
Show 6 quoted lines
>> `has_dash_dash` unexpectedly takes `opts->accept_pathspec` into account.
> 
> You also touched the code that depends on opts->accept_pathspec in
> the earlier step 1/5; these two steps seem harder to reason about
> than necessary---I wonder if it is easier to explain and understand
> if these two steps are merged into one and explained together?

Yes, that sounds like a good idea! In V3 in other topic [1] I have shuffled the changes between commits for easier understanding.

>> +	if (has_dash_dash)
>> +	    expect_commit_only = 1;
> 
> Non-standard indentation here.
Sorry!
Show 10 quoted lines
>> +	opts->count_checkout_paths = !opts->quiet && !expect_commit_only;
> 
> OK.  count_checkout_paths is relevant only when checking out paths
> out of a tree-ish, so "expect-commit-only" would be false in such a
> situation.  On the other hand, if we were checking out a branch (or
> detaching), we must have a commit and a tree-ish is insufficient,
> so expect_commit_only would be true in such a case.
> 
> Makes sense.  I am wondering if we still need has_dash_dash, and
> also if expect_commit_only is the best name for the variable.

It seems that indeed, the variable could use an even better name. It's <commit> as opposed to <pathspec>, and not as opposed to <tree-ish>. I have renamed the variable again in V3 in other topic [1].

---- [1] https://lore.kernel.org/git/pull.490.v3.git.1576778515.gitgitgadget@gmail.com/

Previous: Junio C HamanoNext: Alexandr Miloslavskiy via GitGitGadget
Message 7 of 10 in “parse_branchname_arg(): make code easier to understand”
  1. 0/5 parse_branchname_arg(): make code easier to understandAlexandr Miloslavskiy via GitGitGadget, Nov 28, 2019
  2. 1/5 parse_branchname_arg(): fix dash_dash_pos, drop argcountAlexandr Miloslavskiy via GitGitGadget, Nov 28, 2019
  3. Junio C HamanoDec 18, 2019
  4. Alexandr MiloslavskiyDec 19, 2019
  5. 2/5 parse_branchname_arg(): introduce expect_commit_onlyAlexandr Miloslavskiy via GitGitGadget, Nov 28, 2019
  6. Junio C HamanoDec 18, 2019
  7. Alexandr MiloslavskiyDec 19, 2019
  8. 5/5 t2024: cover more casesAlexandr Miloslavskiy via GitGitGadget, Nov 28, 2019
  9. 4/5 parse_branchname_arg(): refactor the decision makingAlexandr Miloslavskiy via GitGitGadget, Nov 28, 2019
  10. 3/5 parse_branchname_arg(): update code commentsAlexandr Miloslavskiy via GitGitGadget, Nov 28, 2019

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.