diff options
author | Jeff King <peff@peff.net> | 2018-11-02 07:36:36 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-11-05 05:14:35 +0100 |
commit | b135739125e9dc49fafc42d4a8a1956c46329ff1 (patch) | |
tree | b851e900bb4f33f6e9f91a14fc938fc167a0fb13 /diff.c | |
parent | diff: avoid generating unused hunk header lines (diff) | |
download | git-b135739125e9dc49fafc42d4a8a1956c46329ff1.tar.xz git-b135739125e9dc49fafc42d4a8a1956c46329ff1.zip |
diff: discard hunk headers for patch-ids earlier
We do not include hunk header lines when computing patch-ids, since
the line numbers would create false negatives. Rather than detect and
skip them in our line callback, we can simply tell xdiff to avoid
generating them.
This is similar to the previous commit, but split out because it
actually requires modifying the matching line callback.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to '')
-rw-r--r-- | diff.c | 8 |
1 files changed, 2 insertions, 6 deletions
@@ -5607,10 +5607,6 @@ static void patch_id_consume(void *priv, char *line, unsigned long len) struct patch_id_t *data = priv; int new_len; - /* Ignore line numbers when computing the SHA1 of the patch */ - if (starts_with(line, "@@ -")) - return; - new_len = remove_space(line, len); git_SHA1_Update(data->ctx, line, new_len); @@ -5712,8 +5708,8 @@ static int diff_get_patch_id(struct diff_options *options, struct object_id *oid xpp.flags = 0; xecfg.ctxlen = 3; xecfg.flags = 0; - if (xdi_diff_outf(&mf1, &mf2, NULL, patch_id_consume, - &data, &xpp, &xecfg)) + if (xdi_diff_outf(&mf1, &mf2, discard_hunk_line, + patch_id_consume, &data, &xpp, &xecfg)) return error("unable to generate patch-id diff for %s", p->one->path); } |