patch-id: call flush_current_id() only when needed
The caller passes a flag that is used to become no-op when calling flush_current_id(). Instead of calling something that becomes a no-op, teach the caller not to call it in the first place. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Jul 29, 2024 at 18:17 UTC
c92f3195adf61f248af5bc787def379b2db6f2e9
1 file changed
+4
-4
builtin/patch-id.c
+4
-4
@@ -6,10 +6,9 @@
6
#include "hex.h"
7
#include "parse-options.h"
8
9
-static void flush_current_id(int patchlen, struct object_id *id, struct object_id *result)
9
+static void flush_current_id(struct object_id *id, struct object_id *result)
10
{
11
- if (patchlen)
12
- printf("%s %s\n", oid_to_hex(result), oid_to_hex(id));
11
+ printf("%s %s\n", oid_to_hex(result), oid_to_hex(id));
12
}
13
14
static int remove_space(char *line)
@@ -181,7 +180,8 @@ static void generate_id_list(int stable, int verbatim)
180
oidclr(&oid);
181
while (!feof(stdin)) {
182
patchlen = get_one_patchid(&n, &result, &line_buf, stable, verbatim);
184
- flush_current_id(patchlen, &oid, &result);
183
+ if (patchlen)
184
+ flush_current_id(&oid, &result);
185
oidcpy(&oid, &n);
186
}
187
strbuf_release(&line_buf);