Skip to content

Commit b135739

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3b40a09 commit b135739

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

diff.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5607,10 +5607,6 @@ static void patch_id_consume(void *priv, char *line, unsigned long len)
56075607
struct patch_id_t *data = priv;
56085608
int new_len;
56095609

5610-
/* Ignore line numbers when computing the SHA1 of the patch */
5611-
if (starts_with(line, "@@ -"))
5612-
return;
5613-
56145610
new_len = remove_space(line, len);
56155611

56165612
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
57125708
xpp.flags = 0;
57135709
xecfg.ctxlen = 3;
57145710
xecfg.flags = 0;
5715-
if (xdi_diff_outf(&mf1, &mf2, NULL, patch_id_consume,
5716-
&data, &xpp, &xecfg))
5711+
if (xdi_diff_outf(&mf1, &mf2, discard_hunk_line,
5712+
patch_id_consume, &data, &xpp, &xecfg))
57175713
return error("unable to generate patch-id diff for %s",
57185714
p->one->path);
57195715
}

0 commit comments

Comments
 (0)