Diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Abbreviate the index ids into local buffers
Diffstat (limited to '')
-rw-r--r--source/ui-diff.c17
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("<br>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("<br>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)