X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=diff.c;h=fa3b29d92e39cd35b30c1572acd06e2ba2708edd;hb=3f142468997f9d14d8051a96b2e9db265d41ac0d;hp=340d878f02b0daa3b26cf5eb3bf71bdda1437ce2;hpb=71d35bdb3613b753dbd5b83992e298531f701b6b;p=git.git diff --git a/diff.c b/diff.c index 340d878f0..fa3b29d92 100644 --- a/diff.c +++ b/diff.c @@ -1771,8 +1771,14 @@ static void emit_binary_diff(FILE *file, mmfile_t *one, mmfile_t *two, char *pre static void diff_filespec_load_driver(struct diff_filespec *one) { - if (!one->driver) + /* Use already-loaded driver */ + if (one->driver) + return; + + if (S_ISREG(one->mode)) one->driver = userdiff_find_by_path(one->path); + + /* Fallback to default settings */ if (!one->driver) one->driver = userdiff_find_by_name("default"); } @@ -1820,8 +1826,7 @@ struct userdiff_driver *get_textconv(struct diff_filespec *one) { if (!DIFF_FILE_VALID(one)) return NULL; - if (!S_ISREG(one->mode)) - return NULL; + diff_filespec_load_driver(one); if (!one->driver->textconv) return NULL; @@ -2153,7 +2158,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b, ecbdata.ws_rule = data.ws_rule; check_blank_at_eof(&mf1, &mf2, &ecbdata); - blank_at_eof = ecbdata.blank_at_eof_in_preimage; + blank_at_eof = ecbdata.blank_at_eof_in_postimage; if (blank_at_eof) { static char *err; @@ -2386,10 +2391,14 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only) } else { enum object_type type; - if (size_only) + if (size_only) { type = sha1_object_info(s->sha1, &s->size); - else { + if (type < 0) + die("unable to read %s", sha1_to_hex(s->sha1)); + } else { s->data = read_sha1_file(s->sha1, &type, &s->size); + if (!s->data) + die("unable to read %s", sha1_to_hex(s->sha1)); s->should_free = 1; } } @@ -3865,7 +3874,7 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1) xpp.flags = 0; xecfg.ctxlen = 3; - xecfg.flags = XDL_EMIT_FUNCNAMES; + xecfg.flags = 0; xdi_diff_outf(&mf1, &mf2, patch_id_consume, &data, &xpp, &xecfg); } @@ -4379,7 +4388,7 @@ size_t fill_textconv(struct userdiff_driver *driver, return df->size; } - if (driver->textconv_cache) { + if (driver->textconv_cache && df->sha1_valid) { *outbuf = notes_cache_get(driver->textconv_cache, df->sha1, &size); if (*outbuf) @@ -4390,7 +4399,7 @@ size_t fill_textconv(struct userdiff_driver *driver, if (!*outbuf) die("unable to read files to diff"); - if (driver->textconv_cache) { + if (driver->textconv_cache && df->sha1_valid) { /* ignore errors, as we might be in a readonly repository */ notes_cache_put(driver->textconv_cache, df->sha1, *outbuf, size);