From a5c5671bf2967fd104ef85eeda688a667b27c8d7 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 13:32:27 -0700 Subject: Abbreviate the index ids into local buffers --- source/ui-diff.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/source/ui-diff.c b/source/ui-diff.c index 91ad860..260aed2 100644 --- a/source/ui-diff.c +++ b/source/ui-diff.c @@ -211,19 +211,10 @@ static void print_line(char *line, int len) line[len - 1] = c; } -/* - * The buffer repo_find_unique_abbrev returns is reused, so a caller printing - * two abbreviated names together keeps a copy of each. - */ -static char *abbrev_oid(const struct object_id *oid) -{ - return xstrdup(repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV)); -} - static void print_file_header(const struct object_id *old_oid, const char *old_path, unsigned old_mode, const struct object_id *new_oid, const char *new_path, unsigned new_mode) { - char *old_abbrev, *new_abbrev; + char old_abbrev[GIT_MAX_HEXSZ + 1], new_abbrev[GIT_MAX_HEXSZ + 1]; int subproject; subproject = (S_ISGITLINK(old_mode) || S_ISGITLINK(new_mode)); @@ -247,11 +238,9 @@ static void print_file_header(const struct object_id *old_oid, const char *old_p htmlf("
deleted file mode %.6o", old_mode); if (!subproject) { - old_abbrev = abbrev_oid(old_oid); - new_abbrev = abbrev_oid(new_oid); + repo_find_unique_abbrev_r(the_repository, old_abbrev, old_oid, DEFAULT_ABBREV); + repo_find_unique_abbrev_r(the_repository, new_abbrev, new_oid, DEFAULT_ABBREV); htmlf("
index %s..%s", old_abbrev, new_abbrev); - free(old_abbrev); - free(new_abbrev); if (old_mode != 0 && new_mode != 0) { htmlf(" %.6o", old_mode); if (new_mode != old_mode) -- cgit