{"thread":{"id":"52403","subject":"[PATCH] patch-id: use oid_to_hex() to print multiple object IDs","startedAt":"2019-12-07T19:17:09Z","lastAt":"2019-12-09T02:06:32Z","messageCount":2,"participants":["René Scharfe","brian m. carlson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"387696","messageId":"bebcac17-f560-bb73-9aee-72f944df7d95@web.de","threadId":"52403","inReplyTo":null,"subject":"[PATCH] patch-id: use oid_to_hex() to print multiple object IDs","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2019-12-07T19:16:51Z","receivedAt":"2019-12-07T19:17:09Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"flush_current_id() prints the hexadecimal representation of two object\nIDs.  When the code was added in f97672225b (Add \"git-patch-id\" program\nto generate patch ID's., 2005-06-23), sha1_to_hex() had only a single\ninternal static buffer, so the result of one invocation had to be stored\nin a local buffer.\n\nSince dcb3450fd8 (sha1_to_hex() usage cleanup, 2006-05-03) it rotates\nthrough four buffers, which allows to print up to four object IDs at the\nsame time.  1a876a69af6 (patch-id: convert to use struct object_id,\n2015-03-13) replaced sha1_to_hex() with oid_to_hex(), which has the same\nfeature.  Use it to simplify the code.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n builtin/patch-id.c | 9 ++-------\n 1 file changed, 2 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/patch-id.c b/builtin/patch-id.c\nindex 3059e525b8..822ffff51f 100644\n--- a/builtin/patch-id.c\n+++ b/builtin/patch-id.c\n@@ -5,13 +5,8 @@\n\n static void flush_current_id(int patchlen, struct object_id *id, struct object_id *result)\n {\n-\tchar name[GIT_MAX_HEXSZ + 1];\n-\n-\tif (!patchlen)\n-\t\treturn;\n-\n-\tmemcpy(name, oid_to_hex(id), the_hash_algo->hexsz + 1);\n-\tprintf(\"%s %s\\n\", oid_to_hex(result), name);\n+\tif (patchlen)\n+\t\tprintf(\"%s %s\\n\", oid_to_hex(result), oid_to_hex(id));\n }\n\n static int remove_space(char *line)\n--\n2.24.0\n"},{"id":"387725","messageId":"20191209020617.GB1334263@camp.crustytoothpaste.net","threadId":"52403","inReplyTo":"bebcac17-f560-bb73-9aee-72f944df7d95@web.de","subject":"Re: [PATCH] patch-id: use oid_to_hex() to print multiple object IDs","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-12-09T02:06:17Z","receivedAt":"2019-12-09T02:06:32Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2019-12-07 at 19:16:51, René Scharfe wrote:\n> diff --git a/builtin/patch-id.c b/builtin/patch-id.c\n> index 3059e525b8..822ffff51f 100644\n> --- a/builtin/patch-id.c\n> +++ b/builtin/patch-id.c\n> @@ -5,13 +5,8 @@\n> \n>  static void flush_current_id(int patchlen, struct object_id *id, struct object_id *result)\n>  {\n> -\tchar name[GIT_MAX_HEXSZ + 1];\n> -\n> -\tif (!patchlen)\n> -\t\treturn;\n> -\n> -\tmemcpy(name, oid_to_hex(id), the_hash_algo->hexsz + 1);\n> -\tprintf(\"%s %s\\n\", oid_to_hex(result), name);\n> +\tif (patchlen)\n> +\t\tprintf(\"%s %s\\n\", oid_to_hex(result), oid_to_hex(id));\n>  }\n> \n>  static int remove_space(char *line)\n\nThis seems like a nice cleanup to me.  Thanks for sending the patch.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"}]}