X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=diff.c;h=340d878f02b0daa3b26cf5eb3bf71bdda1437ce2;hb=6cf9bf6cbcfd57606da30710656b248651d3113f;hp=6fb97d4623192167e9b9f83b02dfe9250f028c0a;hpb=0c1c798f20bb9956312247e091b23ba2e7baf7b4;p=git.git diff --git a/diff.c b/diff.c index 6fb97d462..340d878f0 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; } @@ -3307,7 +3310,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 +3527,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 +3540,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); } @@ -3853,6 +3856,13 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1) len2, p->two->path); git_SHA1_Update(&ctx, buffer, len1); + if (diff_filespec_is_binary(p->one) || + diff_filespec_is_binary(p->two)) { + git_SHA1_Update(&ctx, sha1_to_hex(p->one->sha1), 40); + git_SHA1_Update(&ctx, sha1_to_hex(p->two->sha1), 40); + continue; + } + xpp.flags = 0; xecfg.ctxlen = 3; xecfg.flags = XDL_EMIT_FUNCNAMES;