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

Re: [PATCH v3 3/5] name-rev: factor code for sharing with a new command

From
KHKristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
Date
May 5, 2026, 19:21 UTC
Message-ID
<a0712ecf-5daf-4932-acde-1a4983d2d56c@app.fastmail.com>
In-Reply-To
<65e013cd-5bca-4340-8018-bcbb44371e4f@gmail.com>
On Sat, May 2, 2026, at 12:00, Phillip Wood wrote:
Show 8 quoted lines
>>>[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.

Show 16 quoted lines
>>>[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.)

Previous: Phillip WoodNext: kristofferhaugsbakk@fastmail.com
Message 21 of 45 in “name-rev: learn --format=<pretty>”
  1. 0/2 name-rev: learn --format=<pretty>kristofferhaugsbakk@fastmail.com, Mar 13, 2026
  2. 1/2 name-rev: wrap both blocks in braceskristofferhaugsbakk@fastmail.com, Mar 13, 2026
  3. Junio C HamanoMar 14, 2026
  4. Kristoffer HaugsbakkMar 17, 2026
  5. 2/2 name-rev: learn --format=<pretty>kristofferhaugsbakk@fastmail.com, Mar 13, 2026
  6. Junio C HamanoMar 14, 2026
  7. Kristoffer HaugsbakkMar 17, 2026
  8. Kristoffer HaugsbakkMar 18, 2026
  9. 0/2 name-rev: learn --format=<pretty>kristofferhaugsbakk@fastmail.com, Mar 20, 2026
  10. 1/2 name-rev: wrap both blocks in braceskristofferhaugsbakk@fastmail.com, Mar 20, 2026
  11. 2/2 name-rev: learn --format=<pretty>kristofferhaugsbakk@fastmail.com, Mar 20, 2026
  12. D. Ben KnobleMar 20, 2026
  13. Kristoffer HaugsbakkMar 23, 2026
  14. 0/5 format-rev: introduce builtin for on-demand pretty formattingkristofferhaugsbakk@fastmail.com, Apr 28, 2026
  15. 1/5 name-rev: wrap both blocks in braceskristofferhaugsbakk@fastmail.com, Apr 28, 2026
  16. 2/5 name-rev: run clang-format before factoring codekristofferhaugsbakk@fastmail.com, Apr 28, 2026
  17. 3/5 name-rev: factor code for sharing with a new commandkristofferhaugsbakk@fastmail.com, Apr 28, 2026
  18. Phillip WoodApr 30, 2026
  19. kristofferhaugsbakk@fastmail.comMay 1, 2026
  20. Phillip WoodMay 2, 2026
  21. Kristoffer HaugsbakkMay 5, 2026
  22. 4/5 name-rev: make dedicated --annotate-stdin --name-only testkristofferhaugsbakk@fastmail.com, Apr 28, 2026
  23. 5/5 format-rev: introduce builtin for on-demand pretty formattingkristofferhaugsbakk@fastmail.com, Apr 28, 2026
  24. Kristoffer HaugsbakkApr 29, 2026
  25. Kristoffer HaugsbakkApr 30, 2026
  26. Kristoffer HaugsbakkApr 30, 2026
  27. Phillip WoodMay 1, 2026
  28. kristofferhaugsbakk@fastmail.comMay 1, 2026
  29. Phillip WoodMay 2, 2026
  30. Kristoffer HaugsbakkMay 5, 2026
  31. Junio C HamanoMay 3, 2026
  32. 0/5 format-rev: introduce builtin for on-demand pretty formattingkristofferhaugsbakk@fastmail.com, May 7, 2026
  33. 1/5 name-rev: wrap both blocks in braceskristofferhaugsbakk@fastmail.com, May 7, 2026
  34. 2/5 name-rev: run clang-format before factoring codekristofferhaugsbakk@fastmail.com, May 7, 2026
  35. 3/5 name-rev: factor code for sharing with a new commandkristofferhaugsbakk@fastmail.com, May 7, 2026
  36. 4/5 name-rev: make dedicated --annotate-stdin --name-only testkristofferhaugsbakk@fastmail.com, May 7, 2026
  37. 5/5 format-rev: introduce builtin for on-demand pretty formattingkristofferhaugsbakk@fastmail.com, May 7, 2026
  38. Kristoffer HaugsbakkMay 8, 2026
  39. Kristoffer HaugsbakkMay 11, 2026
  40. 0/5 format-rev: introduce builtin for on-demand pretty formattingkristofferhaugsbakk@fastmail.com, May 11, 2026
  41. 1/5 name-rev: wrap both blocks in braceskristofferhaugsbakk@fastmail.com, May 11, 2026
  42. 2/5 name-rev: run clang-format before factoring codekristofferhaugsbakk@fastmail.com, May 11, 2026
  43. 3/5 name-rev: factor code for sharing with a new commandkristofferhaugsbakk@fastmail.com, May 11, 2026
  44. 4/5 name-rev: make dedicated --annotate-stdin --name-only testkristofferhaugsbakk@fastmail.com, May 11, 2026
  45. 5/5 format-rev: introduce builtin for on-demand pretty formattingkristofferhaugsbakk@fastmail.com, May 11, 2026

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.