aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-03-27 11:00:03 -0700
committerJunio C Hamano <gitster@pobox.com>2026-03-27 11:00:03 -0700
commit7241be412367d60c69b1eb7eb979be5935bed646 (patch)
tree30ceeab91b7842697456de1cb66366d0f854823c
parent18396dc97d3e6b2f36772103b88c8855b703ea6b (diff)
parentf64c50e76827f39c843102bc603817648a38a48c (diff)
downloadgit-7241be412367d60c69b1eb7eb979be5935bed646.tar.xz
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
-rw-r--r--rerere.c8
-rw-r--r--tools/coccinelle/strbuf.cocci7
2 files changed, 9 insertions, 6 deletions
diff --git a/rerere.c b/rerere.c
index 6ec55964e2..0296700f9f 100644
--- a/rerere.c
+++ b/rerere.c
@@ -403,12 +403,8 @@ static int handle_conflict(struct strbuf *out, struct rerere_io *io,
strbuf_addbuf(out, &two);
rerere_strbuf_putconflict(out, '>', marker_size);
if (ctx) {
- git_hash_update(ctx, one.buf ?
- one.buf : "",
- one.len + 1);
- git_hash_update(ctx, two.buf ?
- two.buf : "",
- two.len + 1);
+ git_hash_update(ctx, one.buf, one.len + 1);
+ git_hash_update(ctx, two.buf, two.len + 1);
}
break;
} else if (hunk == RR_SIDE_1)
diff --git a/tools/coccinelle/strbuf.cocci b/tools/coccinelle/strbuf.cocci
index 83bd93be5f..f586128329 100644
--- a/tools/coccinelle/strbuf.cocci
+++ b/tools/coccinelle/strbuf.cocci
@@ -71,3 +71,10 @@ identifier fn, param;
{
...
}
+
+// In modern codebase, .buf member of an empty strbuf is not NULL.
+@@
+struct strbuf SB;
+@@
+- SB.buf ? SB.buf : ""
++ SB.buf