Skip to content

Commit 4507ecc

Browse files
rscharfegitster
authored andcommitted
patch-id: use oid_to_hex() to print multiple object IDs
flush_current_id() prints the hexadecimal representation of two object IDs. When the code was added in f976722 (Add "git-patch-id" program to generate patch ID's., 2005-06-23), sha1_to_hex() had only a single internal static buffer, so the result of one invocation had to be stored in a local buffer. Since dcb3450 (sha1_to_hex() usage cleanup, 2006-05-03) it rotates through four buffers, which allows to print up to four object IDs at the same time. 1a876a6 (patch-id: convert to use struct object_id, 2015-03-13) replaced sha1_to_hex() with oid_to_hex(), which has the same feature. Use it to simplify the code. Signed-off-by: René Scharfe <[email protected]> Acked-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent da72936 commit 4507ecc

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

builtin/patch-id.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,8 @@
55

66
static void flush_current_id(int patchlen, struct object_id *id, struct object_id *result)
77
{
8-
char name[GIT_MAX_HEXSZ + 1];
9-
10-
if (!patchlen)
11-
return;
12-
13-
memcpy(name, oid_to_hex(id), the_hash_algo->hexsz + 1);
14-
printf("%s %s\n", oid_to_hex(result), name);
8+
if (patchlen)
9+
printf("%s %s\n", oid_to_hex(result), oid_to_hex(id));
1510
}
1611

1712
static int remove_space(char *line)

0 commit comments

Comments
 (0)