Re: [PATCH 2/2] status: improve rebase todo list parsing
- From
Tian Yuchen <cat@malon.dev>
- Date
- Apr 20, 2026, 16:38 UTC
- Message-ID
- <b62a96c5-fab4-4c6d-9768-ade48a8476ca@malon.dev>
- In-Reply-To
- <d20dc1f6550078883995ae963b91faaa00984c6e.1776697483.git.phillip.wood@dunelm.org.uk>
Hi Phillip,
On 4/20/26 23:04, Phillip Wood wrote:
Show 5 quoted lines
> + if (!starts_with(p, abbrev)) > + goto out; /* object name was a refname containing only xdigits */ > + p += strlen(abbrev); > + strbuf_remove(line, p - line->buf, end_of_object_name - p); > + end_of_object_name = p;
Show 7 quoted lines
> - if ((2 <= string_list_split(&split, line->buf, " ", 2)) &&
> - !repo_get_oid(r, split.items[1].string, &oid)) {
> - strbuf_reset(line);
> - strbuf_addf(line, "%s ", split.items[0].string);
> - strbuf_add_unique_abbrev(line, &oid, DEFAULT_ABBREV);
> - for (size_t i = 2; i < split.nr; i++)
> - strbuf_addf(line, " %s", split.items[i].string);I noticed that after this patch, refnames shorter than seven characters are no longer standardised to the standard seven-character length, because the 'start_with()' function always returns FALSE. The code jumps directly to 'out', without completing or cutting the refname.
I’m not sure if this was your intention, but I just want to point it out for your information.
(Also noted that there is a very rare scenario where the OID of a refname longer than 7 characters happens to begin with the refname itself; in this case, 'start_with' returns TRUE and the string is cut incorrectly. However, I think we can safely ignore this.)
Regards, Yuchen