summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2016-02-22 18:28:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-02-22 18:40:35 (GMT)
commita64e6a44c63a965c5bc26242ddd3ed049b42e117 (patch)
tree7bf3c3388e48bcbc548da65a688ba2425afc42f0 /diff.c
parenta2558fb8e1e387b630312311e1d22c95663da5d0 (diff)
downloadgit-a64e6a44c63a965c5bc26242ddd3ed049b42e117.zip
git-a64e6a44c63a965c5bc26242ddd3ed049b42e117.tar.gz
git-a64e6a44c63a965c5bc26242ddd3ed049b42e117.tar.bz2
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>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/diff.c b/diff.c
index f62b7f7..a09b0b6 100644
--- a/diff.c
+++ b/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);