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

Re: [PATCH 1/5] parse_branchname_arg(): fix dash_dash_pos, drop argcount

From
AMAlexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Date
Dec 19, 2019, 18:03 UTC
Message-ID
<807d4e5c-89b9-298b-c022-08d330fbd3c9@syntevo.com>
In-Reply-To
<xmqqk16tea9u.fsf@gitster-ct.c.googlers.com>
Thanks for having a look at my patches!
On 18.12.2019 19:52, Junio C Hamano wrote:
Show 10 quoted lines
>> Simplify the code by dropping `argcount` and useless `argc` / `argv`
>> manipulations.
> 
> I am not sure if this is a good change, though.  It goes against the
> reasoning that makes the above "dash-dash-pos" change is a good one,
> doesn't it?  When the code changes over time, wouldn't it make the
> code more clear to keep track of the count of args it saw in a
> separate variable, than relying on the invariant that currently
> happens to hold which is "if dash-dash is after the first argument,
> return 2 and otherwise return 1"?

My bad that I forgot to write a detailed explanation for that. In V3 in other topic [2] I have separated this change as a separate commit with a good message.

Show 10 quoted lines
>> +	if (opts->accept_pathspec) {
>> +	    if (dash_dash_pos == 0)
>> +		    return 1; /* case (2) */
>> +	    else if (dash_dash_pos == 1)
>> +		    has_dash_dash = 1; /* case (3) or (1) */
>> +	    else if (dash_dash_pos >= 2)
>> +		    die(_("only one reference expected, %d given."), dash_dash_pos);
> 
> Non-standard indentation?  In our code, a level of indent is another
> horizontal tab.

Sorry, my Visual Studio was acting up again. It's doing pretty weird things when I have tab size 4 (due to other projects), which is overridden by git repo settings to 8.

Fixed it in V3 in other topic [2]

---- [1] Commit 09ebad6f ("checkout: split off a function to peel away branchname arg", 2011-02-08) [2] https://lore.kernel.org/git/pull.490.v3.git.1576778515.gitgitgadget@gmail.com/

Previous: Junio C HamanoNext: Alexandr Miloslavskiy via GitGitGadget
Message 4 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.