Commit 753c810
committed
rerere: update to modern representation of empty strbufs
Back when b4833a2c (rerere: Fix use of an empty strbuf.buf,
2007-09-26) was written, a freshly initialized empty strbuf
had NULL in its .buf member, with .len set to 0. The code this
patch touches in rerere.c was written to _fix_ the original code
that assumed that the .buf member is always pointing at a NUL-terminated
string, even for an empty string, which did not hold back then.
That changed in b315c5c (strbuf change: be sure ->buf is never ever
NULL., 2007-09-27), and it has again become safe to assume that .buf
is never NULL, and .buf[0] has '\0' for an empty string (i.e., a
strbuf with its .len member set to 0).
A funny thing is, this piece of code has been moved around from
builtin-rerere.c to rerere.c and also adjusted for updates to the
hash function API over the years, but nobody bothered to question
if this special casing for an empty strbuf was still necessary:
b4833a2 (rerere: Fix use of an empty strbuf.buf, 2007-09-26)
5b2fd95 (rerere: Separate libgit and builtin functions, 2008-07-09)
9126f00 (fix openssl headers conflicting with custom SHA1 implementations, 2008-10-01)
c0f16f8 (rerere: factor out handle_conflict function, 2018-08-05)
0d7c419 (rerere: convert to use the_hash_algo, 2018-10-15)
0578f1e (global: adapt callers to use generic hash context helpers, 2025-01-31)
Finally get rid of the special casing that was unnecessary for the
last 19 years.
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent f368df4 commit 753c810
1 file changed
+2
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
| 405 | + | |
| 406 | + | |
411 | 407 | | |
412 | 408 | | |
413 | 409 | | |
| |||
0 commit comments