Skip to content

Commit 7241be4

Browse files
committed
Merge branch 'jc/rerere-modern-strbuf-handling'
Code clean-up overdue by 19 years. * jc/rerere-modern-strbuf-handling: cocci: strbuf.buf is never NULL rerere: update to modern representation of empty strbufs
2 parents 18396dc + f64c50e commit 7241be4

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

rerere.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,8 @@ static int handle_conflict(struct strbuf *out, struct rerere_io *io,
403403
strbuf_addbuf(out, &two);
404404
rerere_strbuf_putconflict(out, '>', marker_size);
405405
if (ctx) {
406-
git_hash_update(ctx, one.buf ?
407-
one.buf : "",
408-
one.len + 1);
409-
git_hash_update(ctx, two.buf ?
410-
two.buf : "",
411-
two.len + 1);
406+
git_hash_update(ctx, one.buf, one.len + 1);
407+
git_hash_update(ctx, two.buf, two.len + 1);
412408
}
413409
break;
414410
} else if (hunk == RR_SIDE_1)

tools/coccinelle/strbuf.cocci

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,10 @@ identifier fn, param;
7171
{
7272
...
7373
}
74+
75+
// In modern codebase, .buf member of an empty strbuf is not NULL.
76+
@@
77+
struct strbuf SB;
78+
@@
79+
- SB.buf ? SB.buf : ""
80+
+ SB.buf

0 commit comments

Comments
 (0)