Subject: [PATCH 0/4] fix const issues in revision parser

From: Jeff King <[email-masked]>
Date: Thu, 26 Mar 2026 15:02:43 -0400

On Thu, Mar 26, 2026 at 01:42:04PM -0400, Jeff King wrote:

> IMHO the right solution here is to teach the revision-parser not to
> touch the incoming buffers. We do it only to tie off strings, which can
> mostly be replaced with xmemdupz(). That's slightly less efficient, but
> I don't think it would be measurable (it's one allocation that tends to
> happen a handful of times per program execution, and the rest of the
> parsing is going to allocate things like commit structs anyway).
> 
> I have some patches in that direction, but I haven't gotten around to
> polishing them yet.

Here it is. There were a few oddities to untangle, but I think the
result makes the whole thing a bit easier to understand. I may be biased
as the author, though. ;)

  [1/4]: revision: make handle_dotdot() interface less confusing
  [2/4]: rev-parse: simplify dotdot parsing
  [3/4]: revision: avoid writing to const string for parent marks
  [4/4]: rev-parse: avoid writing to const string for parent marks

 builtin/rev-parse.c | 40 +++++++++++++--------------
 revision.c          | 67 +++++++++++++++++++++++----------------------
 2 files changed, 54 insertions(+), 53 deletions(-)

-Peff