Skip to content

fix const issues in revision parser

Jeff King git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4revision: make handle_dotdot() interface less confusingrevision.c+19 -233 replies
2/4rev-parse: simplify dotdot parsingbuiltin/rev-parse.c+7 -80 replies
3/4revision: avoid writing to const string for parent marksrevision.c+15 -100 replies
4/4rev-parse: avoid writing to const string for parent marksbuiltin/rev-parse.c+13 -120 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/4] fix const issues in revision parser
Quoted 9 lines · Jeff King

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