From patchwork Fri Nov 2 06:36:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 10664993 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 348EE17D4 for ; Fri, 2 Nov 2018 06:36:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00B082B8E4 for ; Fri, 2 Nov 2018 06:36:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E54832BC9F; Fri, 2 Nov 2018 06:36:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86E1C2B8E4 for ; Fri, 2 Nov 2018 06:36:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728414AbeKBPmn (ORCPT ); Fri, 2 Nov 2018 11:42:43 -0400 Received: from cloud.peff.net ([104.130.231.41]:37722 "HELO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1728409AbeKBPmn (ORCPT ); Fri, 2 Nov 2018 11:42:43 -0400 Received: (qmail 29460 invoked by uid 109); 2 Nov 2018 06:36:38 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with SMTP; Fri, 02 Nov 2018 06:36:38 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 976 invoked by uid 111); 2 Nov 2018 06:35:55 -0000 Received: from sigill.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.7) by peff.net (qpsmtpd/0.94) with (ECDHE-RSA-AES256-GCM-SHA384 encrypted) SMTP; Fri, 02 Nov 2018 02:35:55 -0400 Authentication-Results: peff.net; auth=none Received: by sigill.intra.peff.net (sSMTP sendmail emulation); Fri, 02 Nov 2018 02:36:36 -0400 Date: Fri, 2 Nov 2018 02:36:36 -0400 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 4/9] diff: discard hunk headers for patch-ids earlier Message-ID: <20181102063636.GD31216@sigill.intra.peff.net> References: <20181102063156.GA30252@sigill.intra.peff.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20181102063156.GA30252@sigill.intra.peff.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- diff.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/diff.c b/diff.c index d84356e007..8a83ce6058 100644 --- a/diff.c +++ b/diff.c @@ -5666,10 +5666,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); @@ -5771,8 +5767,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); }