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
Kkristofferhaugsbakk@fastmail.com <kristofferhaugsbakk@fastmail.com>
Date
May 1, 2026, 17:24 UTC
Message-ID
<20260501172450.25037-2-kristofferhaugsbakk@fastmail.com>
In-Reply-To
<8016697f-9eb7-4c75-be87-d9479186919c@gmail.com>
Hi Phillip. Thanks for taking a look.
On Thu, Apr 30, 2026, at 15:54, Phillip Wood wrote:
Show 18 quoted lines
>>[snip]
>> @@ -524,25 +543,32 @@ static void name_rev_line(char *p, struct name_ref_data *data)
>>   			const char *name = NULL;
>>   			char c = *(p + 1);
>>   			int p_len = p - p_start + 1;
>> +			struct object *o = NULL;
>> +			int oid_ret = 1;
>>
>>   			counter = 0;
>>
>>   			*(p + 1) = 0;
>> -			if (!repo_get_oid(the_repository, p - (hexsz - 1), &oid)) {
>> -				struct object *o =
>> -					lookup_object(the_repository, &oid);
>> +			oid_ret = repo_get_oid(the_repository, p - (hexsz - 1), &oid);
>
> It would be safer to restore *(p + 1) here rather that relying on each
> case block to do it.

Yeah, I didn’t want to repeat that bookkeeping but in some iteration it looked necessary. But it’s good that it isn’t.

Show 15 quoted lines
>
> 			*(p + 1) = c;
>> +
>> +			switch (cmd->type) {
>> +			case NAME_REV:
>> +				if (!oid_ret)
>> +					o = lookup_object(the_repository, &oid);
>>   				if (o)
>>   					name = get_rev_name(o, &buf);
>> +				*(p + 1) = c;
>> +				if (!name)
>> +					goto start;
>
> The pre-image uses "continue" which will increment p - why the change in
> behavior?

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.

Thanks again.
>[snip]
-- 
Happy May Day
Previous: Phillip WoodNext: Phillip Wood
Message 19 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.