diff options
| author | Junio C Hamano <gitster@pobox.com> | 2026-03-27 11:00:03 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-03-27 11:00:03 -0700 |
| commit | 7241be412367d60c69b1eb7eb979be5935bed646 (patch) | |
| tree | 30ceeab91b7842697456de1cb66366d0f854823c | |
| parent | 18396dc97d3e6b2f36772103b88c8855b703ea6b (diff) | |
| parent | f64c50e76827f39c843102bc603817648a38a48c (diff) | |
| download | git-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.c | 8 | ||||
| -rw-r--r-- | tools/coccinelle/strbuf.cocci | 7 |
2 files changed, 9 insertions, 6 deletions
@@ -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 |
