diff: clarify textconv interface
The memory allocation scheme for the textconv interface is a bit tricky, and not well documented. It was originally designed as an internal part of diff.c (matching fill_mmfile), but gradually was made public. Refactoring it is difficult, but we can at least improve the situation by documenting the intended flow and enforcing it with an in-code assertion. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
a2558fb8e1
commit
a64e6a44c6
5
diff.c
5
diff.c
@ -4996,7 +4996,7 @@ size_t fill_textconv(struct userdiff_driver *driver,
|
||||
{
|
||||
size_t size;
|
||||
|
||||
if (!driver || !driver->textconv) {
|
||||
if (!driver) {
|
||||
if (!DIFF_FILE_VALID(df)) {
|
||||
*outbuf = "";
|
||||
return 0;
|
||||
@ -5007,6 +5007,9 @@ size_t fill_textconv(struct userdiff_driver *driver,
|
||||
return df->size;
|
||||
}
|
||||
|
||||
if (!driver->textconv)
|
||||
die("BUG: fill_textconv called with non-textconv driver");
|
||||
|
||||
if (driver->textconv_cache && df->sha1_valid) {
|
||||
*outbuf = notes_cache_get(driver->textconv_cache, df->sha1,
|
||||
&size);
|
||||
|
Reference in New Issue
Block a user