Git development
 help / color / mirror / Atom feed
From: "Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com>
To: "Phillip Wood" <phillip.wood123@gmail.com>
Cc: "D. Ben Knoble" <ben.knoble@gmail.com>,
	git@vger.kernel.org, "Phillip Wood" <phillip.wood@dunelm.org.uk>
Subject: Re: [PATCH v3 3/5] name-rev: factor code for sharing with a new command
Date: Tue, 05 May 2026 21:21:11 +0200	[thread overview]
Message-ID: <a0712ecf-5daf-4932-acde-1a4983d2d56c@app.fastmail.com> (raw)
In-Reply-To: <65e013cd-5bca-4340-8018-bcbb44371e4f@gmail.com>

On Sat, May 2, 2026, at 12:00, Phillip Wood wrote:
>>>[snip]
>>
>> Yeah, I didn’t want to repeat that bookkeeping but in some iteration it
>> looked necessary. But it’s good that it isn’t.
>
> It looks like the printing code is shared between the two case blocks in
> patch 5 as well so we should move that outside them as well and just set
> "name" inside the switch statement.

They’re not shared. Both commands work the same: either the object name
is consumed and replaced or it is written out as-is, in other words when
commit lookup fails. But somehow the name-rev path prints that *failure
to look up* case before continuing here (I don’t know how):

    if (!name)
        continue;

Because the printf(3) only prints when a symbolic name was found. Either
name-only:

    <symbolic name>

Or not name-only:

    <object name> (<symbolic name>)

On the other hand format-rev uses those two print statements to output
either the name lookup case or the lookup failure case.

>>>[snip]
>>
>> They looked the same to me. So I will need to think about this some
>> more. Just a lack of C experience on my part.
>>
>> Replacing the `continue` with a goto at the start of the loop was also
>> unnecessary. Of course the `continue` breaks out of the loop and not the
>> switch-block (unlike `break`).
>>
>> But I didn’t break `t6120-describe.sh`. So I’ll also take a look to see
>> if there are any holes.
>
> I think the difference only matters in pathological cases as "goto
> start" means we end up looking at the same character twice but the loop
> carries on as normal after that. We should just keep using "continue",
> I'm not sure we need a new test case.

Yeah, I have gone back to the sensible `continue`. Thanks.

(To be honest I tried to provoke a parsing bug here but I was unable
to. Somewhat annoying.)

  reply	other threads:[~2026-05-05 19:21 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-13 16:03 [PATCH 0/2] name-rev: learn --format=<pretty> kristofferhaugsbakk
2026-03-13 16:03 ` [PATCH 1/2] name-rev: wrap both blocks in braces kristofferhaugsbakk
2026-03-14  0:22   ` Junio C Hamano
2026-03-17 22:10     ` Kristoffer Haugsbakk
2026-03-13 16:03 ` [PATCH 2/2] name-rev: learn --format=<pretty> kristofferhaugsbakk
2026-03-14  0:22   ` Junio C Hamano
2026-03-17 22:07     ` Kristoffer Haugsbakk
2026-03-18 15:36       ` Kristoffer Haugsbakk
2026-03-20 13:09 ` [PATCH v2 0/2] " kristofferhaugsbakk
2026-03-20 13:09   ` [PATCH v2 1/2] name-rev: wrap both blocks in braces kristofferhaugsbakk
2026-03-20 13:09   ` [PATCH v2 2/2] name-rev: learn --format=<pretty> kristofferhaugsbakk
2026-03-20 15:25     ` D. Ben Knoble
2026-03-23 17:34       ` Kristoffer Haugsbakk
2026-04-28 22:25   ` [PATCH v3 0/5] format-rev: introduce builtin for on-demand pretty formatting kristofferhaugsbakk
2026-04-28 22:25     ` [PATCH v3 1/5] name-rev: wrap both blocks in braces kristofferhaugsbakk
2026-04-28 22:25     ` [PATCH v3 2/5] name-rev: run clang-format before factoring code kristofferhaugsbakk
2026-04-28 22:25     ` [PATCH v3 3/5] name-rev: factor code for sharing with a new command kristofferhaugsbakk
2026-04-30 13:54       ` Phillip Wood
2026-05-01 17:24         ` kristofferhaugsbakk
2026-05-02 10:00           ` Phillip Wood
2026-05-05 19:21             ` Kristoffer Haugsbakk [this message]
2026-04-28 22:25     ` [PATCH v3 4/5] name-rev: make dedicated --annotate-stdin --name-only test kristofferhaugsbakk
2026-04-28 22:25     ` [PATCH v3 5/5] format-rev: introduce builtin for on-demand pretty formatting kristofferhaugsbakk
2026-04-29 13:41       ` Kristoffer Haugsbakk
2026-04-30  6:23         ` Kristoffer Haugsbakk
2026-04-30  9:21       ` Kristoffer Haugsbakk
2026-05-01 10:16       ` Phillip Wood
2026-05-01 18:27         ` kristofferhaugsbakk
2026-05-02 10:00           ` Phillip Wood
2026-05-05 19:27             ` Kristoffer Haugsbakk
2026-05-03 19:19       ` Junio C Hamano
2026-05-07 19:34     ` [PATCH v4 0/5] " kristofferhaugsbakk
2026-05-07 19:34       ` [PATCH v4 1/5] name-rev: wrap both blocks in braces kristofferhaugsbakk
2026-05-07 19:34       ` [PATCH v4 2/5] name-rev: run clang-format before factoring code kristofferhaugsbakk
2026-05-07 19:34       ` [PATCH v4 3/5] name-rev: factor code for sharing with a new command kristofferhaugsbakk
2026-05-07 19:34       ` [PATCH v4 4/5] name-rev: make dedicated --annotate-stdin --name-only test kristofferhaugsbakk
2026-05-07 19:34       ` [PATCH v4 5/5] format-rev: introduce builtin for on-demand pretty formatting kristofferhaugsbakk
2026-05-08 13:25         ` Kristoffer Haugsbakk
2026-05-11 13:25         ` Kristoffer Haugsbakk
2026-05-11 15:45       ` [PATCH v5 0/5] " kristofferhaugsbakk
2026-05-11 15:45         ` [PATCH v5 1/5] name-rev: wrap both blocks in braces kristofferhaugsbakk
2026-05-11 15:45         ` [PATCH v5 2/5] name-rev: run clang-format before factoring code kristofferhaugsbakk
2026-05-11 15:45         ` [PATCH v5 3/5] name-rev: factor code for sharing with a new command kristofferhaugsbakk
2026-05-11 15:45         ` [PATCH v5 4/5] name-rev: make dedicated --annotate-stdin --name-only test kristofferhaugsbakk
2026-05-11 15:45         ` [PATCH v5 5/5] format-rev: introduce builtin for on-demand pretty formatting kristofferhaugsbakk

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=a0712ecf-5daf-4932-acde-1a4983d2d56c@app.fastmail.com \
    --to=kristofferhaugsbakk@fastmail.com \
    --cc=ben.knoble@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=phillip.wood123@gmail.com \
    --cc=phillip.wood@dunelm.org.uk \
    /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