path: root/builtin/patch-id.c
diff options
authorRené Scharfe <>2019-12-07 19:16:51 (GMT)
committerJunio C Hamano <>2019-12-09 20:26:40 (GMT)
commit4507ecc7710e172ed36421eaa4efe743785ccb4b (patch)
treeee566f2a213cb23c4f332a611422a26b19c86e72 /builtin/patch-id.c
parentda72936f544fec5a335e66432610e4cef4430991 (diff)
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 f97672225b (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 dcb3450fd8 (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. 1a876a69af6 (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 <> Acked-by: brian m. carlson <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin/patch-id.c')
1 files changed, 2 insertions, 7 deletions
diff --git a/builtin/patch-id.c b/builtin/patch-id.c
index 3059e52..822ffff 100644
--- a/builtin/patch-id.c
+++ b/builtin/patch-id.c
@@ -5,13 +5,8 @@
static void flush_current_id(int patchlen, struct object_id *id, struct object_id *result)
- char name[GIT_MAX_HEXSZ + 1];
- if (!patchlen)
- return;
- memcpy(name, oid_to_hex(id), the_hash_algo->hexsz + 1);
- printf("%s %s\n", oid_to_hex(result), name);
+ if (patchlen)
+ printf("%s %s\n", oid_to_hex(result), oid_to_hex(id));
static int remove_space(char *line)