From patchwork Thu Jul 11 16:08:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11040395 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 1914D138B for ; Thu, 11 Jul 2019 16:09:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F16A528AFC for ; Thu, 11 Jul 2019 16:09:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E22E628B0B; Thu, 11 Jul 2019 16:09:16 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 82F4E28AFC for ; Thu, 11 Jul 2019 16:09:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728311AbfGKQJB (ORCPT ); Thu, 11 Jul 2019 12:09:01 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:38606 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726213AbfGKQJA (ORCPT ); Thu, 11 Jul 2019 12:09:00 -0400 Received: by mail-wr1-f66.google.com with SMTP id g17so6923227wrr.5 for ; Thu, 11 Jul 2019 09:08:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2xXqebNTZyy/qKd0wKsFDUyNRx/QP5rWyLVrMPAhmVU=; b=DBpBNeH9XNdNcifRRR8Sog1RG3r7PC7yITUwEtDVuGHFScTtSNpZrcvHtnPs2xLT4T SCXAOl+rzkA/135G4AVuzpkU0uyfJhRLiPcgjJugWkmjMABj5eizwNceQq6bJcv940WB wcxvSNmsiijqmghydNDyE0kHoZ9lWlIFDA2GtDs4g3HCGsgFvTVyywA0OfaJDD3X8Zdm 6ChgheU//B6T4O2tx/vcMJFUUXkgFzUK0k5x7N8TkyOp26lIFrHZp0lWdd1KxErueKTM 2QelxT15Omr7VxqREXVooc1eWdz0DAqULyCMyIGw5p3Jcx9MA+4+4qW11IXW1OElof6K qesA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2xXqebNTZyy/qKd0wKsFDUyNRx/QP5rWyLVrMPAhmVU=; b=QRyZP4E/ExghMBizEHKPhuUiqYAO/2s4obO850KlXzBvuZyA2t+iRD97TsN4PPh+Dh XWPb/CEvlcNUayAI7t+7zekvMBpz8tRzRbSP9wcPMf36QgTwBqQanql8y3BkCTJxGoiZ M1CnurelfoR6FQvvkJ5VQSQV0sxTUA+cXXhegGTP8OiqtvwAixvqpFR96iWNbxXPnvRw xZqBEKum2Sdz5pR80ldXCWbjEVL4Z9O4T6NInVLrMQ4Asj1bSoxbuefYJZnw2NwUASNM CAbmIYoM73nYNPN2Em+V1/MPKnMYsJzaCMC64EP1cof2zqyf4zNeJCfN6VJ26TjPICTm h9bQ== X-Gm-Message-State: APjAAAXAhRNSQ9bQZIIhkgH1KRHy1bri8ulyVH9hdmWjetSPRb4FCuGb KLVHt8D05CVtTPfgutc5EqD8lWh1lwc= X-Google-Smtp-Source: APXvYqyyzv9Fy6wMq6awAFclilZpiBJpxzfNs0Vr6av/0/zOP1K6MnGUedEmjbuv9KN3Z5YU752RAA== X-Received: by 2002:adf:ec0c:: with SMTP id x12mr5921922wrn.342.1562861338906; Thu, 11 Jul 2019 09:08:58 -0700 (PDT) Received: from localhost (host232-157-dynamic.24-79-r.retail.telecomitalia.it. [79.24.157.232]) by smtp.gmail.com with ESMTPSA id h14sm6061663wrs.66.2019.07.11.09.08.57 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 11 Jul 2019 09:08:57 -0700 (PDT) From: Thomas Gummerer To: git@vger.kernel.org Cc: Duy Nguyen , Johannes Schindelin , Junio C Hamano , Eric Sunshine , Johannes Sixt , Thomas Gummerer Subject: [PATCH v4 01/14] apply: replace marc.info link with public-inbox Date: Thu, 11 Jul 2019 17:08:38 +0100 Message-Id: <20190711160851.14380-2-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190711160851.14380-1-t.gummerer@gmail.com> References: <20190708163315.29912-1-t.gummerer@gmail.com> <20190711160851.14380-1-t.gummerer@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP public-inbox.org links include the whole message ID by default. This means the message can still be found even if the site goes away, which is not the case with the marc.info link. Replace the marc.info link with a more future proof one. Signed-off-by: Thomas Gummerer --- apply.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apply.c b/apply.c index f15afa9f6a..599cf8956f 100644 --- a/apply.c +++ b/apply.c @@ -478,7 +478,7 @@ static char *find_name_gnu(struct apply_state *state, /* * Proposed "new-style" GNU patch/diff format; see - * http://marc.info/?l=git&m=112927316408690&w=2 + * https://public-inbox.org/git/7vll0wvb2a.fsf@assigned-by-dhcp.cox.net/ */ if (unquote_c_style(&name, line, NULL)) { strbuf_release(&name); From patchwork Thu Jul 11 16:08:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11040397 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 607F96C5 for ; Thu, 11 Jul 2019 16:09:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EF9E28B0B for ; Thu, 11 Jul 2019 16:09:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4282328AFC; Thu, 11 Jul 2019 16:09:17 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 A2A1028B03 for ; Thu, 11 Jul 2019 16:09:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728366AbfGKQJD (ORCPT ); Thu, 11 Jul 2019 12:09:03 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:55460 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726213AbfGKQJD (ORCPT ); Thu, 11 Jul 2019 12:09:03 -0400 Received: by mail-wm1-f67.google.com with SMTP id a15so6233358wmj.5 for ; Thu, 11 Jul 2019 09:09:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gIbXyTxlwMdejKMx7NpVdVDXqC/2s+5mFLjBN4bTADg=; b=ZhtZHPllbfH29idDseyqtZZkGThCNKZGcezu/ILOCOEfYYn9UrEd5/J2IY3cnm2Dn6 g1/8WJa4XnDkWPfULgUHrPG2vndj28I91zuS+vZv4H15CqiEocxp5u67V/Os0cS1RTU2 d5rEg9KYoGZ8gtghqmszdRj6X2ATc9HwT+g4sEd0RqpCwjYfmrHVMbJEuKDWdjKCx/lA MfuFuVmEdYXgQ8FUV2zXrH7JUtS5eP5OJEl/50+ZkU0cSrA7qlgRd2Rw7OZsQunXmYjq G2yNYWqP3g+5iz/3LoMfjLNR9+W0tA8+UVYsPxres4Q9Xlwc5QHqnLAtdoGGGk/4Ferp qJ1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gIbXyTxlwMdejKMx7NpVdVDXqC/2s+5mFLjBN4bTADg=; b=CBqUyIj/cs4CJeHH2CjUbYXPFmi3FKohqD325UoCLeKb83tJsCDoOtwmcXWMkwiIRq /69vEWKQ58dQPfIMZDgv2ZW0T9firDhFgj3rjAz2hk5IwDZV+3f91DgSJSAgWwtlOUfd QoamclvLWdgBtPmua8f2/YZYFd3dLcBrIbGfb+Nl/7FZ/gpLg0u2vig2fv+R/pjHnAsQ yjDj58VYIS1efDeCu8PmQ2e3MEJmJ06PdMiRee3YagmyoWtIG43S0O1VlHnOygok7iAY 7pKV3FohynKo/S58LY7sUEddqz/jYeKfhUQtMr3SB4XpoaQ/zUwwjjg0DPYAUajoVh0Z UKFg== X-Gm-Message-State: APjAAAU3t5tA18Fji+BzimY2NZtbRlYvQ1HL7daHuLBlqhz2cTcMBCUW PaGmPyipyK6WhXLrjVUVZwzK1PeMd/A= X-Google-Smtp-Source: APXvYqwlYsrebjnXPh5wHBUvztz0HIzx+sRvu0QZJOKbEbH+vO+rQrM2Jkf/clJykJ1roNDNn6bMyg== X-Received: by 2002:a1c:9e4d:: with SMTP id h74mr5216997wme.9.1562861340734; Thu, 11 Jul 2019 09:09:00 -0700 (PDT) Received: from localhost (host232-157-dynamic.24-79-r.retail.telecomitalia.it. [79.24.157.232]) by smtp.gmail.com with ESMTPSA id u1sm6104679wml.14.2019.07.11.09.08.59 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 11 Jul 2019 09:09:00 -0700 (PDT) From: Thomas Gummerer To: git@vger.kernel.org Cc: Duy Nguyen , Johannes Schindelin , Junio C Hamano , Eric Sunshine , Johannes Sixt , Thomas Gummerer Subject: [PATCH v4 02/14] apply: only pass required data to skip_tree_prefix Date: Thu, 11 Jul 2019 17:08:39 +0100 Message-Id: <20190711160851.14380-3-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190711160851.14380-1-t.gummerer@gmail.com> References: <20190708163315.29912-1-t.gummerer@gmail.com> <20190711160851.14380-1-t.gummerer@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently the 'skip_tree_prefix()' function takes 'struct apply_state' as parameter, even though it only needs the p_value from that struct. This function is in the callchain of 'parse_git_header()', which we want to make more generally useful in a subsequent commit. To make that happen we only want to pass in the required data to 'parse_git_header()', and not the whole 'struct apply_state', and thus we want functions in the callchain of 'parse_git_header()' to only take arguments they really need. Signed-off-by: Thomas Gummerer --- apply.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/apply.c b/apply.c index 599cf8956f..fc7083fcbc 100644 --- a/apply.c +++ b/apply.c @@ -1137,17 +1137,17 @@ static int gitdiff_unrecognized(struct apply_state *state, * Skip p_value leading components from "line"; as we do not accept * absolute paths, return NULL in that case. */ -static const char *skip_tree_prefix(struct apply_state *state, +static const char *skip_tree_prefix(int p_value, const char *line, int llen) { int nslash; int i; - if (!state->p_value) + if (!p_value) return (llen && line[0] == '/') ? NULL : line; - nslash = state->p_value; + nslash = p_value; for (i = 0; i < llen; i++) { int ch = line[i]; if (ch == '/' && --nslash <= 0) @@ -1184,7 +1184,7 @@ static char *git_header_name(struct apply_state *state, goto free_and_fail1; /* strip the a/b prefix including trailing slash */ - cp = skip_tree_prefix(state, first.buf, first.len); + cp = skip_tree_prefix(state->p_value, first.buf, first.len); if (!cp) goto free_and_fail1; strbuf_remove(&first, 0, cp - first.buf); @@ -1201,7 +1201,7 @@ static char *git_header_name(struct apply_state *state, if (*second == '"') { if (unquote_c_style(&sp, second, NULL)) goto free_and_fail1; - cp = skip_tree_prefix(state, sp.buf, sp.len); + cp = skip_tree_prefix(state->p_value, sp.buf, sp.len); if (!cp) goto free_and_fail1; /* They must match, otherwise ignore */ @@ -1212,7 +1212,7 @@ static char *git_header_name(struct apply_state *state, } /* unquoted second */ - cp = skip_tree_prefix(state, second, line + llen - second); + cp = skip_tree_prefix(state->p_value, second, line + llen - second); if (!cp) goto free_and_fail1; if (line + llen - cp != first.len || @@ -1227,7 +1227,7 @@ static char *git_header_name(struct apply_state *state, } /* unquoted first name */ - name = skip_tree_prefix(state, line, llen); + name = skip_tree_prefix(state->p_value, line, llen); if (!name) return NULL; @@ -1243,7 +1243,7 @@ static char *git_header_name(struct apply_state *state, if (unquote_c_style(&sp, second, NULL)) goto free_and_fail2; - np = skip_tree_prefix(state, sp.buf, sp.len); + np = skip_tree_prefix(state->p_value, sp.buf, sp.len); if (!np) goto free_and_fail2; @@ -1287,7 +1287,7 @@ static char *git_header_name(struct apply_state *state, */ if (!name[len + 1]) return NULL; /* no postimage name */ - second = skip_tree_prefix(state, name + len + 1, + second = skip_tree_prefix(state->p_value, name + len + 1, line_len - (len + 1)); if (!second) return NULL; From patchwork Thu Jul 11 16:08:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11040399 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 75FA2184E for ; Thu, 11 Jul 2019 16:09:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6653128AFC for ; Thu, 11 Jul 2019 16:09:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 580FD28B05; Thu, 11 Jul 2019 16:09:17 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 C239428B05 for ; Thu, 11 Jul 2019 16:09:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728409AbfGKQJF (ORCPT ); Thu, 11 Jul 2019 12:09:05 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:40916 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726213AbfGKQJF (ORCPT ); Thu, 11 Jul 2019 12:09:05 -0400 Received: by mail-wr1-f68.google.com with SMTP id r1so6910043wrl.7 for ; Thu, 11 Jul 2019 09:09:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aZ9kFX0N72mcSGgn7JN2fNtiXauZXqmYq3Ey8+GVM3Y=; b=U17roAFSarKOQN1cDX2H+mJj7HEfnLNnwro6lpOGw7t28xdGKqmQqdAD0Y3THYsRCV Y/uD7bY0QuZo02xbsA10mzC1pGPUOvVy8Ud/KAFkdGV7UaDa/T9HvoG6KHC9mGnXCjxS lIl/ynH+9u64v5mU5kvP8RAKKINkqkxGveBaKf+i7m+NWjtJbN8oX68thIUhL4hBWQms k6ef9psIEbGmfuz1XHqm6X8to5Wgc6aRlPm+mUvohknURJ47svNDt7tyLWzSrmssx6Ec hVFkQOKLYMKshtjJtBSoqsQV93OT2oA29MxIHGgJEKtXTUA1flC3R/duodkl3u6Taa2o uIoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aZ9kFX0N72mcSGgn7JN2fNtiXauZXqmYq3Ey8+GVM3Y=; b=X54Z5604LO3/7ueY+CJzVzzcjAxNafciOW+WklywTEZt0EyniKJ/RO3cdAZK5MTFst qBDhxSnXCjBtCwichJHHqJXyRBYAU0qx4VNefBKRVENW2XCcPxP81a/HvnQmQbtutykr K0xWLeQnV8eWtWHKcA8spbXtodIbbR/2VQl3/xbEPlcC5N3X9ODcFvQHpISMzzp8K/t0 4/hDoU2J7UPdDdlGRm1JTr+FKC2mMO7phOPiFLVyXQfKVOBXg5Xz4940//72m3jtgpRu SqlWV3dcoV/vBHitQW+I8oYwmkQf200TzPqMECeeDCYF8PD/MLTLK19Qp8PHrkNTyGCa Bs2w== X-Gm-Message-State: APjAAAVfPY4yRBt48tTK4MaYieDZRumzkq3pBOezAHyzN3zK8ieHM0Xt qBdv5t1Ye+QHtx7QTRNPUlYA0W5d59U= X-Google-Smtp-Source: APXvYqx4eRmaqV32nKQFgm7yllbacQwUCd7yZ82pEnlS2Y53hpJY9nFRsXi8WBM0moF19jY8BTAjYA== X-Received: by 2002:adf:f050:: with SMTP id t16mr5630565wro.99.1562861342696; Thu, 11 Jul 2019 09:09:02 -0700 (PDT) Received: from localhost (host232-157-dynamic.24-79-r.retail.telecomitalia.it. [79.24.157.232]) by smtp.gmail.com with ESMTPSA id n3sm4848037wrt.31.2019.07.11.09.09.01 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 11 Jul 2019 09:09:02 -0700 (PDT) From: Thomas Gummerer To: git@vger.kernel.org Cc: Duy Nguyen , Johannes Schindelin , Junio C Hamano , Eric Sunshine , Johannes Sixt , Thomas Gummerer Subject: [PATCH v4 03/14] apply: only pass required data to git_header_name Date: Thu, 11 Jul 2019 17:08:40 +0100 Message-Id: <20190711160851.14380-4-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190711160851.14380-1-t.gummerer@gmail.com> References: <20190708163315.29912-1-t.gummerer@gmail.com> <20190711160851.14380-1-t.gummerer@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently the 'git_header_name()' function takes 'struct apply_state' as parameter, even though it only needs the p_value from that struct. This function is in the callchain of 'parse_git_header()', which we want to make more generally useful in a subsequent commit. To make that happen we only want to pass in the required data to 'parse_git_header()', and not the whole 'struct apply_state', and thus we want functions in the callchain of 'parse_git_header()' to only take arguments they really need. Signed-off-by: Thomas Gummerer --- apply.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/apply.c b/apply.c index fc7083fcbc..ac668e754d 100644 --- a/apply.c +++ b/apply.c @@ -1164,7 +1164,7 @@ static const char *skip_tree_prefix(int p_value, * creation or deletion of an empty file. In any of these cases, * both sides are the same name under a/ and b/ respectively. */ -static char *git_header_name(struct apply_state *state, +static char *git_header_name(int p_value, const char *line, int llen) { @@ -1184,7 +1184,7 @@ static char *git_header_name(struct apply_state *state, goto free_and_fail1; /* strip the a/b prefix including trailing slash */ - cp = skip_tree_prefix(state->p_value, first.buf, first.len); + cp = skip_tree_prefix(p_value, first.buf, first.len); if (!cp) goto free_and_fail1; strbuf_remove(&first, 0, cp - first.buf); @@ -1201,7 +1201,7 @@ static char *git_header_name(struct apply_state *state, if (*second == '"') { if (unquote_c_style(&sp, second, NULL)) goto free_and_fail1; - cp = skip_tree_prefix(state->p_value, sp.buf, sp.len); + cp = skip_tree_prefix(p_value, sp.buf, sp.len); if (!cp) goto free_and_fail1; /* They must match, otherwise ignore */ @@ -1212,7 +1212,7 @@ static char *git_header_name(struct apply_state *state, } /* unquoted second */ - cp = skip_tree_prefix(state->p_value, second, line + llen - second); + cp = skip_tree_prefix(p_value, second, line + llen - second); if (!cp) goto free_and_fail1; if (line + llen - cp != first.len || @@ -1227,7 +1227,7 @@ static char *git_header_name(struct apply_state *state, } /* unquoted first name */ - name = skip_tree_prefix(state->p_value, line, llen); + name = skip_tree_prefix(p_value, line, llen); if (!name) return NULL; @@ -1243,7 +1243,7 @@ static char *git_header_name(struct apply_state *state, if (unquote_c_style(&sp, second, NULL)) goto free_and_fail2; - np = skip_tree_prefix(state->p_value, sp.buf, sp.len); + np = skip_tree_prefix(p_value, sp.buf, sp.len); if (!np) goto free_and_fail2; @@ -1287,7 +1287,7 @@ static char *git_header_name(struct apply_state *state, */ if (!name[len + 1]) return NULL; /* no postimage name */ - second = skip_tree_prefix(state->p_value, name + len + 1, + second = skip_tree_prefix(p_value, name + len + 1, line_len - (len + 1)); if (!second) return NULL; @@ -1333,7 +1333,7 @@ static int parse_git_header(struct apply_state *state, * or removing or adding empty files), so we get * the default name from the header. */ - patch->def_name = git_header_name(state, line, len); + patch->def_name = git_header_name(state->p_value, line, len); if (patch->def_name && state->root.len) { char *s = xstrfmt("%s%s", state->root.buf, patch->def_name); free(patch->def_name); From patchwork Thu Jul 11 16:08:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11040403 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 E587E18EC for ; Thu, 11 Jul 2019 16:09:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D77C928AFC for ; Thu, 11 Jul 2019 16:09:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC10928B06; Thu, 11 Jul 2019 16:09:17 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 E1E8F28B08 for ; Thu, 11 Jul 2019 16:09:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728434AbfGKQJH (ORCPT ); Thu, 11 Jul 2019 12:09:07 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:40921 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726213AbfGKQJG (ORCPT ); Thu, 11 Jul 2019 12:09:06 -0400 Received: by mail-wr1-f66.google.com with SMTP id r1so6910177wrl.7 for ; Thu, 11 Jul 2019 09:09:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=O0O/eXuhEnD5jx/0ReEjojd9SJEmu2xsvsKP7ud/r9I=; b=ZatYcW8L9XJE9tsYyanIiuPw6i9EK4/E5Me38Qq4rNuh9JJsICVLxEAqM/84BR9h/m Ll0Bkb9d90aXdEWfxCZ+nawK3deI6l8qRruY3AeniCp6D1pvt2YoJ2y03gA303TU+6T1 B7SwvmC2dXoBgROFM5HXoLBGy1tD3RSaWf1iyQq9UeusJvlqUr8/JstoGRjvn1ETYiy5 T4e3YFxcpW/nt3L91c99hhsWG19TtqwOVkWQ00sBWkcHEtGIXxdd1VOUZetyJZrAj4Ps ax1cAQrL+V3Hapeksq5xZd1Ob01bQ5tZpyanTiT2O/+4Nz9V+4RMRk9gegkZFk9RJx/2 HREg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=O0O/eXuhEnD5jx/0ReEjojd9SJEmu2xsvsKP7ud/r9I=; b=snPPjEFRZSIrobXYUDEUeHZoPsimcemn9oDquOZi4QbPy2vSy4Hqy6aGDW0zanACfX dnfIUInJdK1znKPApvjDu03yCLMLJ8kxvMxBNccKx9046owdZs8yOIX5Me5g70quGCDE 2BafkHIHSrVs8mOYu00UbyqHTqfsXy7rEcTupGYwJ1ryowZTV5Lp8vnyeGQXoMst6pJn aXR8zb5hc+lE8FIhntuXL7SIfHDvmMI0skEJ649WImrDfb9Q8Qd2/JiAOB8cSEpdE1zZ c6waM4BRK9Re3O707VZB03eov/TdPHhSjftTj/bQRG3Hf5v7SIIgwIVbc3FyH6LB841G v5vg== X-Gm-Message-State: APjAAAUZBWmCf44lVhYc+Omi+iGoCIMo+Wzt6lNyo/NolRbozsHRINmr Of5cgUPS/uFP1D8LRFLNrPrZ0pCePSs= X-Google-Smtp-Source: APXvYqxlMJ8ssy99JP+ZauZdG5q4ceAHZyG+zg9WZeZlvC+B0+vozb0dMZFwJLXn3Ykow1snUO6IRQ== X-Received: by 2002:a5d:5450:: with SMTP id w16mr6258685wrv.128.1562861344868; Thu, 11 Jul 2019 09:09:04 -0700 (PDT) Received: from localhost (host232-157-dynamic.24-79-r.retail.telecomitalia.it. [79.24.157.232]) by smtp.gmail.com with ESMTPSA id c78sm6742616wmd.16.2019.07.11.09.09.03 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 11 Jul 2019 09:09:03 -0700 (PDT) From: Thomas Gummerer To: git@vger.kernel.org Cc: Duy Nguyen , Johannes Schindelin , Junio C Hamano , Eric Sunshine , Johannes Sixt , Thomas Gummerer Subject: [PATCH v4 04/14] apply: only pass required data to check_header_line Date: Thu, 11 Jul 2019 17:08:41 +0100 Message-Id: <20190711160851.14380-5-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190711160851.14380-1-t.gummerer@gmail.com> References: <20190708163315.29912-1-t.gummerer@gmail.com> <20190711160851.14380-1-t.gummerer@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently the 'check_header_line()' function takes 'struct apply_state' as parameter, even though it only needs the linenr from that struct. This function is in the callchain of 'parse_git_header()', which we want to make more generally useful in a subsequent commit. To make that happen we only want to pass in the required data to 'parse_git_header()', and not the whole 'struct apply_state', and thus we want functions in the callchain of 'parse_git_header()' to only take arguments they really need. Signed-off-by: Thomas Gummerer --- apply.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apply.c b/apply.c index ac668e754d..1602fd5db0 100644 --- a/apply.c +++ b/apply.c @@ -1302,15 +1302,15 @@ static char *git_header_name(int p_value, } } -static int check_header_line(struct apply_state *state, struct patch *patch) +static int check_header_line(int linenr, struct patch *patch) { int extensions = (patch->is_delete == 1) + (patch->is_new == 1) + (patch->is_rename == 1) + (patch->is_copy == 1); if (extensions > 1) return error(_("inconsistent header lines %d and %d"), - patch->extension_linenr, state->linenr); + patch->extension_linenr, linenr); if (extensions && !patch->extension_linenr) - patch->extension_linenr = state->linenr; + patch->extension_linenr = linenr; return 0; } @@ -1380,7 +1380,7 @@ static int parse_git_header(struct apply_state *state, res = p->fn(state, line + oplen, patch); if (res < 0) return -1; - if (check_header_line(state, patch)) + if (check_header_line(state->linenr, patch)) return -1; if (res > 0) return offset; From patchwork Thu Jul 11 16:08:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11040409 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 800E4184E for ; Thu, 11 Jul 2019 16:09:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E95C28A0F for ; Thu, 11 Jul 2019 16:09:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6324228AFC; Thu, 11 Jul 2019 16:09:18 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 0D94E28B0F for ; Thu, 11 Jul 2019 16:09:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728455AbfGKQJJ (ORCPT ); Thu, 11 Jul 2019 12:09:09 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:34444 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726213AbfGKQJI (ORCPT ); Thu, 11 Jul 2019 12:09:08 -0400 Received: by mail-wr1-f68.google.com with SMTP id 31so6950907wrm.1 for ; Thu, 11 Jul 2019 09:09:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GHvYJZH4IZ7ELFv3K/QTLwxkP5gJcypPwWDqRBGoxgc=; b=hz4QMHZtYWLZOt71DBMge8+SkBvbsKw713noWuuH4P2fQybYI3GK6E7j1IQZNlnPps a22ViiCrSspGkBQrwRUbMg8PhiJ+9Vrg5HVV2Im6GWUrrMbbyYGhErEkYp27QAqrEIfK 5FWM7nWKeAeV28fi4Yy6EeEkJCTuK7VRU28NBuWRY3jChf7uffUQInQ3Xfa6J/eZUvSl BS9UrL6Yki+EoNJdFyd9tqXuFAsZDpFBeHvyqQJBQa72KeGl5fOJxjfwAVCN/cM2q6Rj h1ElHmmPZinIJeEhmeEK6IOK1GJJwjMjzzQI7hi83VFYrbX0pqgp8BSDOJEq6HlQmNQw /oyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GHvYJZH4IZ7ELFv3K/QTLwxkP5gJcypPwWDqRBGoxgc=; b=KG0gYQ4gTEMgIAe3SeXu7WgTqyMZqFGL9pxs/h1Mk6+Kh08+gvQ2g3KoWf/p+XOY8V n23QgZGtCNBG2QVxDX/3dgj3/BA/zg/rI9ehs7BKAPO5Jt6+FOazYuVUvC6e/zjkAnNO If1E37CK8ArsLiDqcPI9eWbNP3Kf+6ceCRU7LqF8mtrlmQKm8eAO4gqU5R/5F7XlyAaK VM84JciVUPESRuGcKITVxzB3fQWro8BOq1aDHgtvPpi8ylez47FzF5QpnYrdyH9tp+dr 5rGOWz86wiheFmF5PL4m4Ie6xuwKozSoyt/eepTR1JxMeeFf1OmioNAbTgG8ZKQioCuE b74w== X-Gm-Message-State: APjAAAX+6NUfJ6Pg/XfdC4dZjoTxtONFbOvu0mIT4gl2qTbU5gNe5YJ2 IF7wckkK0mqpBqeDG4MOBcENsHliQ4I= X-Google-Smtp-Source: APXvYqzINZ95tZfCVXdbhc8VW1MeMj4P+aPTWyrbaJGjokECrdip9TT5d8+7R9o1FgnuoGbYnZS4gA== X-Received: by 2002:adf:a70b:: with SMTP id c11mr6235152wrd.172.1562861346706; Thu, 11 Jul 2019 09:09:06 -0700 (PDT) Received: from localhost (host232-157-dynamic.24-79-r.retail.telecomitalia.it. [79.24.157.232]) by smtp.gmail.com with ESMTPSA id t15sm5929546wrx.84.2019.07.11.09.09.05 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 11 Jul 2019 09:09:06 -0700 (PDT) From: Thomas Gummerer To: git@vger.kernel.org Cc: Duy Nguyen , Johannes Schindelin , Junio C Hamano , Eric Sunshine , Johannes Sixt , Thomas Gummerer Subject: [PATCH v4 05/14] apply: only pass required data to find_name_* Date: Thu, 11 Jul 2019 17:08:42 +0100 Message-Id: <20190711160851.14380-6-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190711160851.14380-1-t.gummerer@gmail.com> References: <20190708163315.29912-1-t.gummerer@gmail.com> <20190711160851.14380-1-t.gummerer@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently the 'find_name_*()' functions take 'struct apply_state' as parameter, even though they only need the 'root' member from that struct. These functions are in the callchain of 'parse_git_header()', which we want to make more generally useful in a subsequent commit. To make that happen we only want to pass in the required data to 'parse_git_header()', and not the whole 'struct apply_state', and thus we want functions in the callchain of 'parse_git_header()' to only take arguments they really need. Signed-off-by: Thomas Gummerer --- apply.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/apply.c b/apply.c index 1602fd5db0..3cd4e3d3b3 100644 --- a/apply.c +++ b/apply.c @@ -469,7 +469,7 @@ static char *squash_slash(char *name) return name; } -static char *find_name_gnu(struct apply_state *state, +static char *find_name_gnu(struct strbuf *root, const char *line, int p_value) { @@ -495,8 +495,8 @@ static char *find_name_gnu(struct apply_state *state, } strbuf_remove(&name, 0, cp - name.buf); - if (state->root.len) - strbuf_insert(&name, 0, state->root.buf, state->root.len); + if (root->len) + strbuf_insert(&name, 0, root->buf, root->len); return squash_slash(strbuf_detach(&name, NULL)); } @@ -659,7 +659,7 @@ static size_t diff_timestamp_len(const char *line, size_t len) return line + len - end; } -static char *find_name_common(struct apply_state *state, +static char *find_name_common(struct strbuf *root, const char *line, const char *def, int p_value, @@ -702,30 +702,30 @@ static char *find_name_common(struct apply_state *state, return squash_slash(xstrdup(def)); } - if (state->root.len) { - char *ret = xstrfmt("%s%.*s", state->root.buf, len, start); + if (root->len) { + char *ret = xstrfmt("%s%.*s", root->buf, len, start); return squash_slash(ret); } return squash_slash(xmemdupz(start, len)); } -static char *find_name(struct apply_state *state, +static char *find_name(struct strbuf *root, const char *line, char *def, int p_value, int terminate) { if (*line == '"') { - char *name = find_name_gnu(state, line, p_value); + char *name = find_name_gnu(root, line, p_value); if (name) return name; } - return find_name_common(state, line, def, p_value, NULL, terminate); + return find_name_common(root, line, def, p_value, NULL, terminate); } -static char *find_name_traditional(struct apply_state *state, +static char *find_name_traditional(struct strbuf *root, const char *line, char *def, int p_value) @@ -734,7 +734,7 @@ static char *find_name_traditional(struct apply_state *state, size_t date_len; if (*line == '"') { - char *name = find_name_gnu(state, line, p_value); + char *name = find_name_gnu(root, line, p_value); if (name) return name; } @@ -742,10 +742,10 @@ static char *find_name_traditional(struct apply_state *state, len = strchrnul(line, '\n') - line; date_len = diff_timestamp_len(line, len); if (!date_len) - return find_name_common(state, line, def, p_value, NULL, TERM_TAB); + return find_name_common(root, line, def, p_value, NULL, TERM_TAB); len -= date_len; - return find_name_common(state, line, def, p_value, line + len, 0); + return find_name_common(root, line, def, p_value, line + len, 0); } /* @@ -759,7 +759,7 @@ static int guess_p_value(struct apply_state *state, const char *nameline) if (is_dev_null(nameline)) return -1; - name = find_name_traditional(state, nameline, NULL, 0); + name = find_name_traditional(&state->root, nameline, NULL, 0); if (!name) return -1; cp = strchr(name, '/'); @@ -883,17 +883,17 @@ static int parse_traditional_patch(struct apply_state *state, if (is_dev_null(first)) { patch->is_new = 1; patch->is_delete = 0; - name = find_name_traditional(state, second, NULL, state->p_value); + name = find_name_traditional(&state->root, second, NULL, state->p_value); patch->new_name = name; } else if (is_dev_null(second)) { patch->is_new = 0; patch->is_delete = 1; - name = find_name_traditional(state, first, NULL, state->p_value); + name = find_name_traditional(&state->root, first, NULL, state->p_value); patch->old_name = name; } else { char *first_name; - first_name = find_name_traditional(state, first, NULL, state->p_value); - name = find_name_traditional(state, second, first_name, state->p_value); + first_name = find_name_traditional(&state->root, first, NULL, state->p_value); + name = find_name_traditional(&state->root, second, first_name, state->p_value); free(first_name); if (has_epoch_timestamp(first)) { patch->is_new = 1; @@ -940,7 +940,7 @@ static int gitdiff_verify_name(struct apply_state *state, int side) { if (!*name && !isnull) { - *name = find_name(state, line, NULL, state->p_value, TERM_TAB); + *name = find_name(&state->root, line, NULL, state->p_value, TERM_TAB); return 0; } @@ -949,7 +949,7 @@ static int gitdiff_verify_name(struct apply_state *state, if (isnull) return error(_("git apply: bad git-diff - expected /dev/null, got %s on line %d"), *name, state->linenr); - another = find_name(state, line, NULL, state->p_value, TERM_TAB); + another = find_name(&state->root, line, NULL, state->p_value, TERM_TAB); if (!another || strcmp(another, *name)) { free(another); return error((side == DIFF_NEW_NAME) ? @@ -1032,7 +1032,7 @@ static int gitdiff_copysrc(struct apply_state *state, { patch->is_copy = 1; free(patch->old_name); - patch->old_name = find_name(state, line, NULL, state->p_value ? state->p_value - 1 : 0, 0); + patch->old_name = find_name(&state->root, line, NULL, state->p_value ? state->p_value - 1 : 0, 0); return 0; } @@ -1042,7 +1042,7 @@ static int gitdiff_copydst(struct apply_state *state, { patch->is_copy = 1; free(patch->new_name); - patch->new_name = find_name(state, line, NULL, state->p_value ? state->p_value - 1 : 0, 0); + patch->new_name = find_name(&state->root, line, NULL, state->p_value ? state->p_value - 1 : 0, 0); return 0; } @@ -1052,7 +1052,7 @@ static int gitdiff_renamesrc(struct apply_state *state, { patch->is_rename = 1; free(patch->old_name); - patch->old_name = find_name(state, line, NULL, state->p_value ? state->p_value - 1 : 0, 0); + patch->old_name = find_name(&state->root, line, NULL, state->p_value ? state->p_value - 1 : 0, 0); return 0; } @@ -1062,7 +1062,7 @@ static int gitdiff_renamedst(struct apply_state *state, { patch->is_rename = 1; free(patch->new_name); - patch->new_name = find_name(state, line, NULL, state->p_value ? state->p_value - 1 : 0, 0); + patch->new_name = find_name(&state->root, line, NULL, state->p_value ? state->p_value - 1 : 0, 0); return 0; } From patchwork Thu Jul 11 16:08:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11040405 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 0A5F81890 for ; Thu, 11 Jul 2019 16:09:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDFAC28A0F for ; Thu, 11 Jul 2019 16:09:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E27D528B0B; Thu, 11 Jul 2019 16:09:17 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 2D01E28A0F for ; Thu, 11 Jul 2019 16:09:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728491AbfGKQJL (ORCPT ); Thu, 11 Jul 2019 12:09:11 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:40931 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728456AbfGKQJL (ORCPT ); Thu, 11 Jul 2019 12:09:11 -0400 Received: by mail-wr1-f65.google.com with SMTP id r1so6910395wrl.7 for ; Thu, 11 Jul 2019 09:09:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PhmadcU2Rhqw/ySCLOA3sGdYVP5KAb5UxizO12/IrsU=; b=pqe0TXzMYk2MKPpHJOk8YZ1sl03u58mHGb942H86v/xG8+5jmoytbfIi4xfm91BOub vb/nZlclAvJu+E9ha2O+BGL13lP28Fu16F9l5JbrTSSwUpUWne/ur/fvnPfqP2roDMKp NXESCsnYEKMGz2g4TTXk8dZ5LCZYZhQSAhpY/YpBMY7oG1erH2eb1x1FdaR784CGcGXY eZmtm9FDziHLNfPeVxE2ghLA/Otqey0DDapc86Q7xUlD9tm3sbtmaA+2et4fEh5OYZCQ 3ztY5OTbgZyQe2OCdEVsO/A13wkeG01QILTJd2gtn3log5LDhmjJeWzO2Fr8u6FgpnuJ grdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PhmadcU2Rhqw/ySCLOA3sGdYVP5KAb5UxizO12/IrsU=; b=afARtusG0e+gDHbETa2t1H+Wjs+zGNBQel/jdSP0zEWbsVTd6kBJ0tRBp09ziFjElk FBQyb/Qqt1MQ7EaHC9yXsbGeNOjb9BhOyx//jCMDFVwVIVH8Ct8LHkazhz7X1OKRDIl5 82uZj2DbhgSQasW4kpYQmvNfLfD4olBc3aPfziRATyVlo/WtFzC+eIpJJJDfat7liHGF LmlbMlqX9gmeTgI5sitnAoIy+UmaPyrp0UWrh820NSHyXtjoyz88hKWeTqZnNl2AOFJ1 VPtBV0uprlwr0LsHHVxI5vt6nQ880u/Kt5bdg87ARGIkVef3THutGC+hDDMdhrYAEDAl qmEg== X-Gm-Message-State: APjAAAXjRQej4h1NaZ3DZXz6WxEylLCgnhRRf7sfKqtz43IztMU4QokH jhaIPxXIXKPjHe7dZiAzKMIdzL96itE= X-Google-Smtp-Source: APXvYqyb0GsGXOzYfhuH/CZOxAP/v5hQahAUUII1YjmMe6EaGVc3ZI59z7sG9K6NWoc4BK3ZzmAoNA== X-Received: by 2002:adf:f042:: with SMTP id t2mr5979523wro.139.1562861348645; Thu, 11 Jul 2019 09:09:08 -0700 (PDT) Received: from localhost (host232-157-dynamic.24-79-r.retail.telecomitalia.it. [79.24.157.232]) by smtp.gmail.com with ESMTPSA id s2sm4153728wmj.33.2019.07.11.09.09.07 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 11 Jul 2019 09:09:08 -0700 (PDT) From: Thomas Gummerer To: git@vger.kernel.org Cc: Duy Nguyen , Johannes Schindelin , Junio C Hamano , Eric Sunshine , Johannes Sixt , Thomas Gummerer Subject: [PATCH v4 06/14] apply: only pass required data to gitdiff_* functions Date: Thu, 11 Jul 2019 17:08:43 +0100 Message-Id: <20190711160851.14380-7-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190711160851.14380-1-t.gummerer@gmail.com> References: <20190708163315.29912-1-t.gummerer@gmail.com> <20190711160851.14380-1-t.gummerer@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently the 'gitdiff_*()' functions take 'struct apply_state' as parameter, even though they only needs the root, linenr and p_value from that struct. These functions are in the callchain of 'parse_git_header()', which we want to make more generally useful in a subsequent commit. To make that happen we only want to pass in the required data to 'parse_git_header()', and not the whole 'struct apply_state', and thus we want functions in the callchain of 'parse_git_header()' to only take arguments they really need. As these functions are called in a loop using their function pointers, each function needs to be passed all the parameters even if only one of the functions actually needs it. We therefore pass this data along in a struct to avoid adding too many unused parameters to each function and making the code very verbose in the process. Signed-off-by: Thomas Gummerer --- apply.c | 59 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/apply.c b/apply.c index 3cd4e3d3b3..034d134dd5 100644 --- a/apply.c +++ b/apply.c @@ -22,6 +22,12 @@ #include "rerere.h" #include "apply.h" +struct gitdiff_data { + struct strbuf *root; + int linenr; + int p_value; +}; + static void git_apply_config(void) { git_config_get_string_const("apply.whitespace", &apply_default_whitespace); @@ -914,7 +920,7 @@ static int parse_traditional_patch(struct apply_state *state, return 0; } -static int gitdiff_hdrend(struct apply_state *state, +static int gitdiff_hdrend(struct gitdiff_data *state, const char *line, struct patch *patch) { @@ -933,14 +939,14 @@ static int gitdiff_hdrend(struct apply_state *state, #define DIFF_OLD_NAME 0 #define DIFF_NEW_NAME 1 -static int gitdiff_verify_name(struct apply_state *state, +static int gitdiff_verify_name(struct gitdiff_data *state, const char *line, int isnull, char **name, int side) { if (!*name && !isnull) { - *name = find_name(&state->root, line, NULL, state->p_value, TERM_TAB); + *name = find_name(state->root, line, NULL, state->p_value, TERM_TAB); return 0; } @@ -949,7 +955,7 @@ static int gitdiff_verify_name(struct apply_state *state, if (isnull) return error(_("git apply: bad git-diff - expected /dev/null, got %s on line %d"), *name, state->linenr); - another = find_name(&state->root, line, NULL, state->p_value, TERM_TAB); + another = find_name(state->root, line, NULL, state->p_value, TERM_TAB); if (!another || strcmp(another, *name)) { free(another); return error((side == DIFF_NEW_NAME) ? @@ -965,7 +971,7 @@ static int gitdiff_verify_name(struct apply_state *state, return 0; } -static int gitdiff_oldname(struct apply_state *state, +static int gitdiff_oldname(struct gitdiff_data *state, const char *line, struct patch *patch) { @@ -974,7 +980,7 @@ static int gitdiff_oldname(struct apply_state *state, DIFF_OLD_NAME); } -static int gitdiff_newname(struct apply_state *state, +static int gitdiff_newname(struct gitdiff_data *state, const char *line, struct patch *patch) { @@ -992,21 +998,21 @@ static int parse_mode_line(const char *line, int linenr, unsigned int *mode) return 0; } -static int gitdiff_oldmode(struct apply_state *state, +static int gitdiff_oldmode(struct gitdiff_data *state, const char *line, struct patch *patch) { return parse_mode_line(line, state->linenr, &patch->old_mode); } -static int gitdiff_newmode(struct apply_state *state, +static int gitdiff_newmode(struct gitdiff_data *state, const char *line, struct patch *patch) { return parse_mode_line(line, state->linenr, &patch->new_mode); } -static int gitdiff_delete(struct apply_state *state, +static int gitdiff_delete(struct gitdiff_data *state, const char *line, struct patch *patch) { @@ -1016,7 +1022,7 @@ static int gitdiff_delete(struct apply_state *state, return gitdiff_oldmode(state, line, patch); } -static int gitdiff_newfile(struct apply_state *state, +static int gitdiff_newfile(struct gitdiff_data *state, const char *line, struct patch *patch) { @@ -1026,47 +1032,47 @@ static int gitdiff_newfile(struct apply_state *state, return gitdiff_newmode(state, line, patch); } -static int gitdiff_copysrc(struct apply_state *state, +static int gitdiff_copysrc(struct gitdiff_data *state, const char *line, struct patch *patch) { patch->is_copy = 1; free(patch->old_name); - patch->old_name = find_name(&state->root, line, NULL, state->p_value ? state->p_value - 1 : 0, 0); + patch->old_name = find_name(state->root, line, NULL, state->p_value ? state->p_value - 1 : 0, 0); return 0; } -static int gitdiff_copydst(struct apply_state *state, +static int gitdiff_copydst(struct gitdiff_data *state, const char *line, struct patch *patch) { patch->is_copy = 1; free(patch->new_name); - patch->new_name = find_name(&state->root, line, NULL, state->p_value ? state->p_value - 1 : 0, 0); + patch->new_name = find_name(state->root, line, NULL, state->p_value ? state->p_value - 1 : 0, 0); return 0; } -static int gitdiff_renamesrc(struct apply_state *state, +static int gitdiff_renamesrc(struct gitdiff_data *state, const char *line, struct patch *patch) { patch->is_rename = 1; free(patch->old_name); - patch->old_name = find_name(&state->root, line, NULL, state->p_value ? state->p_value - 1 : 0, 0); + patch->old_name = find_name(state->root, line, NULL, state->p_value ? state->p_value - 1 : 0, 0); return 0; } -static int gitdiff_renamedst(struct apply_state *state, +static int gitdiff_renamedst(struct gitdiff_data *state, const char *line, struct patch *patch) { patch->is_rename = 1; free(patch->new_name); - patch->new_name = find_name(&state->root, line, NULL, state->p_value ? state->p_value - 1 : 0, 0); + patch->new_name = find_name(state->root, line, NULL, state->p_value ? state->p_value - 1 : 0, 0); return 0; } -static int gitdiff_similarity(struct apply_state *state, +static int gitdiff_similarity(struct gitdiff_data *state, const char *line, struct patch *patch) { @@ -1076,7 +1082,7 @@ static int gitdiff_similarity(struct apply_state *state, return 0; } -static int gitdiff_dissimilarity(struct apply_state *state, +static int gitdiff_dissimilarity(struct gitdiff_data *state, const char *line, struct patch *patch) { @@ -1086,7 +1092,7 @@ static int gitdiff_dissimilarity(struct apply_state *state, return 0; } -static int gitdiff_index(struct apply_state *state, +static int gitdiff_index(struct gitdiff_data *state, const char *line, struct patch *patch) { @@ -1126,7 +1132,7 @@ static int gitdiff_index(struct apply_state *state, * This is normal for a diff that doesn't change anything: we'll fall through * into the next diff. Tell the parser to break out. */ -static int gitdiff_unrecognized(struct apply_state *state, +static int gitdiff_unrecognized(struct gitdiff_data *state, const char *line, struct patch *patch) { @@ -1322,6 +1328,7 @@ static int parse_git_header(struct apply_state *state, struct patch *patch) { unsigned long offset; + struct gitdiff_data parse_hdr_state; /* A git diff has explicit new/delete information, so we don't guess */ patch->is_new = 0; @@ -1343,10 +1350,14 @@ static int parse_git_header(struct apply_state *state, line += len; size -= len; state->linenr++; + parse_hdr_state.root = &state->root; + parse_hdr_state.linenr = state->linenr; + parse_hdr_state.p_value = state->p_value; + for (offset = len ; size > 0 ; offset += len, size -= len, line += len, state->linenr++) { static const struct opentry { const char *str; - int (*fn)(struct apply_state *, const char *, struct patch *); + int (*fn)(struct gitdiff_data *, const char *, struct patch *); } optable[] = { { "@@ -", gitdiff_hdrend }, { "--- ", gitdiff_oldname }, @@ -1377,7 +1388,7 @@ static int parse_git_header(struct apply_state *state, int res; if (len < oplen || memcmp(p->str, line, oplen)) continue; - res = p->fn(state, line + oplen, patch); + res = p->fn(&parse_hdr_state, line + oplen, patch); if (res < 0) return -1; if (check_header_line(state->linenr, patch)) From patchwork Thu Jul 11 16:08:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11040407 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 32984138B for ; Thu, 11 Jul 2019 16:09:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1ED2928A0F for ; Thu, 11 Jul 2019 16:09:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 135A828B03; Thu, 11 Jul 2019 16:09:18 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 6E13128B0D for ; Thu, 11 Jul 2019 16:09:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728495AbfGKQJP (ORCPT ); Thu, 11 Jul 2019 12:09:15 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:51001 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728469AbfGKQJN (ORCPT ); Thu, 11 Jul 2019 12:09:13 -0400 Received: by mail-wm1-f68.google.com with SMTP id v15so6256145wml.0 for ; Thu, 11 Jul 2019 09:09:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SuVebWK5oI4Mo7NW3DvUVzOVzu7xvxJpZthVHUaS+bc=; b=ewJ+lCiVT0Ix4XhYMx9sVGy3uvhGRt4i0YovRteqZeHs5DiPZ33ppxwWGQFC2U8sAT v+Nvy+UA4gnafxZMf+F+CGTxy3LyZsJGR5f24OKP1s43+i0Cs3CG1Gu7yMO+YivkfR6b XJrDrenh3TCFXgl51KW86qUp5sYEIX26hkAgFUyUymrnQUO0oKN/iZ/YDZTgEWqD9r4J MELs/RiPiOc2cz+yMbTk/2spSmGxh6b+YO8IPcg543oW/9BH3VlMw+DRlweBtrKWgvOy bCvwpoVuodkZTz4GsLnHdwE4D2gCPcw2zrKVwZ2YVRKusYnu5CZmcI2nwkqKt/6XOVbg XD1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SuVebWK5oI4Mo7NW3DvUVzOVzu7xvxJpZthVHUaS+bc=; b=RLDhyDGSqe9Gyh+COUoBQhwyD0LaVKYOnjM3XRE4CczselzChWdxAUA/3TENlTHYEg tYmHZ7nQjP4sj7/t4tZME/2PYqT2/Yo2jZ7dwnIvgePgA/hqPWbIKpkgrWv5h9/k2WEF Jfvi1QgVvyIIPzndjVpBg8DnVs9ubCEIb8mvKYcxCDhvPILpqihz+q2jvto7kJa5wYYZ C0YilF/Wkh0EymCKUgETAi9CjJCmlr3PXiG9Hx4HEIMTxhegq8hh4hPyccDSKaUBAh5U SmaLvzJVVbe0K/BctWMZFLUftOLpuc81r9/GtIR1WlGGcpCael1YypwXcqPH8IpZix5j tYjQ== X-Gm-Message-State: APjAAAVniZd9Wv++z2eQcBN5GVi/B2tYTYVucx5/2weRwXGR6l4TcJvY uKMo43312ENJL/Q4PvV86JomWkgnOvo= X-Google-Smtp-Source: APXvYqxegx7e9VIRxjBATHr+NWiHunRnnDH+s+uxMXjAoUmZQcrlKpMTTA72KstEHwoOcAqvcL5SWg== X-Received: by 2002:a1c:18d:: with SMTP id 135mr4905040wmb.171.1562861350392; Thu, 11 Jul 2019 09:09:10 -0700 (PDT) Received: from localhost (host232-157-dynamic.24-79-r.retail.telecomitalia.it. [79.24.157.232]) by smtp.gmail.com with ESMTPSA id a67sm4842254wmh.40.2019.07.11.09.09.09 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 11 Jul 2019 09:09:09 -0700 (PDT) From: Thomas Gummerer To: git@vger.kernel.org Cc: Duy Nguyen , Johannes Schindelin , Junio C Hamano , Eric Sunshine , Johannes Sixt , Thomas Gummerer Subject: [PATCH v4 07/14] apply: make parse_git_diff_header public Date: Thu, 11 Jul 2019 17:08:44 +0100 Message-Id: <20190711160851.14380-8-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190711160851.14380-1-t.gummerer@gmail.com> References: <20190708163315.29912-1-t.gummerer@gmail.com> <20190711160851.14380-1-t.gummerer@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make 'parse_git_header()' (renamed to 'parse_git_diff_header()') a "public" function in apply.h, so we can re-use it in range-diff in a subsequent commit. We're renaming the function to make it clearer in other parts of the codebase that we're talking about a diff header and not just any header. Signed-off-by: Thomas Gummerer --- apply.c | 69 ++++++++++++++++----------------------------------------- apply.h | 48 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 50 deletions(-) diff --git a/apply.c b/apply.c index 034d134dd5..d68a6acad7 100644 --- a/apply.c +++ b/apply.c @@ -207,40 +207,6 @@ struct fragment { #define BINARY_DELTA_DEFLATED 1 #define BINARY_LITERAL_DEFLATED 2 -/* - * This represents a "patch" to a file, both metainfo changes - * such as creation/deletion, filemode and content changes represented - * as a series of fragments. - */ -struct patch { - char *new_name, *old_name, *def_name; - unsigned int old_mode, new_mode; - int is_new, is_delete; /* -1 = unknown, 0 = false, 1 = true */ - int rejected; - unsigned ws_rule; - int lines_added, lines_deleted; - int score; - int extension_linenr; /* first line specifying delete/new/rename/copy */ - unsigned int is_toplevel_relative:1; - unsigned int inaccurate_eof:1; - unsigned int is_binary:1; - unsigned int is_copy:1; - unsigned int is_rename:1; - unsigned int recount:1; - unsigned int conflicted_threeway:1; - unsigned int direct_to_threeway:1; - unsigned int crlf_in_old:1; - struct fragment *fragments; - char *result; - size_t resultsize; - char old_oid_prefix[GIT_MAX_HEXSZ + 1]; - char new_oid_prefix[GIT_MAX_HEXSZ + 1]; - struct patch *next; - - /* three-way fallback result */ - struct object_id threeway_stage[3]; -}; - static void free_fragment_list(struct fragment *list) { while (list) { @@ -1320,12 +1286,13 @@ static int check_header_line(int linenr, struct patch *patch) return 0; } -/* Verify that we recognize the lines following a git header */ -static int parse_git_header(struct apply_state *state, - const char *line, - int len, - unsigned int size, - struct patch *patch) +int parse_git_diff_header(struct strbuf *root, + int *linenr, + int p_value, + const char *line, + int len, + unsigned int size, + struct patch *patch) { unsigned long offset; struct gitdiff_data parse_hdr_state; @@ -1340,21 +1307,21 @@ static int parse_git_header(struct apply_state *state, * or removing or adding empty files), so we get * the default name from the header. */ - patch->def_name = git_header_name(state->p_value, line, len); - if (patch->def_name && state->root.len) { - char *s = xstrfmt("%s%s", state->root.buf, patch->def_name); + patch->def_name = git_header_name(p_value, line, len); + if (patch->def_name && root->len) { + char *s = xstrfmt("%s%s", root->buf, patch->def_name); free(patch->def_name); patch->def_name = s; } line += len; size -= len; - state->linenr++; - parse_hdr_state.root = &state->root; - parse_hdr_state.linenr = state->linenr; - parse_hdr_state.p_value = state->p_value; + (*linenr)++; + parse_hdr_state.root = root; + parse_hdr_state.linenr = *linenr; + parse_hdr_state.p_value = p_value; - for (offset = len ; size > 0 ; offset += len, size -= len, line += len, state->linenr++) { + for (offset = len ; size > 0 ; offset += len, size -= len, line += len, (*linenr)++) { static const struct opentry { const char *str; int (*fn)(struct gitdiff_data *, const char *, struct patch *); @@ -1391,7 +1358,7 @@ static int parse_git_header(struct apply_state *state, res = p->fn(&parse_hdr_state, line + oplen, patch); if (res < 0) return -1; - if (check_header_line(state->linenr, patch)) + if (check_header_line(*linenr, patch)) return -1; if (res > 0) return offset; @@ -1572,7 +1539,9 @@ static int find_header(struct apply_state *state, * or mode change, so we handle that specially */ if (!memcmp("diff --git ", line, 11)) { - int git_hdr_len = parse_git_header(state, line, len, size, patch); + int git_hdr_len = parse_git_diff_header(&state->root, &state->linenr, + state->p_value, line, len, + size, patch); if (git_hdr_len < 0) return -128; if (git_hdr_len <= len) diff --git a/apply.h b/apply.h index 5948348133..a795193435 100644 --- a/apply.h +++ b/apply.h @@ -117,6 +117,40 @@ struct apply_state { int applied_after_fixing_ws; }; +/* + * This represents a "patch" to a file, both metainfo changes + * such as creation/deletion, filemode and content changes represented + * as a series of fragments. + */ +struct patch { + char *new_name, *old_name, *def_name; + unsigned int old_mode, new_mode; + int is_new, is_delete; /* -1 = unknown, 0 = false, 1 = true */ + int rejected; + unsigned ws_rule; + int lines_added, lines_deleted; + int score; + int extension_linenr; /* first line specifying delete/new/rename/copy */ + unsigned int is_toplevel_relative:1; + unsigned int inaccurate_eof:1; + unsigned int is_binary:1; + unsigned int is_copy:1; + unsigned int is_rename:1; + unsigned int recount:1; + unsigned int conflicted_threeway:1; + unsigned int direct_to_threeway:1; + unsigned int crlf_in_old:1; + struct fragment *fragments; + char *result; + size_t resultsize; + char old_oid_prefix[GIT_MAX_HEXSZ + 1]; + char new_oid_prefix[GIT_MAX_HEXSZ + 1]; + struct patch *next; + + /* three-way fallback result */ + struct object_id threeway_stage[3]; +}; + int apply_parse_options(int argc, const char **argv, struct apply_state *state, int *force_apply, int *options, @@ -127,6 +161,20 @@ int init_apply_state(struct apply_state *state, void clear_apply_state(struct apply_state *state); int check_apply_state(struct apply_state *state, int force_apply); +/* + * Parse a git diff header, starting at line. Fills the relevant + * metadata information in 'struct patch'. + * + * Returns -1 on failure, the length of the parsed header otherwise. + */ +int parse_git_diff_header(struct strbuf *root, + int *linenr, + int p_value, + const char *line, + int len, + unsigned int size, + struct patch *patch); + /* * Some aspects of the apply behavior are controlled by the following * bits in the "options" parameter passed to apply_all_patches(). From patchwork Thu Jul 11 16:08:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11040401 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 B48DD1805 for ; Thu, 11 Jul 2019 16:09:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A34E128AFC for ; Thu, 11 Jul 2019 16:09:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 971E228B0B; Thu, 11 Jul 2019 16:09:17 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 4D36528B03 for ; Thu, 11 Jul 2019 16:09:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728517AbfGKQJP (ORCPT ); Thu, 11 Jul 2019 12:09:15 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:55483 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728456AbfGKQJO (ORCPT ); Thu, 11 Jul 2019 12:09:14 -0400 Received: by mail-wm1-f66.google.com with SMTP id a15so6233920wmj.5 for ; Thu, 11 Jul 2019 09:09:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZK6F8I9MMRXb1nyoGtw4TkkqOifbnYF7o0+q1l/W/JM=; b=kAMbPj1JfZ8kzpL/Ffgo6M+wohD5b/767zojEW6hIEiiF2pJIr6xaXEpQEFHp3m6XK M5Pf/LiL2ZAIesvThja2d51QYPWQiyz4VXkDe+iVCSzuvNnqwOw8fE0+TMIch9CBX/SU JGY6j1C3cQt5wMI2SSzZJk/2sOUVhcKXx0wksnxiXfRg5+U6KaOsgdzKdveNWzmp7PHH nY8PPVhvgtpdxJnOADQ2EkfdD3QtzUOSmiPLBpU+LNkNkz/QhqpbpZlFaCk+j8si5rpQ r9Cvpe3L0to9tFLBnyDENup3N4nMoZ/HR7WTBVO6ji2awXOj7pAKuokLBo9mRDurjlX2 u8DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZK6F8I9MMRXb1nyoGtw4TkkqOifbnYF7o0+q1l/W/JM=; b=OleCviMNiHExroIhACChoM/lbSisXlXjk6QqrxE7l2wWZPo0B145fwI/SJNgeluU3c Gxy1B1jeEShsEpoFWbNtL3HZK+3aG2wRpuholHyR9thJfyEY7YwenpClpnMlcnGuBcKw qjcHdVJO6D5TGMesHRKY6YGobZFP4+JSsaOt5sGDNgKIhS1HSW7vw+tpb+1aa4qRHnF9 N5VimQ6FvM0ZAJJjS6jvcV/LlfPC1aRHNtqbFdD2QJcx8sa9b8QtwNlo+sTlQYuoVlUG QkjHqsoES85PU+qraoU11wQtJ4+/TkPOJTCNnajWJSyfoUCq1ye2XpfpKOJVffZwpZW0 EXpg== X-Gm-Message-State: APjAAAXGYhbpFDPaqiYVCKQgQZ5HgRmZDrMSVnCQCxC67pWXr7b0BaOj a8VrrnXE0muA6iGfJuJ1RbhVazrel0k= X-Google-Smtp-Source: APXvYqyUecXoSD+//bP7PvxPP9pCbb9zBtMBqGylG+SziJE8IwJkHh86IIYu/4nqupr09RXNuU7hLQ== X-Received: by 2002:a7b:c0c6:: with SMTP id s6mr5216790wmh.115.1562861352135; Thu, 11 Jul 2019 09:09:12 -0700 (PDT) Received: from localhost (host232-157-dynamic.24-79-r.retail.telecomitalia.it. [79.24.157.232]) by smtp.gmail.com with ESMTPSA id e7sm6208336wmd.0.2019.07.11.09.09.11 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 11 Jul 2019 09:09:11 -0700 (PDT) From: Thomas Gummerer To: git@vger.kernel.org Cc: Duy Nguyen , Johannes Schindelin , Junio C Hamano , Eric Sunshine , Johannes Sixt , Thomas Gummerer Subject: [PATCH v4 08/14] range-diff: fix function parameter indentation Date: Thu, 11 Jul 2019 17:08:45 +0100 Message-Id: <20190711160851.14380-9-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190711160851.14380-1-t.gummerer@gmail.com> References: <20190708163315.29912-1-t.gummerer@gmail.com> <20190711160851.14380-1-t.gummerer@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fix the indentation of the function parameters for a couple of functions, to match the style in the rest of the file. Signed-off-by: Thomas Gummerer --- range-diff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/range-diff.c b/range-diff.c index 48b0e1b4ce..9242b8975f 100644 --- a/range-diff.c +++ b/range-diff.c @@ -148,7 +148,7 @@ static int read_patches(const char *range, struct string_list *list) } static int patch_util_cmp(const void *dummy, const struct patch_util *a, - const struct patch_util *b, const char *keydata) + const struct patch_util *b, const char *keydata) { return strcmp(a->diff, keydata ? keydata : b->diff); } @@ -373,7 +373,7 @@ static struct diff_filespec *get_filespec(const char *name, const char *p) } static void patch_diff(const char *a, const char *b, - struct diff_options *diffopt) + struct diff_options *diffopt) { diff_queue(&diff_queued_diff, get_filespec("a", a), get_filespec("b", b)); From patchwork Thu Jul 11 16:08:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11040413 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 E30D7138B for ; Thu, 11 Jul 2019 16:09:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D17AE28A0F for ; Thu, 11 Jul 2019 16:09:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5FB528B03; Thu, 11 Jul 2019 16:09:21 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 4256C28A0F for ; Thu, 11 Jul 2019 16:09:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728549AbfGKQJT (ORCPT ); Thu, 11 Jul 2019 12:09:19 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:33029 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728469AbfGKQJQ (ORCPT ); Thu, 11 Jul 2019 12:09:16 -0400 Received: by mail-wr1-f66.google.com with SMTP id n9so6968950wru.0 for ; Thu, 11 Jul 2019 09:09:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ke93K8MCfZTOpFN6h+SvDkqgwsTG3sIHO4fNip/unDI=; b=R/YhK99PCrzsrshw+dPQYjHV4dzOO2AUBiG6O0+CvW5ontn8ch8luBoCZoYyLaeTvb 5RBy6DxRt8emyP9EH91gGPFWM87Qgrj9aNJUrWRFIxRHLnjLLjIiMmtZLP/j6CB31Dxe 8GMV44+W88dR2JsTNa51EM5lZnz2tSdIuDRS5bFEGpwMW0VmE/gckOdKM2qiv+SaaL2R FYO2x91k9p0vDz4MIKlCpiaVidK33D04mEdS0YqRpkyJ1myFCZYJpxeLadHXlqQp6sn9 hEuurS2Hbv1lm/HU5MNxsepvgcuirAH5aeNLsKU6KE734g2LRqHZ7mOGWrPu7llxpTIl anSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ke93K8MCfZTOpFN6h+SvDkqgwsTG3sIHO4fNip/unDI=; b=CNRWSawayn7rCFiOwfgofrIYlJMVjKUxRriM3l/YOE+4eoEfEdyMy9eC3tjYDJJKdg sHANihlZNHcFQ7Q9DPqu7VbEKxS1i/g7MJNbcQy1JJZcYZyZci8A0CjtvtwIWPwwiect 3ynCm9Ih2QdTHFDfgIOgEXFQzsbqRTfsIFc8pbVRvFYdaTpJ2oN4O2PiS956xicgowrV 1aK4zsfw8LnmN+4+HKrocBVlKjjgcb9b4YSeDVILCq+RtCj4qx10WDr8x1BRpasL6utI /8WTCHawde4vUeOcDbP5XmoA4FEOHDZTylv8otinviZphDxX94xRawxOufFTquifWbld CbbQ== X-Gm-Message-State: APjAAAWB4bN2AAMl7ELpbHY5knk5S/W57rBud+RUbdzCBcBq0328nlSr pUdi6mWs/mMnlzq9zu5FK4mlNTBSCmQ= X-Google-Smtp-Source: APXvYqxIV6OJN50clYb5b0xmmXK/wzSGr8gHh8r+tmDIsFZEgBvSTw8D+X4GFWvTW3a64KKdWuHKhA== X-Received: by 2002:a5d:438e:: with SMTP id i14mr2954218wrq.122.1562861354016; Thu, 11 Jul 2019 09:09:14 -0700 (PDT) Received: from localhost (host232-157-dynamic.24-79-r.retail.telecomitalia.it. [79.24.157.232]) by smtp.gmail.com with ESMTPSA id 17sm6192686wmx.47.2019.07.11.09.09.12 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 11 Jul 2019 09:09:13 -0700 (PDT) From: Thomas Gummerer To: git@vger.kernel.org Cc: Duy Nguyen , Johannes Schindelin , Junio C Hamano , Eric Sunshine , Johannes Sixt , Thomas Gummerer Subject: [PATCH v4 09/14] range-diff: split lines manually Date: Thu, 11 Jul 2019 17:08:46 +0100 Message-Id: <20190711160851.14380-10-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190711160851.14380-1-t.gummerer@gmail.com> References: <20190708163315.29912-1-t.gummerer@gmail.com> <20190711160851.14380-1-t.gummerer@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently range-diff uses the 'strbuf_getline()' function for doing its line by line processing. In a future patch we want to do parts of that parsing using the 'parse_git_diff_header()' function. That function does its own line by line reading of the input, and doesn't use strbufs. This doesn't match with how we do the line-by-line processing in range-diff currently. Switch range-diff to do our own line by line parsing, so we can re-use the 'parse_git_diff_header()' function later. Signed-off-by: Thomas Gummerer --- range-diff.c | 68 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 26 deletions(-) diff --git a/range-diff.c b/range-diff.c index 9242b8975f..784fac301b 100644 --- a/range-diff.c +++ b/range-diff.c @@ -24,6 +24,17 @@ struct patch_util { struct object_id oid; }; +static size_t find_end_of_line(char *buffer, unsigned long size) +{ + char *eol = memchr(buffer, '\n', size); + + if (!eol) + return size; + + *eol = '\0'; + return eol + 1 - buffer; +} + /* * Reads the patches into a string list, with the `util` field being populated * as struct object_id (will need to be free()d). @@ -31,10 +42,12 @@ struct patch_util { static int read_patches(const char *range, struct string_list *list) { struct child_process cp = CHILD_PROCESS_INIT; - FILE *in; - struct strbuf buf = STRBUF_INIT, line = STRBUF_INIT; + struct strbuf buf = STRBUF_INIT, contents = STRBUF_INIT; struct patch_util *util = NULL; int in_header = 1; + char *line; + int offset, len; + size_t size; argv_array_pushl(&cp.args, "log", "--no-color", "-p", "--no-merges", "--reverse", "--date-order", "--decorate=no", @@ -54,17 +67,20 @@ static int read_patches(const char *range, struct string_list *list) if (start_command(&cp)) return error_errno(_("could not start `log`")); - in = fdopen(cp.out, "r"); - if (!in) { + if (strbuf_read(&contents, cp.out, 0) < 0) { error_errno(_("could not read `log` output")); finish_command(&cp); return -1; } - while (strbuf_getline(&line, in) != EOF) { + line = contents.buf; + size = contents.len; + for (offset = 0; size > 0; offset += len, size -= len, line += len) { const char *p; - if (skip_prefix(line.buf, "commit ", &p)) { + len = find_end_of_line(line, size); + line[len - 1] = '\0'; + if (skip_prefix(line, "commit ", &p)) { if (util) { string_list_append(list, buf.buf)->util = util; strbuf_reset(&buf); @@ -75,8 +91,7 @@ static int read_patches(const char *range, struct string_list *list) free(util); string_list_clear(list, 1); strbuf_release(&buf); - strbuf_release(&line); - fclose(in); + strbuf_release(&contents); finish_command(&cp); return -1; } @@ -85,26 +100,28 @@ static int read_patches(const char *range, struct string_list *list) continue; } - if (starts_with(line.buf, "diff --git")) { + if (starts_with(line, "diff --git")) { in_header = 0; strbuf_addch(&buf, '\n'); if (!util->diff_offset) util->diff_offset = buf.len; strbuf_addch(&buf, ' '); - strbuf_addbuf(&buf, &line); + strbuf_addstr(&buf, line); } else if (in_header) { - if (starts_with(line.buf, "Author: ")) { - strbuf_addbuf(&buf, &line); + if (starts_with(line, "Author: ")) { + strbuf_addstr(&buf, line); strbuf_addstr(&buf, "\n\n"); - } else if (starts_with(line.buf, " ")) { - strbuf_rtrim(&line); - strbuf_addbuf(&buf, &line); + } else if (starts_with(line, " ")) { + p = line + len - 2; + while (isspace(*p) && p >= line) + p--; + strbuf_add(&buf, line, p - line + 1); strbuf_addch(&buf, '\n'); } continue; - } else if (starts_with(line.buf, "@@ ")) + } else if (starts_with(line, "@@ ")) strbuf_addstr(&buf, "@@"); - else if (!line.buf[0] || starts_with(line.buf, "index ")) + else if (!line[0] || starts_with(line, "index ")) /* * A completely blank (not ' \n', which is context) * line is not valid in a diff. We skip it @@ -117,25 +134,24 @@ static int read_patches(const char *range, struct string_list *list) * we are not interested. */ continue; - else if (line.buf[0] == '>') { + else if (line[0] == '>') { strbuf_addch(&buf, '+'); - strbuf_add(&buf, line.buf + 1, line.len - 1); - } else if (line.buf[0] == '<') { + strbuf_addstr(&buf, line + 1); + } else if (line[0] == '<') { strbuf_addch(&buf, '-'); - strbuf_add(&buf, line.buf + 1, line.len - 1); - } else if (line.buf[0] == '#') { + strbuf_addstr(&buf, line + 1); + } else if (line[0] == '#') { strbuf_addch(&buf, ' '); - strbuf_add(&buf, line.buf + 1, line.len - 1); + strbuf_addstr(&buf, line + 1); } else { strbuf_addch(&buf, ' '); - strbuf_addbuf(&buf, &line); + strbuf_addstr(&buf, line); } strbuf_addch(&buf, '\n'); util->diffsize++; } - fclose(in); - strbuf_release(&line); + strbuf_release(&contents); if (util) string_list_append(list, buf.buf)->util = util; From patchwork Thu Jul 11 16:08:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11040415 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 CE40B6C5 for ; Thu, 11 Jul 2019 16:09:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD3B728A0F for ; Thu, 11 Jul 2019 16:09:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B18ED28B03; Thu, 11 Jul 2019 16:09:22 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 53AB328A0F for ; Thu, 11 Jul 2019 16:09:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728553AbfGKQJU (ORCPT ); Thu, 11 Jul 2019 12:09:20 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:44911 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728456AbfGKQJS (ORCPT ); Thu, 11 Jul 2019 12:09:18 -0400 Received: by mail-wr1-f68.google.com with SMTP id p17so6896903wrf.11 for ; Thu, 11 Jul 2019 09:09:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=I66tsNV2uTuOAR7JVNCEJFP+b6dKf2BHOOpTBcnMnc0=; b=OA0Nbi4ciaCLCDprL5rBOe+CqHkucCDB5fCJootCsmcMsJd5gnoVld2wZYFhmNS1PZ NnG4/EiDtrRpXErcmuYca6ZNQi2d0mY226toI6vHNyz21CzjLl31pD6Aut6FINmJYQ9h Q6fFjEscWyKgb1/pQenNpfVwewWv2l4RXSgBPQ1wyoWRP1RwuS3drW71IwWeOxq/+Lba lo93ZyXESLVHjlvG3FRMMLaLtEYkXFrG/KQMDqGG4aWZTj/pcyNPngjL+PyaV1ZpRYtW 6+7EZ3G+AocjNKMwu2+yNIaiSZScZkFccnFGVte0N8ddf5FESv8CiWL77eUy3f8/ebE5 u8qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=I66tsNV2uTuOAR7JVNCEJFP+b6dKf2BHOOpTBcnMnc0=; b=cHJmj3G46/LXnnKbPV+Jtnj0kw8xEI42vUdFt5Xf8EBDfLQ7ZX+8w6XifT0WYsPwXP PuOL+n8NuXMuTy60fFSBVLrgG2J+R/BbzAqB1WwupaeNNgaffJzvwgtqqVmZE1EIIfL5 4qEdcIrutIJEc5aVfvkJENjm2RlGoDa09qvMz4U1zH6kj7xnp3uAZIowDqSPUpVOtZ1g eEK3w3T6UwUdS8/YsAfTs9lJiQa6WgWt+FzzXeMWAWd7AFIoIFdMHuOJFvJeAToMZ71F DVjQMCLVHvKcaUBZg2qbk1QgaggmkkwWB5PTT+InawYN5+cRCh9Mj4Ze/0J4us+O6ntx dBag== X-Gm-Message-State: APjAAAWzUtYA0kIZknq13d5oPmHswOVWczQgJst9aSgp3n7KEQl6MlEz 39zNzAmMCZQTec22BBRQOBlXHR3KF2c= X-Google-Smtp-Source: APXvYqwy1RylEONXB5rRhKKC9CP0C7M7KaWX45CSfNtzekCRXJhqZz3YircoCDHS+zI6CwC8ArLHTQ== X-Received: by 2002:adf:de10:: with SMTP id b16mr5790917wrm.296.1562861355999; Thu, 11 Jul 2019 09:09:15 -0700 (PDT) Received: from localhost (host232-157-dynamic.24-79-r.retail.telecomitalia.it. [79.24.157.232]) by smtp.gmail.com with ESMTPSA id r5sm6274233wmh.35.2019.07.11.09.09.14 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 11 Jul 2019 09:09:15 -0700 (PDT) From: Thomas Gummerer To: git@vger.kernel.org Cc: Duy Nguyen , Johannes Schindelin , Junio C Hamano , Eric Sunshine , Johannes Sixt , Thomas Gummerer Subject: [PATCH v4 10/14] range-diff: don't remove funcname from inner diff Date: Thu, 11 Jul 2019 17:08:47 +0100 Message-Id: <20190711160851.14380-11-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190711160851.14380-1-t.gummerer@gmail.com> References: <20190708163315.29912-1-t.gummerer@gmail.com> <20190711160851.14380-1-t.gummerer@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When postprocessing the inner diff in range-diff, we currently replace the whole hunk header line with just "@@". This matches how 'git tbdiff' used to handle hunk headers as well. Most likely this is being done because line numbers in the hunk header are not relevant without other changes. They can for example easily change if a range is rebased, and lines are added/removed before a change that we actually care about in our ranges. However it can still be useful to have the function name that 'git diff' extracts as additional context for the change. Note that it is not guaranteed that the hunk header actually shows up in the range-diff, and this change only aims to improve the case where a hunk header would already be included in the final output. Signed-off-by: Thomas Gummerer --- range-diff.c | 7 ++++--- t/t3206-range-diff.sh | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/range-diff.c b/range-diff.c index 784fac301b..a5202d8b6c 100644 --- a/range-diff.c +++ b/range-diff.c @@ -119,9 +119,10 @@ static int read_patches(const char *range, struct string_list *list) strbuf_addch(&buf, '\n'); } continue; - } else if (starts_with(line, "@@ ")) - strbuf_addstr(&buf, "@@"); - else if (!line[0] || starts_with(line, "index ")) + } else if (skip_prefix(line, "@@ ", &p)) { + p = strstr(p, "@@"); + strbuf_addstr(&buf, p ? p : "@@"); + } else if (!line[0] || starts_with(line, "index ")) /* * A completely blank (not ' \n', which is context) * line is not valid in a diff. We skip it diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh index 048feaf6dd..aebd4e3693 100755 --- a/t/t3206-range-diff.sh +++ b/t/t3206-range-diff.sh @@ -110,7 +110,7 @@ test_expect_success 'changed commit' ' 14 4: a63e992 ! 4: d966c5c s/12/B/ @@ -8,7 +8,7 @@ - @@ + @@ A 9 10 - B @@ -169,7 +169,7 @@ test_expect_success 'changed commit with sm config' ' 14 4: a63e992 ! 4: d966c5c s/12/B/ @@ -8,7 +8,7 @@ - @@ + @@ A 9 10 - B @@ -231,7 +231,7 @@ test_expect_success 'dual-coloring' ' : 14 :4: d966c5c ! 4: 8add5f1 s/12/B/ : @@ -8,7 +8,7 @@ - : @@ + : @@ A : 9 : 10 : - BB From patchwork Thu Jul 11 16:08:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11040419 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 517B3138B for ; Thu, 11 Jul 2019 16:09:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4173928A0F for ; Thu, 11 Jul 2019 16:09:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 35CDA28AFC; Thu, 11 Jul 2019 16:09:26 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 B4EDD28B05 for ; Thu, 11 Jul 2019 16:09:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728555AbfGKQJX (ORCPT ); Thu, 11 Jul 2019 12:09:23 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:34469 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728552AbfGKQJV (ORCPT ); Thu, 11 Jul 2019 12:09:21 -0400 Received: by mail-wr1-f68.google.com with SMTP id 31so6951535wrm.1 for ; Thu, 11 Jul 2019 09:09:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MBG8XPPKz8ibxbYni/vjeLuUiVvXX0RsyKnVNaocxMY=; b=mp5skgw7IPsRUntebd6QgFKZpmSxCBkQKj1JkmdM5jiy9rdwaPtHUR97k5PAmQSQyL Uc6gzBioBin2LSOYdPK8bEKQIUC8QdThMcNu6c4fNiOdJIkG8cDpPpXnQfNtbX+3EVak ZNGeN+vBODlBjL0PPy5W6jkTJyu7lXNszBHaM9b8doOi+CjQXtuv3Lv4ZSMmQX49s/bm a0FNlG8CvS6ByFlbY9h+j/wOP+Hg3zHXO22rEupcVwq86ZMo8I3PCpCyhElIWDGVTw9n Syl3BNttYhljwkWNQeR5REmL/ENnDE5xWLK6dLTq3nrYZT+NqgqtrrHfSJfH4R9dGSK7 0fHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MBG8XPPKz8ibxbYni/vjeLuUiVvXX0RsyKnVNaocxMY=; b=byJ2Ee6QewvfnF3smZL0Dd5fLId3RKhwgcMuh6YgBN4Y1plW0xiJb9hrn/N0cA+Ojv htjXFPqxt04lCj+nNjGyqDA2s8Jd11Z7QwmF9H3BCkjfxRa6xvV+nik6GdzJGPBBhKwy AUMsO5Jr3hSWk4HnjNNFUqdzgUdXuUzMDiHclG840Ev64FdDmY+VFk4sdD+z+Bi2sC9O voJe052lmupxbmQ5zpxaGFfuzO8w/aza6T7P6qxL/FLPaAsxIWln+ku9E9vRnI+mxgir EpMo/Hh8z2KUE+i1HMXtS06W9MMRyc6sje0+afTwGKqt7K8D/ypgs1Th2OBfrIIFVEl/ jQWw== X-Gm-Message-State: APjAAAXgyDXfC5Jrzby6RJrUUp21EQXHyX5Std9o4ICGpepgpm73XXl2 pWuJxRSpn+Gn4d7AHI6CGa2RhbCwlsc= X-Google-Smtp-Source: APXvYqy2fQKrDI+BUdu76Soi79sW/cQAgXspYBLow89mH3fv1co+kNfPlcIzZyfb04iZjUTB+ob48g== X-Received: by 2002:a5d:6205:: with SMTP id y5mr5754187wru.314.1562861357993; Thu, 11 Jul 2019 09:09:17 -0700 (PDT) Received: from localhost (host232-157-dynamic.24-79-r.retail.telecomitalia.it. [79.24.157.232]) by smtp.gmail.com with ESMTPSA id g8sm7152773wme.20.2019.07.11.09.09.16 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 11 Jul 2019 09:09:17 -0700 (PDT) From: Thomas Gummerer To: git@vger.kernel.org Cc: Duy Nguyen , Johannes Schindelin , Junio C Hamano , Eric Sunshine , Johannes Sixt , Thomas Gummerer Subject: [PATCH v4 11/14] range-diff: suppress line count in outer diff Date: Thu, 11 Jul 2019 17:08:48 +0100 Message-Id: <20190711160851.14380-12-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190711160851.14380-1-t.gummerer@gmail.com> References: <20190708163315.29912-1-t.gummerer@gmail.com> <20190711160851.14380-1-t.gummerer@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The line count in the outer diff's hunk headers of a range diff is not all that interesting. It merely shows how far along the inner diff are on both sides. That number is of no use for human readers, and range-diffs are not meant to be machine readable. In a subsequent commit we're going to add some more contextual information such as the filename corresponding to the diff to the hunk headers. Remove the unnecessary information, and just keep the "@@" to indicate that a new hunk of the outer diff is starting. Signed-off-by: Thomas Gummerer --- diff.c | 5 ++++- diff.h | 1 + range-diff.c | 1 + t/t3206-range-diff.sh | 16 ++++++++-------- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/diff.c b/diff.c index ec5c095199..9c28ff0a92 100644 --- a/diff.c +++ b/diff.c @@ -1672,7 +1672,10 @@ static void emit_hunk_header(struct emit_callback *ecbdata, if (ecbdata->opt->flags.dual_color_diffed_diffs) strbuf_addstr(&msgbuf, reverse); strbuf_addstr(&msgbuf, frag); - strbuf_add(&msgbuf, line, ep - line); + if (ecbdata->opt->flags.suppress_hunk_header_line_count) + strbuf_add(&msgbuf, atat, sizeof(atat)); + else + strbuf_add(&msgbuf, line, ep - line); strbuf_addstr(&msgbuf, reset); /* diff --git a/diff.h b/diff.h index c9db9825bb..49913049f9 100644 --- a/diff.h +++ b/diff.h @@ -98,6 +98,7 @@ struct diff_flags { unsigned stat_with_summary; unsigned suppress_diff_headers; unsigned dual_color_diffed_diffs; + unsigned suppress_hunk_header_line_count; }; static inline void diff_flags_or(struct diff_flags *a, diff --git a/range-diff.c b/range-diff.c index a5202d8b6c..f4a90b33b8 100644 --- a/range-diff.c +++ b/range-diff.c @@ -486,6 +486,7 @@ int show_range_diff(const char *range1, const char *range2, opts.output_format = DIFF_FORMAT_PATCH; opts.flags.suppress_diff_headers = 1; opts.flags.dual_color_diffed_diffs = dual_color; + opts.flags.suppress_hunk_header_line_count = 1; opts.output_prefix = output_prefix_cb; strbuf_addstr(&indent, " "); opts.output_prefix_data = &indent; diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh index aebd4e3693..9f89af7178 100755 --- a/t/t3206-range-diff.sh +++ b/t/t3206-range-diff.sh @@ -99,7 +99,7 @@ test_expect_success 'changed commit' ' 1: 4de457d = 1: a4b3333 s/5/A/ 2: fccce22 = 2: f51d370 s/4/A/ 3: 147e64e ! 3: 0559556 s/11/B/ - @@ -10,7 +10,7 @@ + @@ 9 10 -11 @@ -109,7 +109,7 @@ test_expect_success 'changed commit' ' 13 14 4: a63e992 ! 4: d966c5c s/12/B/ - @@ -8,7 +8,7 @@ + @@ @@ A 9 10 @@ -158,7 +158,7 @@ test_expect_success 'changed commit with sm config' ' 1: 4de457d = 1: a4b3333 s/5/A/ 2: fccce22 = 2: f51d370 s/4/A/ 3: 147e64e ! 3: 0559556 s/11/B/ - @@ -10,7 +10,7 @@ + @@ 9 10 -11 @@ -168,7 +168,7 @@ test_expect_success 'changed commit with sm config' ' 13 14 4: a63e992 ! 4: d966c5c s/12/B/ - @@ -8,7 +8,7 @@ + @@ @@ A 9 10 @@ -191,7 +191,7 @@ test_expect_success 'changed message' ' sed s/Z/\ /g >expected <<-EOF && 1: 4de457d = 1: f686024 s/5/A/ 2: fccce22 ! 2: 4ab067d s/4/A/ - @@ -2,6 +2,8 @@ + @@ Z Z s/4/A/ Z @@ -210,7 +210,7 @@ test_expect_success 'dual-coloring' ' sed -e "s|^:||" >expect <<-\EOF && :1: a4b3333 = 1: f686024 s/5/A/ :2: f51d370 ! 2: 4ab067d s/4/A/ - : @@ -2,6 +2,8 @@ + : @@ : : s/4/A/ : @@ -220,7 +220,7 @@ test_expect_success 'dual-coloring' ' : --- a/file : +++ b/file :3: 0559556 ! 3: b9cb956 s/11/B/ - : @@ -10,7 +10,7 @@ + : @@ : 9 : 10 : -11 @@ -230,7 +230,7 @@ test_expect_success 'dual-coloring' ' : 13 : 14 :4: d966c5c ! 4: 8add5f1 s/12/B/ - : @@ -8,7 +8,7 @@ + : @@ : @@ A : 9 : 10 From patchwork Thu Jul 11 16:08:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11040417 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 C17996C5 for ; Thu, 11 Jul 2019 16:09:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B108F28A0F for ; Thu, 11 Jul 2019 16:09:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A597B28B03; Thu, 11 Jul 2019 16:09:25 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 DC29D28A0F for ; Thu, 11 Jul 2019 16:09:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728563AbfGKQJX (ORCPT ); Thu, 11 Jul 2019 12:09:23 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:39601 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728554AbfGKQJW (ORCPT ); Thu, 11 Jul 2019 12:09:22 -0400 Received: by mail-wm1-f65.google.com with SMTP id z23so2041034wma.4 for ; Thu, 11 Jul 2019 09:09:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HIiDotHve9IS3xSWO+oP+cT/BF0N0P0ryS3crNa3M7E=; b=MqXVA61vwS9NhWy2/1/P15UG+cnO2ds7ldR/e8KwGK0FL8VPcO40N/YV4a1wvlJqSe lEBI8wuUq7jCIq7aSSapgLewUzE2DWkAr7lMqstjmeaL1FpyBNUfVQEBo1SMPgGwB1CK 4EiiSvTxqGzo9kLFaQLMRez6MvwSzxOCbbX3kjHVjTv+jBSv2lDYb5YkEWRxxfOGMVmw LlXdvEjPtUtVFIrk1Q20s97+ggVP+o2KZkChX+MViWiJF4eNXa3ppon5/C2F3i9wUdBR BgZIn/TnuEOiipXaGdHlNzC5BcITK4yFhfK6XceNH2ZkyzT6r4kl54T1x2HUHdMFLRW7 OYFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HIiDotHve9IS3xSWO+oP+cT/BF0N0P0ryS3crNa3M7E=; b=ql3XktmICIzo/sllfgdJHhviExjOnrDIoo9cUjZM1yygiOoY5psPlNAeL11wBF3W/f aa2tpqqzoVCeeHqF1XDRBgqVpNAeY49reQO47MhGrbB89iG2y8qKr+LbPISmSaGy/JDf 5NqSTYoMtoDwjRyX0B+/p/Du4LxfD2Udyj+uSCZuqYjTf3+FH5+GuLZ4sDsIgyTjqgqf UjaH8u9GZbTmCzpBfuY9rAbzcoZ+vMD3BatQRcGj0qB+kbqGOc3UFviuJikDkO1ZBxSb 1Lm1inQh06pfOf4ewoca6ZHsdUzQiBzgnB2kyHiaJTHBxjOLRUXaHuoLygn2POFMrAsE wxMw== X-Gm-Message-State: APjAAAV/UAdkuYpBiAp0AMDwOKAP54wmrxmANP1G/w7RSA1OCXlgEkxW jNpZIgoSBNeoLC+MudlsTOUqcVGNRjU= X-Google-Smtp-Source: APXvYqw2BrQSwjK6lMhmx54MqBhXE4dOStn755gR0fy6JlxDU9woL7q0IZ/omsYpFx1hH7nzR7djrg== X-Received: by 2002:a7b:c202:: with SMTP id x2mr4773805wmi.49.1562861359993; Thu, 11 Jul 2019 09:09:19 -0700 (PDT) Received: from localhost (host232-157-dynamic.24-79-r.retail.telecomitalia.it. [79.24.157.232]) by smtp.gmail.com with ESMTPSA id f70sm6300750wme.22.2019.07.11.09.09.18 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 11 Jul 2019 09:09:19 -0700 (PDT) From: Thomas Gummerer To: git@vger.kernel.org Cc: Duy Nguyen , Johannes Schindelin , Junio C Hamano , Eric Sunshine , Johannes Sixt , Thomas Gummerer Subject: [PATCH v4 12/14] range-diff: add section header instead of diff header Date: Thu, 11 Jul 2019 17:08:49 +0100 Message-Id: <20190711160851.14380-13-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190711160851.14380-1-t.gummerer@gmail.com> References: <20190708163315.29912-1-t.gummerer@gmail.com> <20190711160851.14380-1-t.gummerer@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently range-diff keeps the diff header of the inner diff intact (apart from stripping lines starting with index). This diff header is somewhat useful, especially when files get different names in different ranges. However there is no real need to keep the whole diff header for that. The main reason we currently do that is probably because it is easy to do. Introduce a new range diff hunk header, that's enclosed by "##", similar to how line numbers in diff hunks are enclosed by "@@", and give human readable information of what exactly happened to the file, including the file name. This improves the readability of the range-diff by giving more concise information to the users. For example if a file was renamed in one iteration, but not in another, the diff of the headers would be quite noisy. However the diff of a single line is concise and should be easier to understand. Additionally, this allows us to add these range diff section headers to the outer diffs hunk headers using a custom userdiff pattern, which should help making the range-diff more readable. Signed-off-by: Thomas Gummerer --- range-diff.c | 34 ++++++++++++---- t/t3206-range-diff.sh | 91 +++++++++++++++++++++++++++++++++++++++--- t/t3206/history.export | 84 ++++++++++++++++++++++++++++++++++++-- 3 files changed, 192 insertions(+), 17 deletions(-) diff --git a/range-diff.c b/range-diff.c index f4a90b33b8..5f64380fe4 100644 --- a/range-diff.c +++ b/range-diff.c @@ -10,6 +10,7 @@ #include "commit.h" #include "pretty.h" #include "userdiff.h" +#include "apply.h" struct patch_util { /* For the search for an exact match */ @@ -101,12 +102,35 @@ static int read_patches(const char *range, struct string_list *list) } if (starts_with(line, "diff --git")) { + struct patch patch = { 0 }; + struct strbuf root = STRBUF_INIT; + int linenr = 0; + in_header = 0; strbuf_addch(&buf, '\n'); if (!util->diff_offset) util->diff_offset = buf.len; - strbuf_addch(&buf, ' '); - strbuf_addstr(&buf, line); + line[len - 1] = '\n'; + len = parse_git_diff_header(&root, &linenr, 1, line, + len, size, &patch); + if (len < 0) + die(_("could not parse git header '%.*s'"), (int)len, line); + strbuf_addstr(&buf, " ## "); + if (patch.is_new > 0) + strbuf_addf(&buf, "%s (new)", patch.new_name); + else if (patch.is_delete > 0) + strbuf_addf(&buf, "%s (deleted)", patch.old_name); + else if (patch.is_rename) + strbuf_addf(&buf, "%s => %s", patch.old_name, patch.new_name); + else + strbuf_addstr(&buf, patch.new_name); + + if (patch.new_mode && patch.old_mode && + patch.old_mode != patch.new_mode) + strbuf_addf(&buf, " (mode change %06o => %06o)", + patch.old_mode, patch.new_mode); + + strbuf_addstr(&buf, " ##"); } else if (in_header) { if (starts_with(line, "Author: ")) { strbuf_addstr(&buf, line); @@ -122,17 +146,13 @@ static int read_patches(const char *range, struct string_list *list) } else if (skip_prefix(line, "@@ ", &p)) { p = strstr(p, "@@"); strbuf_addstr(&buf, p ? p : "@@"); - } else if (!line[0] || starts_with(line, "index ")) + } else if (!line[0]) /* * A completely blank (not ' \n', which is context) * line is not valid in a diff. We skip it * silently, because this neatly handles the blank * separator line between commits in git-log * output. - * - * We also want to ignore the diff's `index` lines - * because they contain exact blob hashes in which - * we are not interested. */ continue; else if (line[0] == '>') { diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh index 9f89af7178..c277756057 100755 --- a/t/t3206-range-diff.sh +++ b/t/t3206-range-diff.sh @@ -181,6 +181,85 @@ test_expect_success 'changed commit with sm config' ' test_cmp expected actual ' +test_expect_success 'renamed file' ' + git range-diff --no-color --submodule=log topic...renamed-file >actual && + sed s/Z/\ /g >expected <<-EOF && + 1: 4de457d = 1: f258d75 s/5/A/ + 2: fccce22 ! 2: 017b62d s/4/A/ + @@ + ZAuthor: Thomas Rast + Z + - s/4/A/ + + s/4/A/ + rename file + Z + - ## file ## + + ## file => renamed-file ## + Z@@ + Z 1 + Z 2 + 3: 147e64e ! 3: 3ce7af6 s/11/B/ + @@ + Z + Z s/11/B/ + Z + - ## file ## + + ## renamed-file ## + Z@@ A + Z 8 + Z 9 + 4: a63e992 ! 4: 1e6226b s/12/B/ + @@ + Z + Z s/12/B/ + Z + - ## file ## + + ## renamed-file ## + Z@@ A + Z 9 + Z 10 + EOF + test_cmp expected actual +' + +test_expect_success 'file added and later removed' ' + git range-diff --no-color --submodule=log topic...added-removed >actual && + sed s/Z/\ /g >expected <<-EOF && + 1: 4de457d = 1: 096b1ba s/5/A/ + 2: fccce22 ! 2: d92e698 s/4/A/ + @@ + ZAuthor: Thomas Rast + Z + - s/4/A/ + + s/4/A/ + new-file + Z + Z ## file ## + Z@@ + @@ + Z A + Z 6 + Z 7 + + + + ## new-file (new) ## + 3: 147e64e ! 3: 9a1db4d s/11/B/ + @@ + ZAuthor: Thomas Rast + Z + - s/11/B/ + + s/11/B/ + remove file + Z + Z ## file ## + Z@@ A + @@ + Z 12 + Z 13 + Z 14 + + + + ## new-file (deleted) ## + 4: a63e992 = 4: fea3b5c s/12/B/ + EOF + test_cmp expected actual +' + test_expect_success 'no commits on one side' ' git commit --amend -m "new message" && git range-diff master HEAD@{1} HEAD @@ -197,9 +276,9 @@ test_expect_success 'changed message' ' Z + Also a silly comment here! + - Z diff --git a/file b/file - Z --- a/file - Z +++ b/file + Z ## file ## + Z@@ + Z 1 3: 147e64e = 3: b9cb956 s/11/B/ 4: a63e992 = 4: 8add5f1 s/12/B/ EOF @@ -216,9 +295,9 @@ test_expect_success 'dual-coloring' ' : : + Also a silly comment here! : + - : diff --git a/file b/file - : --- a/file - : +++ b/file + : ## file ## + : @@ + : 1 :3: 0559556 ! 3: b9cb956 s/11/B/ : @@ : 9 diff --git a/t/t3206/history.export b/t/t3206/history.export index b8ffff0940..7bb3814962 100644 --- a/t/t3206/history.export +++ b/t/t3206/history.export @@ -22,8 +22,8 @@ data 51 19 20 -reset refs/heads/removed -commit refs/heads/removed +reset refs/heads/renamed-file +commit refs/heads/renamed-file mark :2 author Thomas Rast 1374424921 +0200 committer Thomas Rast 1374484724 +0200 @@ -599,6 +599,82 @@ s/12/B/ from :46 M 100644 :28 file -reset refs/heads/removed -from :47 +commit refs/heads/added-removed +mark :48 +author Thomas Rast 1374485014 +0200 +committer Thomas Gummerer 1556574151 +0100 +data 7 +s/5/A/ +from :2 +M 100644 :3 file + +blob +mark :49 +data 0 + +commit refs/heads/added-removed +mark :50 +author Thomas Rast 1374485024 +0200 +committer Thomas Gummerer 1556574177 +0100 +data 18 +s/4/A/ + new-file +from :48 +M 100644 :5 file +M 100644 :49 new-file + +commit refs/heads/added-removed +mark :51 +author Thomas Rast 1374485036 +0200 +committer Thomas Gummerer 1556574177 +0100 +data 22 +s/11/B/ + remove file +from :50 +M 100644 :7 file +D new-file + +commit refs/heads/added-removed +mark :52 +author Thomas Rast 1374485044 +0200 +committer Thomas Gummerer 1556574177 +0100 +data 8 +s/12/B/ +from :51 +M 100644 :9 file + +commit refs/heads/renamed-file +mark :53 +author Thomas Rast 1374485014 +0200 +committer Thomas Gummerer 1556574309 +0100 +data 7 +s/5/A/ +from :2 +M 100644 :3 file + +commit refs/heads/renamed-file +mark :54 +author Thomas Rast 1374485024 +0200 +committer Thomas Gummerer 1556574312 +0100 +data 21 +s/4/A/ + rename file +from :53 +D file +M 100644 :5 renamed-file + +commit refs/heads/renamed-file +mark :55 +author Thomas Rast 1374485036 +0200 +committer Thomas Gummerer 1556574319 +0100 +data 8 +s/11/B/ +from :54 +M 100644 :7 renamed-file + +commit refs/heads/renamed-file +mark :56 +author Thomas Rast 1374485044 +0200 +committer Thomas Gummerer 1556574319 +0100 +data 8 +s/12/B/ +from :55 +M 100644 :9 renamed-file From patchwork Thu Jul 11 16:08:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11040421 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 70D28138B for ; Thu, 11 Jul 2019 16:09:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60B4628A0F for ; Thu, 11 Jul 2019 16:09:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 553A628B03; Thu, 11 Jul 2019 16:09:28 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 D8A7328A0F for ; Thu, 11 Jul 2019 16:09:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728574AbfGKQJZ (ORCPT ); Thu, 11 Jul 2019 12:09:25 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33045 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728456AbfGKQJY (ORCPT ); Thu, 11 Jul 2019 12:09:24 -0400 Received: by mail-wr1-f65.google.com with SMTP id n9so6969401wru.0 for ; Thu, 11 Jul 2019 09:09:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=udrGBbeDOfJexYXQeYvgplKe+0XhIyUM+81mT/hCb/k=; b=Y8klEKFTFbZBRYbtzAlJHZ/sVhwAqTHhGRK54uqH13UtcdEotjITefPxxQJJsPEy/Y 3L3VfHSakxmyUs2aND3raGAl3xflql3dQiKzf+92zfsyKUZVesIFGvGPz+WEYC/gZiSd S+wMUiv3k2WxWgy1aZjEKw8zIkSpLabltA0Es+PQc1+GO1fsjq0pfWArusFtTK3B+4y+ xQCAw0pflkOTHALh5vD2cUwQHJwZnkVCPWunGj9LQr1jawm2agRArO+glVQEVvH4cpYG 7ahEOm0Y9B9c4u7x0NfTg+T/PCpe/VcZKDQWFy4XPRovXwK5mnv42wcsqcIZ126dicZg 1D+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=udrGBbeDOfJexYXQeYvgplKe+0XhIyUM+81mT/hCb/k=; b=XVK14y51GEXSBd4Xa50CAmE4UdKkdO9Ie2CUyWw11H1xNmyW0krDr9Aoqu/p9qfWax EA7ar1byjgaPRwpn027SspNx/YXadrusHNPmwAqgbe62qX9h9hR2ilek7V+NdKOWFDGV RAMhxemypiuKVukgHa+X+ZM2E+ddYFsS9d7DRZIoINetiwWCiLSXle5HLwuC9j103zKe fYMB6agYLqHv7VjVHjq5l7t1GFYffb3FZsm6kJ4V0kFlvFH58xOakcmXwjJ/1E+4NbnO W7ulHoCyP4lz+5zDXL8kux028M3EOteS2y6NKxHxRrXZxkP8wmb6dhrub8ZPDQYStBNQ GqUQ== X-Gm-Message-State: APjAAAVLf4TWDRl/QdR12+WHIAmtFvMaEMWHzZ6ZOHFcZ7VWKHrDJlQ6 QBJg7hKYE6gk+XJru1Ji0GiqdTsSZ2Q= X-Google-Smtp-Source: APXvYqz4CWXjsjIDsqH2on43ukpjuhR3mHHqKTXe0gCjwbg2iuEninimLC5Us4SahvGbSAjo8byydg== X-Received: by 2002:a05:6000:14b:: with SMTP id r11mr6040583wrx.196.1562861362299; Thu, 11 Jul 2019 09:09:22 -0700 (PDT) Received: from localhost (host232-157-dynamic.24-79-r.retail.telecomitalia.it. [79.24.157.232]) by smtp.gmail.com with ESMTPSA id y12sm3549237wrm.79.2019.07.11.09.09.20 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 11 Jul 2019 09:09:21 -0700 (PDT) From: Thomas Gummerer To: git@vger.kernel.org Cc: Duy Nguyen , Johannes Schindelin , Junio C Hamano , Eric Sunshine , Johannes Sixt , Thomas Gummerer Subject: [PATCH v4 13/14] range-diff: add filename to inner diff Date: Thu, 11 Jul 2019 17:08:50 +0100 Message-Id: <20190711160851.14380-14-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190711160851.14380-1-t.gummerer@gmail.com> References: <20190708163315.29912-1-t.gummerer@gmail.com> <20190711160851.14380-1-t.gummerer@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In a range-diff it's not always clear which file a certain funcname of the inner diff belongs to, because the diff header (or section header as added in a previous commit) is not always visible in the range-diff. Add the filename to the inner diffs header, so it's always visible to users. This also allows us to add the filename + the funcname to the outer diffs hunk headers using a custom userdiff pattern, which will be done in the next commit. Signed-off-by: Thomas Gummerer --- range-diff.c | 15 +++++++++++++-- t/t3206-range-diff.sh | 16 ++++++++++------ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/range-diff.c b/range-diff.c index 5f64380fe4..7a96a587f1 100644 --- a/range-diff.c +++ b/range-diff.c @@ -46,7 +46,7 @@ static int read_patches(const char *range, struct string_list *list) struct strbuf buf = STRBUF_INIT, contents = STRBUF_INIT; struct patch_util *util = NULL; int in_header = 1; - char *line; + char *line, *current_filename = NULL; int offset, len; size_t size; @@ -125,6 +125,12 @@ static int read_patches(const char *range, struct string_list *list) else strbuf_addstr(&buf, patch.new_name); + free(current_filename); + if (patch.is_delete > 0) + current_filename = xstrdup(patch.old_name); + else + current_filename = xstrdup(patch.new_name); + if (patch.new_mode && patch.old_mode && patch.old_mode != patch.new_mode) strbuf_addf(&buf, " (mode change %06o => %06o)", @@ -145,7 +151,11 @@ static int read_patches(const char *range, struct string_list *list) continue; } else if (skip_prefix(line, "@@ ", &p)) { p = strstr(p, "@@"); - strbuf_addstr(&buf, p ? p : "@@"); + strbuf_addstr(&buf, "@@"); + if (current_filename && p[2]) + strbuf_addf(&buf, " %s:", current_filename); + if (p) + strbuf_addstr(&buf, p + 2); } else if (!line[0]) /* * A completely blank (not ' \n', which is context) @@ -177,6 +187,7 @@ static int read_patches(const char *range, struct string_list *list) if (util) string_list_append(list, buf.buf)->util = util; strbuf_release(&buf); + free(current_filename); if (finish_command(&cp)) return -1; diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh index c277756057..d4de270979 100755 --- a/t/t3206-range-diff.sh +++ b/t/t3206-range-diff.sh @@ -110,7 +110,7 @@ test_expect_success 'changed commit' ' 14 4: a63e992 ! 4: d966c5c s/12/B/ @@ - @@ A + @@ file: A 9 10 - B @@ -169,7 +169,7 @@ test_expect_success 'changed commit with sm config' ' 14 4: a63e992 ! 4: d966c5c s/12/B/ @@ - @@ A + @@ file: A 9 10 - B @@ -203,20 +203,24 @@ test_expect_success 'renamed file' ' Z s/11/B/ Z - ## file ## + -@@ file: A + ## renamed-file ## - Z@@ A + +@@ renamed-file: A Z 8 Z 9 + Z 10 4: a63e992 ! 4: 1e6226b s/12/B/ @@ Z Z s/12/B/ Z - ## file ## + -@@ file: A + ## renamed-file ## - Z@@ A + +@@ renamed-file: A Z 9 Z 10 + Z B EOF test_cmp expected actual ' @@ -248,7 +252,7 @@ test_expect_success 'file added and later removed' ' + s/11/B/ + remove file Z Z ## file ## - Z@@ A + Z@@ file: A @@ Z 12 Z 13 @@ -310,7 +314,7 @@ test_expect_success 'dual-coloring' ' : 14 :4: d966c5c ! 4: 8add5f1 s/12/B/ : @@ - : @@ A + : @@ file: A : 9 : 10 : - BB From patchwork Thu Jul 11 16:08:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11040423 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 01C756C5 for ; Thu, 11 Jul 2019 16:09:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E440828A0F for ; Thu, 11 Jul 2019 16:09:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D89AB28B03; Thu, 11 Jul 2019 16:09:29 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 49A1E28A0F for ; Thu, 11 Jul 2019 16:09:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728588AbfGKQJ2 (ORCPT ); Thu, 11 Jul 2019 12:09:28 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:44929 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728571AbfGKQJ0 (ORCPT ); Thu, 11 Jul 2019 12:09:26 -0400 Received: by mail-wr1-f67.google.com with SMTP id p17so6897432wrf.11 for ; Thu, 11 Jul 2019 09:09:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zoIqHKw3zDEACzwLd448WaYWaae1CraA0g3v4j0IPiY=; b=bFTvw/dyhkdir0Kn5YN0POj5ELryPqAVxqYzL+mcv4uw9wOvTrwRcCMm8WYigRedn6 ywT/gXhMuSJ4KQSDB8nfXV2LjCVJdot4hPOpAkZpAgu+nrgkkkcU8bpM3pWxdCZifVjs FTRPH6A5DuwaRY1cZUZZVKan99Mi2hwfb6Gi3ZEyYlf+BlE73DtiVHKd72KvpQQFsOn+ +yd3MzSlzh2s4sosDVZtGLwZW3BbTq+XIDpUgo9qU05eU7r/VYqd3UAcTfqAOm8f7JcS t4qiMl2YBBPt/muIuxdPke7e0Pf+l6ni9J2wQahPdlvQdnfnJTScd6BEwRpyFjsAv6/a c+eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zoIqHKw3zDEACzwLd448WaYWaae1CraA0g3v4j0IPiY=; b=MmgX2zXwCK58NrWHGhwMPWdyhEQdB1D+608o0+8j32DntGuKMoPDJMkqoMmPW9PuqE uj6nK7H+wHNjjCFuayOxLPQUpdf8driRmXKQTIbcRfhnXFEDpKAG8T2Gqb3Z/bVicRAm jeUG3mffRjjzOqDajtJXqAB13FC1SzQ+/7qEttdAhaY4j5xw2d5ZtATWU2/MMXhubslK ZfTBqhGE+a9AVDLTQLfe3gFwjeXiKEv2kMBa9R65vVFT8EF2ytxgzE9Bo9d1cbW64trl WyenzYgIEfnJIcmbnAHXSeaNsxPkLBiYYIJMbQmEdjBjpQhHTsIBokOPV6DDpUPm2lCS CZ1Q== X-Gm-Message-State: APjAAAWPDcwLUUKGRM9da6Asj1mSyJZ4HkgshknqgfllLAVl2yShrcOW LsDXxGaq0HsxRmVYEybmAZkIrIaNjo4= X-Google-Smtp-Source: APXvYqzX5nGvQCPNQB1aECIsBp+QGMv2Ol9ubtu6bXW/Ww+2ONxsA6K0xg/3e22X5Vbf1M6q8KsVhQ== X-Received: by 2002:adf:afe7:: with SMTP id y39mr5878274wrd.350.1562861364191; Thu, 11 Jul 2019 09:09:24 -0700 (PDT) Received: from localhost (host232-157-dynamic.24-79-r.retail.telecomitalia.it. [79.24.157.232]) by smtp.gmail.com with ESMTPSA id u6sm7805911wml.9.2019.07.11.09.09.23 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 11 Jul 2019 09:09:23 -0700 (PDT) From: Thomas Gummerer To: git@vger.kernel.org Cc: Duy Nguyen , Johannes Schindelin , Junio C Hamano , Eric Sunshine , Johannes Sixt , Thomas Gummerer Subject: [PATCH v4 14/14] range-diff: add headers to the outer hunk header Date: Thu, 11 Jul 2019 17:08:51 +0100 Message-Id: <20190711160851.14380-15-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190711160851.14380-1-t.gummerer@gmail.com> References: <20190708163315.29912-1-t.gummerer@gmail.com> <20190711160851.14380-1-t.gummerer@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add the section headers/hunk headers we introduced in the previous commits to the outer diff's hunk headers. This makes it easier to understand which change we are actually looking at. For example an outer hunk header might now look like: @@ Documentation/config/interactive.txt while previously it would have only been @@ which doesn't give a lot of context for the change that follows. For completeness also add section headers for the commit metadata and the commit message, although they are arguably less important. Signed-off-by: Thomas Gummerer --- range-diff.c | 9 ++++++--- t/t3206-range-diff.sh | 41 ++++++++++++++++++++++------------------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/range-diff.c b/range-diff.c index 7a96a587f1..ba1e9a4265 100644 --- a/range-diff.c +++ b/range-diff.c @@ -139,8 +139,10 @@ static int read_patches(const char *range, struct string_list *list) strbuf_addstr(&buf, " ##"); } else if (in_header) { if (starts_with(line, "Author: ")) { + strbuf_addstr(&buf, " ## Metadata ##\n"); strbuf_addstr(&buf, line); strbuf_addstr(&buf, "\n\n"); + strbuf_addstr(&buf, " ## Commit message ##\n"); } else if (starts_with(line, " ")) { p = line + len - 2; while (isspace(*p) && p >= line) @@ -402,8 +404,9 @@ static void output_pair_header(struct diff_options *diffopt, fwrite(buf->buf, buf->len, 1, diffopt->file); } -static struct userdiff_driver no_func_name = { - .funcname = { "$^", 0 } +static struct userdiff_driver section_headers = { + .funcname = { "^ ## (.*) ##$\n" + "^.?@@ (.*)$", REG_EXTENDED } }; static struct diff_filespec *get_filespec(const char *name, const char *p) @@ -415,7 +418,7 @@ static struct diff_filespec *get_filespec(const char *name, const char *p) spec->size = strlen(p); spec->should_munmap = 0; spec->is_stdin = 1; - spec->driver = &no_func_name; + spec->driver = §ion_headers; return spec; } diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh index d4de270979..ec548654ce 100755 --- a/t/t3206-range-diff.sh +++ b/t/t3206-range-diff.sh @@ -99,7 +99,7 @@ test_expect_success 'changed commit' ' 1: 4de457d = 1: a4b3333 s/5/A/ 2: fccce22 = 2: f51d370 s/4/A/ 3: 147e64e ! 3: 0559556 s/11/B/ - @@ + @@ file: A 9 10 -11 @@ -109,7 +109,7 @@ test_expect_success 'changed commit' ' 13 14 4: a63e992 ! 4: d966c5c s/12/B/ - @@ + @@ file @@ file: A 9 10 @@ -158,7 +158,7 @@ test_expect_success 'changed commit with sm config' ' 1: 4de457d = 1: a4b3333 s/5/A/ 2: fccce22 = 2: f51d370 s/4/A/ 3: 147e64e ! 3: 0559556 s/11/B/ - @@ + @@ file: A 9 10 -11 @@ -168,7 +168,7 @@ test_expect_success 'changed commit with sm config' ' 13 14 4: a63e992 ! 4: d966c5c s/12/B/ - @@ + @@ file @@ file: A 9 10 @@ -186,9 +186,10 @@ test_expect_success 'renamed file' ' sed s/Z/\ /g >expected <<-EOF && 1: 4de457d = 1: f258d75 s/5/A/ 2: fccce22 ! 2: 017b62d s/4/A/ - @@ + @@ Metadata ZAuthor: Thomas Rast Z + Z ## Commit message ## - s/4/A/ + s/4/A/ + rename file Z @@ -198,8 +199,8 @@ test_expect_success 'renamed file' ' Z 1 Z 2 3: 147e64e ! 3: 3ce7af6 s/11/B/ - @@ - Z + @@ Metadata + Z ## Commit message ## Z s/11/B/ Z - ## file ## @@ -210,8 +211,8 @@ test_expect_success 'renamed file' ' Z 9 Z 10 4: a63e992 ! 4: 1e6226b s/12/B/ - @@ - Z + @@ Metadata + Z ## Commit message ## Z s/12/B/ Z - ## file ## @@ -230,30 +231,32 @@ test_expect_success 'file added and later removed' ' sed s/Z/\ /g >expected <<-EOF && 1: 4de457d = 1: 096b1ba s/5/A/ 2: fccce22 ! 2: d92e698 s/4/A/ - @@ + @@ Metadata ZAuthor: Thomas Rast Z + Z ## Commit message ## - s/4/A/ + s/4/A/ + new-file Z Z ## file ## Z@@ - @@ + @@ file Z A Z 6 Z 7 + + ## new-file (new) ## 3: 147e64e ! 3: 9a1db4d s/11/B/ - @@ + @@ Metadata ZAuthor: Thomas Rast Z + Z ## Commit message ## - s/11/B/ + s/11/B/ + remove file Z Z ## file ## Z@@ file: A - @@ + @@ file: A Z 12 Z 13 Z 14 @@ -274,8 +277,8 @@ test_expect_success 'changed message' ' sed s/Z/\ /g >expected <<-EOF && 1: 4de457d = 1: f686024 s/5/A/ 2: fccce22 ! 2: 4ab067d s/4/A/ - @@ - Z + @@ Metadata + Z ## Commit message ## Z s/4/A/ Z + Also a silly comment here! @@ -293,8 +296,8 @@ test_expect_success 'dual-coloring' ' sed -e "s|^:||" >expect <<-\EOF && :1: a4b3333 = 1: f686024 s/5/A/ :2: f51d370 ! 2: 4ab067d s/4/A/ - : @@ - : + : @@ Metadata + : ## Commit message ## : s/4/A/ : : + Also a silly comment here! @@ -303,7 +306,7 @@ test_expect_success 'dual-coloring' ' : @@ : 1 :3: 0559556 ! 3: b9cb956 s/11/B/ - : @@ + : @@ file: A : 9 : 10 : -11 @@ -313,7 +316,7 @@ test_expect_success 'dual-coloring' ' : 13 : 14 :4: d966c5c ! 4: 8add5f1 s/12/B/ - : @@ + : @@ file : @@ file: A : 9 : 10