X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=diff.c;h=b829c033534f0631dd1a40eb0e2e1097a6f10cf4;hb=a33fb40fe477fa1a9ce882230415f19378959390;hp=144f2aaba85682ef44d307d2b015fd918336879b;hpb=2acf3658a31249d1a09573e2b6870871b5323121;p=git.git diff --git a/diff.c b/diff.c index 144f2aaba..b829c0335 100644 --- a/diff.c +++ b/diff.c @@ -919,7 +919,10 @@ static void free_diff_words_data(struct emit_callback *ecbdata) free (ecbdata->diff_words->minus.orig); free (ecbdata->diff_words->plus.text.ptr); free (ecbdata->diff_words->plus.orig); - free(ecbdata->diff_words->word_regex); + if (ecbdata->diff_words->word_regex) { + regfree(ecbdata->diff_words->word_regex); + free(ecbdata->diff_words->word_regex); + } free(ecbdata->diff_words); ecbdata->diff_words = NULL; } @@ -1768,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"); } @@ -1817,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; @@ -3307,7 +3315,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac) else if ((argcount = parse_long_opt("output", av, &optarg))) { options->file = fopen(optarg, "w"); if (!options->file) - die_errno("Could not open '%s'", arg + strlen("--output=")); + die_errno("Could not open '%s'", optarg); options->close_file = 1; return argcount; } else @@ -3524,7 +3532,7 @@ static void diff_flush_stat(struct diff_filepair *p, struct diff_options *o, if ((DIFF_FILE_VALID(p->one) && S_ISDIR(p->one->mode)) || (DIFF_FILE_VALID(p->two) && S_ISDIR(p->two->mode))) - return; /* no tree diffs in patch format */ + return; /* no useful stat for tree diffs */ run_diffstat(p, o, diffstat); } @@ -3537,7 +3545,7 @@ static void diff_flush_checkdiff(struct diff_filepair *p, if ((DIFF_FILE_VALID(p->one) && S_ISDIR(p->one->mode)) || (DIFF_FILE_VALID(p->two) && S_ISDIR(p->two->mode))) - return; /* no tree diffs in patch format */ + return; /* nothing to check in tree diffs */ run_checkdiff(p, o); } @@ -3862,7 +3870,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); }