From patchwork Fri Jul 5 17:06:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11033075 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 C8D08112C for ; Fri, 5 Jul 2019 17:06:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B195528A4A for ; Fri, 5 Jul 2019 17:06:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A595F28AA0; Fri, 5 Jul 2019 17:06:57 +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 4226A28A4A for ; Fri, 5 Jul 2019 17:06:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727266AbfGERG4 (ORCPT ); Fri, 5 Jul 2019 13:06:56 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:45446 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727190AbfGERGz (ORCPT ); Fri, 5 Jul 2019 13:06:55 -0400 Received: by mail-wr1-f65.google.com with SMTP id f9so10586165wre.12 for ; Fri, 05 Jul 2019 10:06:54 -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=WIgjTdizL9iGzHSW+cnUg8yZlxh6CAkfEGEpz9UcWB1VAhsUZDocNjDVZJIID2ySGm KmmZP1Ynv7KMHF9d5NOOkAcfKNG5RTA8cxymotqHtBX50hs63vrDO1eR+yHCvYP3FZf8 SzC6wri1xRMDdACeY5qN1EULeWqYIiSdD6S7m2lnI54+3FEtcxRP9uGN/xQ4nq+LRi/Y gfD1QiKsNBTn3/ZHp6m+ZLtb2ltS4oYf5ZkKdRKdWAzqpvTWe/FDa5evrj/h8QGbEW2r iefgVfNeB9Gb2lHqbJvnco+sG/rMnD8NJNwkt439EVLeWOQdsLsHo84hzvBdKAvw0Orj 5KKA== 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=BuLLgRsBDCtRgBNwTnbv7knsgYBv3dhBQrVtGd+2kL19rgmHDXOgBE0SWFEs1EJ/m4 dnRlPVpDGaHn/At/mt7AQzWPd7KWkBELXvtDWJnhGPiISZdn6qHrt8EZoaDfOaWE0COc /XIuiufkr4C/ig9UdUVQyKmowvUAV5Ow+wEXV/jkXV6123KojK/OW1m92O1CjSTdXqg+ vYe8G97Xkw6GSx2wX37ewycRjz5TAjHadx5ZqoHq8brbDQ5NWehb4TeOUNhn2yc4uHld nuahWvjeefQNaLIMJGQXNQuh2Ft5YWncfuFiu2I4YBtI2VM/n2snkNfqzl6UO+yAcoxs cVsg== X-Gm-Message-State: APjAAAV3jWXu0Bp+ga2IsG7w4zxAAeMIogPjpEiRORwAmOIoBrQkmMJ/ Gfa1FeuZlc1/L1pRecfdxpjH62g9 X-Google-Smtp-Source: APXvYqwlV8+u0xpgxAsyoZ/BSE8vLYxboPJCWhYv6ol4iQMh+4Wazh1zN/Ugq3E/pvm2d01o5Fce4w== X-Received: by 2002:adf:aa93:: with SMTP id h19mr4752163wrc.3.1562346413684; Fri, 05 Jul 2019 10:06:53 -0700 (PDT) Received: from localhost ([95.148.214.18]) by smtp.gmail.com with ESMTPSA id z2sm7674905wrt.41.2019.07.05.10.06.52 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 05 Jul 2019 10:06:53 -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 v2 01/14] apply: replace marc.info link with public-inbox Date: Fri, 5 Jul 2019 18:06:17 +0100 Message-Id: <20190705170630.27500-2-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190705170630.27500-1-t.gummerer@gmail.com> References: <20190414210933.20875-1-t.gummerer@gmail.com/> <20190705170630.27500-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 Fri Jul 5 17:06:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11033079 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 055C4138D for ; Fri, 5 Jul 2019 17:07:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E34D428A48 for ; Fri, 5 Jul 2019 17:07:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D774D28AAB; Fri, 5 Jul 2019 17:07:00 +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 7133428A48 for ; Fri, 5 Jul 2019 17:07:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727305AbfGERG6 (ORCPT ); Fri, 5 Jul 2019 13:06:58 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:44112 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727190AbfGERG5 (ORCPT ); Fri, 5 Jul 2019 13:06:57 -0400 Received: by mail-wr1-f68.google.com with SMTP id b2so9379388wrx.11 for ; Fri, 05 Jul 2019 10:06:56 -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=L/2uRcNf3aSJQFx2EHdPqtuIzDdbB9zD0t1Fpro5sC3XLLFsraBfisaU2/irYV39bG yFq6tqoQvdgydJ9a71sAAJ/48pkL5iQ1dq4g1NwCjlLJKt8U2CeWlLy+weaYphgHQf6O CWFpC3QEF1rYzlVO69eSgdVvwE7cubwR9EmEMSwKKrhVbxOzlW0bXlwYnFmbnaTQnfiT rvmFVIsRPehAFxhbuBBfhN00hP0CRBtfhobvmAacJ87fe3rnhezhX1lIKMyMdc1gwgQ4 bFWr3opzkLAoU1bMJnO04BRO7pWoRkf4f3u+j7KVJ3MavbNmNzSlBlnFwY/j5arL+rHf IQsw== 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=AAbZfRyyXpmrJqvCzBMHI6+YtpuDb+rEwRRuww7TMLj7Fz5OFc6p1ymO2T3hnVLVcA mIEc1hFI2Nsr7jlc4Y3zVrM7W0L2Pch4VipUR43X8clftuTo3LsKLlJCXD/lk6QH4PxK JluUBnU3If5m+G2sCafatFphAVZoucf7GpFHnCeyvKltD/GSAShZLflLDFwEtiWd1iN6 LSfmrCaVWP6H2NOzIxwSQOkHOW1BoljG70KJc36tali+DLfGl1y2JqDtCK+v7d2cjfpz 2t+IzQOzBAw1BwpMOKSAAoT4JEQrsRdLq9PbtE+6ZK0g0CIIEC8HOAaAxJlTEof8s26X 74qQ== X-Gm-Message-State: APjAAAWolmC/w2b00nMy8wUW9SBs5WscvydcX6MMSxCQuQwh39JFOlFk uI+F4yVrzHZiBnDl4Vxr8sjbJn2F X-Google-Smtp-Source: APXvYqzqSoBmE8s5Dx/piHARo/VDSEnFeWjI7e5RVskCQmQFaQ6yno7gpxrL1FZVkOB7MJs2hsbnkg== X-Received: by 2002:adf:a55b:: with SMTP id j27mr4890920wrb.154.1562346415127; Fri, 05 Jul 2019 10:06:55 -0700 (PDT) Received: from localhost ([95.148.214.18]) by smtp.gmail.com with ESMTPSA id g25sm6066734wmk.39.2019.07.05.10.06.54 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 05 Jul 2019 10:06:54 -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 v2 02/14] apply: only pass required data to skip_tree_prefix Date: Fri, 5 Jul 2019 18:06:18 +0100 Message-Id: <20190705170630.27500-3-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190705170630.27500-1-t.gummerer@gmail.com> References: <20190414210933.20875-1-t.gummerer@gmail.com/> <20190705170630.27500-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 Fri Jul 5 17:06:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11033081 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 840FD18E8 for ; Fri, 5 Jul 2019 17:07:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F1C028A48 for ; Fri, 5 Jul 2019 17:07:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63A6028A4A; Fri, 5 Jul 2019 17:07:01 +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 F008528A86 for ; Fri, 5 Jul 2019 17:07:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727346AbfGERG7 (ORCPT ); Fri, 5 Jul 2019 13:06:59 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:41987 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727275AbfGERG7 (ORCPT ); Fri, 5 Jul 2019 13:06:59 -0400 Received: by mail-wr1-f68.google.com with SMTP id a10so9519358wrp.9 for ; Fri, 05 Jul 2019 10:06:57 -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=rkdIPglJ/YqrBv4tWchuW/Ix9FGquG48+RAJk0d8XPqxquVKICOgR6dbH9jOVw339T EAN+OuMdvp2bt2/JxyfnMD7sLNY9DP3FPHCjxoPuRnJFWr0IUThU4w7KTgSP8rYMxyOV h2nmfmrcf9//UbN+xPfKya+3tF9N0yO3ua9yppZFeNRc5xIl7ToESxWngA2DjtGL9A0Z hbnapuY2PbDA/Ts3rkYWi9C3jesE7lYX0bIBwD8excSvH4a9OhjyusutTAL63EeTHUFy 6V+WTQKIsBKctX2uI9i1ENVGn1E6K62IkV2aRJfwl3CJI2FL3x1+JltLkADzrHClvq8j 2YVw== 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=f1sKH2yJuSpCCBvFGMoEjHPWVCZhFAwn5bZYrLORqYy2vHbmwcHBrlPWK78tEYYvoF n+mY+SxV2ydCJ9bXPmtN6xsx5k4m3LejN3N81s7UhkZeg/b5b34jvvldZmjL9sJzihPC XNq+2CoBRGpjKEWwQFySgPYmZnzBOBBmp3HrX8Tswg40UFqlPOYCcFN2Zr/8oNB0UF5T NvPu9IHDYlTSGDCnxNQ6/GpKka1VJLG+IoxJezOI7gKPpYcdkbI3tNmcUUzd5KvUls5r YbxNqbg74qbIkmTCcIvhpCA6ZUB/YS6RGRmeUk3TfagbFVuOU94AMhyjJcNNDGBFy4mO cG6g== X-Gm-Message-State: APjAAAXRfYwYvk7Mp3VXu7K4XidGrJqYCe+VyRn+niiRDDwx+WWBXoDC eCzgX/Vs9TjDQQnJQXC61iSjZV4b X-Google-Smtp-Source: APXvYqyYZG/LoL0OrbAuTe97n2K3ye38FT5ksUDV9D/Jr0KolEZiQnPIgNqLZurlm6YWgc3c5///UA== X-Received: by 2002:a5d:62c1:: with SMTP id o1mr4824931wrv.293.1562346416619; Fri, 05 Jul 2019 10:06:56 -0700 (PDT) Received: from localhost ([95.148.214.18]) by smtp.gmail.com with ESMTPSA id d9sm13433110wrb.71.2019.07.05.10.06.55 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 05 Jul 2019 10:06:55 -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 v2 03/14] apply: only pass required data to git_header_name Date: Fri, 5 Jul 2019 18:06:19 +0100 Message-Id: <20190705170630.27500-4-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190705170630.27500-1-t.gummerer@gmail.com> References: <20190414210933.20875-1-t.gummerer@gmail.com/> <20190705170630.27500-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 Fri Jul 5 17:06:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11033083 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 B8AFC138D for ; Fri, 5 Jul 2019 17:07:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3D6328A48 for ; Fri, 5 Jul 2019 17:07:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 985F728A86; Fri, 5 Jul 2019 17:07:02 +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 46E5A28A48 for ; Fri, 5 Jul 2019 17:07:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727366AbfGERHB (ORCPT ); Fri, 5 Jul 2019 13:07:01 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:36397 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727338AbfGERHA (ORCPT ); Fri, 5 Jul 2019 13:07:00 -0400 Received: by mail-wr1-f65.google.com with SMTP id n4so10640083wrs.3 for ; Fri, 05 Jul 2019 10:06:58 -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=Gb1OTH2n4DtXkKXSvqpgQAiT12URWBclVhaX4wm5I0Bkk5jeOJPFzNbT3ZuX+CyUZP cQxwTUBglioeR/SVR3a1kcmvwcvuxbfjYtZvXkv68RI3GeKrRhsdpkxIyBd8BPNqk5Aw R9vhRHZFCLxNzbsjCaiA/HGV5tF33S26DbhK/281b7MGwFbM+xGWl3mNNY64FOBR96m4 XgJbadoUmrn+Qauz81YDHBIWUhVZX5AAlmBY2QhbWKMywsJS6sQzltC2J0+AsYTsG8BX sTyrst0uBPGXNl/4Y4B4DmaIjvOD2mjEYHWjMR1etixTtQyufShACq0qdGSGPpGxmuTM aanA== 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=HYr00oH+54FkgzPQl5Aap8Mn91N1u/D/FJOmM8qdOg8QU5O7lszm4I+9RK0LJ2q0Gk rcQ0VL7/7Zw/H3MBNQ0G4Gglv8zBnilsqpK6N4WgOR/g54YvqbbZr7R73r34v17FUjv2 5Y79qqs8DGn0eyXGHG/mY9IdFIFMqSmqZp4bRtFpTjrW6jWLlaSZ0fiqUChxGAoMCBmg u0HukzG4ZMrBzIEzevQWkmLM4Qvh0wlqC/Ats65d/qIv8TrZJlSy2k9WNQnYrfWtZxWk a2jAjQgImm80hgAI9vBtomVNWGipS59VLD1EsSaLeWSFEanYeHxQtZavhTFW/WeBp8nO U6iw== X-Gm-Message-State: APjAAAVZh0He+BInUTVnoMwSNtjHX7HkggOnSLW8/LXBLq4+b1FXkfH1 ExdEKDkbfLLG2vdeyl53vyujx62/ X-Google-Smtp-Source: APXvYqwMnvE8N5hYaSwyjPhHAl+lf6PBZ9OgbY2yive55nRcAuuO0ptfRzG34dGxyMaxWS87Y22w9A== X-Received: by 2002:adf:d081:: with SMTP id y1mr5141676wrh.34.1562346417937; Fri, 05 Jul 2019 10:06:57 -0700 (PDT) Received: from localhost ([95.148.214.18]) by smtp.gmail.com with ESMTPSA id h1sm8648376wrt.20.2019.07.05.10.06.57 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 05 Jul 2019 10:06: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 v2 04/14] apply: only pass required data to check_header_line Date: Fri, 5 Jul 2019 18:06:20 +0100 Message-Id: <20190705170630.27500-5-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190705170630.27500-1-t.gummerer@gmail.com> References: <20190414210933.20875-1-t.gummerer@gmail.com/> <20190705170630.27500-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 Fri Jul 5 17:06:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11033085 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 0E2D6138D for ; Fri, 5 Jul 2019 17:07:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC98128A48 for ; Fri, 5 Jul 2019 17:07:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0EAC28A86; Fri, 5 Jul 2019 17:07:04 +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 4819128A48 for ; Fri, 5 Jul 2019 17:07:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727430AbfGERHC (ORCPT ); Fri, 5 Jul 2019 13:07:02 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:39760 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727275AbfGERHB (ORCPT ); Fri, 5 Jul 2019 13:07:01 -0400 Received: by mail-wr1-f68.google.com with SMTP id x4so10597879wrt.6 for ; Fri, 05 Jul 2019 10:07:00 -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=oEftES1isV/n7zxYEn2p+0ke11ij17vFBnpxm8gWGX8ZJDjOpsR7LH8qLf6rdizzl6 3Ld4EGWixeklbvLcF5AR9Sh2R2Z7I0Prpfe0e5soqpBb00ElcOSGq6OGpQjeF/P5frtV o3XCFh4CSQp77aEAxLkzNMta/fmDSoxE0hU6jhdHlvEXFE7GMqbfKmnzaQ3L6Ba1cDHY lkvaY+5QMdM4e5YG6uQsDA8LOWZ0BGcXmzIZk6mP4FcvkjNgk2HrLVVliyMW7DFuigv5 akFREizOVOJZgy09KuTG5Vtqyqlrvy/OQjbFN3sYGtGA0o+NxlZ3c608kfSCI6m0g2uU H4dw== 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=Clt6ZtbW2jiiUQ6lBTY9xWeBajP1BGmS5u3YzRMZuI8ybrhJjY9nswwMWLgcQvbw/T tQ6tV1bVa6rvTAkytGnzL06UEaDLL6BNqNHdlOu946tetGbCwLfsBCjwl/+ilWH1rlWh 0g5e8XVfDnWVaol6MTnXN6ggiJKTYdFiWKs6pQh4yX5ZdC58mzVD2w43HNX0dMT/dGVT i+obBqTonNJfQ/ui5957sJfGHbh9V9RLdylEVXWngzoR+enhI1A+MwDdIzlER383l3ix Rr56z/dc6Smx2YUTvfdqKemUHx7By9Eclt9wbb0pXbTErXEXbkmq2f2lU+YFET9odO2g L0IA== X-Gm-Message-State: APjAAAWjSSroBqGOPoTQmVaaUnj4bm3x1Eiy04naBVKbwk/uGC818TqH Vu7R5etbejj1y0ZjIzf3TugSlQis X-Google-Smtp-Source: APXvYqzQZRMZddUr7jqB8bRuSHhgz5wJx2ASKpnQn9viB22IKoz7ezlpbqm19VQxs5tTCRB0q/Ny8A== X-Received: by 2002:adf:ecc3:: with SMTP id s3mr4920824wro.306.1562346419275; Fri, 05 Jul 2019 10:06:59 -0700 (PDT) Received: from localhost ([95.148.214.18]) by smtp.gmail.com with ESMTPSA id f17sm3561675wmf.27.2019.07.05.10.06.58 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 05 Jul 2019 10:06:58 -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 v2 05/14] apply: only pass required data to find_name_* Date: Fri, 5 Jul 2019 18:06:21 +0100 Message-Id: <20190705170630.27500-6-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190705170630.27500-1-t.gummerer@gmail.com> References: <20190414210933.20875-1-t.gummerer@gmail.com/> <20190705170630.27500-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 Fri Jul 5 17:06:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11033089 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 4667F138D for ; Fri, 5 Jul 2019 17:07:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31D6428A48 for ; Fri, 5 Jul 2019 17:07:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2589628AA0; Fri, 5 Jul 2019 17:07:08 +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 6A45228A86 for ; Fri, 5 Jul 2019 17:07:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727464AbfGERHF (ORCPT ); Fri, 5 Jul 2019 13:07:05 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:35547 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727383AbfGERHD (ORCPT ); Fri, 5 Jul 2019 13:07:03 -0400 Received: by mail-wm1-f67.google.com with SMTP id l2so3125567wmg.0 for ; Fri, 05 Jul 2019 10:07: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=mdDSZBXVcoMZ/Y508gVESM2Hr6pVhWCk7JODi9DfH4A=; b=RLd48hYC6rypo7afvsGPTbujuAE3SSpR3phndiztXA7hMesG3Bcx1ExDIJnRJ7VH9U Md3d0d9NozR8iISLMw6EqR2hTLJDL3hxIPl2c5sr/fb6jw/NvR/9jaVZhfiT2epHBXEw 3sBqy+8/x5RpBMbSW4DtHPdrNuPc5M7nyu3MEN+QbRTy43Cv9T8oYznCLRJl1Uil+DeX mAy/6wtTDGTU6+WaTFtRYg0gfZu/XCk+UlZ/hl9UN2diu8vW9XrX+19X0+NQHPpv8xfq J9jN5dDqtB1MACz0Sk3HLOiphrfNpn/gXhZSgjgdyRTZZTb9dPiI24k6Dv7ZqVoFxaPi BIIw== 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=mdDSZBXVcoMZ/Y508gVESM2Hr6pVhWCk7JODi9DfH4A=; b=IExpJSV+7Bx0woPgdT2W/+8HYu7KD8X0tQlfw3O74OVwOh1mFfQN0eRrM67AHYlBzd vnsc7i+za6fgFtRZdq2lrCLgMFbJywJMeap/Ip3sBwD1MABXlSdKl5RMfpEKgYe8Qgj8 iVRYw2gnrvvAFmLEGxC4RJJHyYMGrW9u2AQYybeVOUZyQ7pSi/rz4Tl8ML83KLsWXQCq 5FbLZDAGNV+KHKIYxuUPqif/1clXNcaTXARrlXkYuRDAGvibSzELCFV+KfLzWXFhf4fH jNYv+bmxJUpr03P9I7w+yshA7aQ9R5GPMGE5hqJssUah72H/109XLuw1PAKT1cm7ZLw3 Qe7w== X-Gm-Message-State: APjAAAWaJD/yBWTN/bfveiB796oHaa80I/BPaR++mXCPpg0WSxFtpFZQ v1I5jXK6RNJp9T8w8qyfRJt7ajjp X-Google-Smtp-Source: APXvYqzCL0WpOoGtCxeQWadIBjPZJpChEWD3AfK5ltaV8YCYzyQqlMmnp5qNRbYqFpGSOREC6WDZCw== X-Received: by 2002:a1c:9a4b:: with SMTP id c72mr4181142wme.102.1562346420617; Fri, 05 Jul 2019 10:07:00 -0700 (PDT) Received: from localhost ([95.148.214.18]) by smtp.gmail.com with ESMTPSA id v124sm4176930wmf.23.2019.07.05.10.06.59 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 05 Jul 2019 10:07: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 v2 06/14] apply: only pass required data to gitdiff_* functions Date: Fri, 5 Jul 2019 18:06:22 +0100 Message-Id: <20190705170630.27500-7-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190705170630.27500-1-t.gummerer@gmail.com> References: <20190414210933.20875-1-t.gummerer@gmail.com/> <20190705170630.27500-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. 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..468f1d3fee 100644 --- a/apply.c +++ b/apply.c @@ -22,6 +22,12 @@ #include "rerere.h" #include "apply.h" +struct parse_git_header_state { + 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 parse_git_header_state *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 parse_git_header_state *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 parse_git_header_state *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 parse_git_header_state *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 parse_git_header_state *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 parse_git_header_state *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 parse_git_header_state *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 parse_git_header_state *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 parse_git_header_state *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 parse_git_header_state *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 parse_git_header_state *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 parse_git_header_state *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 parse_git_header_state *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 parse_git_header_state *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 parse_git_header_state *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 parse_git_header_state *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 parse_git_header_state 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 parse_git_header_state *, 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 Fri Jul 5 17:06:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11033087 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 9DF0A112C for ; Fri, 5 Jul 2019 17:07:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88B9228A48 for ; Fri, 5 Jul 2019 17:07:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CA6328AA0; Fri, 5 Jul 2019 17:07:07 +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 5793728A48 for ; Fri, 5 Jul 2019 17:07:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727383AbfGERHF (ORCPT ); Fri, 5 Jul 2019 13:07:05 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:38160 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727436AbfGERHF (ORCPT ); Fri, 5 Jul 2019 13:07:05 -0400 Received: by mail-wm1-f66.google.com with SMTP id s15so10402288wmj.3 for ; Fri, 05 Jul 2019 10:07: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=9ZKs3Ftj+G26UFJmALBgp8BlYszs51wVO5TTL4H1tD0=; b=oTF3/HjjlsLkfOnD9KRV9qG64+flWbyVNpkrcOz0HvpMTJ5Og/HLqsT5S1U87JqKQi /fFSxNz5SgLzQa+visnA3RgKUspafx2743Ad0+WT5/Pm30XJPzr/anb+STjVP1L93U4V t8Pz3jrvG8fISFFPG/6NL7oICLJqVeNL+jSTPdC40vfpFeFjPlzAMUUT6zRifwpDrxKD 1dO6OKgZP8lRIA24CgEJ0JaM901LRNoHW7Q3My7AQlai2ufFxE8AmJA8qE1KT6nGiou0 ObyLWZEgkoZfMRG78HRRAONJMBkj0t1TquN2GmZ4iFbwBEpcTwFomNzG0qxpcDTnW/mt cA6A== 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=9ZKs3Ftj+G26UFJmALBgp8BlYszs51wVO5TTL4H1tD0=; b=lf7IvZX3D0H5xwvRM3Fk39p/+mrms9bDBfy61BoZH7nVI9qPYd7DhD3BqUtGZXlFmw LoQHiEeNKZVktXpVAalXTLep/lGqNMlAkJWjttXWQ3kZHTbDNVes6fTw5HrNJcExwQEy 3jmXUuE94SBhko/4BoXeS8KMBrgooFbRSryjtX0X/WWGWoXfwObUlkNMPmwLOpuBtoJJ y4SN3c3Gor/1SToz+cN8oRGTTa+yXFA1G5UuFdgK/BueLOSIa6N1cMKE6HdaXm0EjmJg PfKLPcfcdA0PBpWJ+W37MMuirhYY3hDY2J5WDAbroXD4KruEGNT4q/Kw81BoxrP09E9v NC2g== X-Gm-Message-State: APjAAAW72sm5ysXNXFLtrqn9qm9r69ysBUNWwJLOmwwwJVoRmXAtDz+p o8M1xWiDN5cM+emsI/jygQRTNwcN X-Google-Smtp-Source: APXvYqxydAkStjLf/OHeqAqME1sr46Cw2EcyoNZA6U+Qm5WX1kNwYAmvWPozUrelAuxEIh65/dJr1A== X-Received: by 2002:a05:600c:2056:: with SMTP id p22mr4085826wmg.155.1562346422517; Fri, 05 Jul 2019 10:07:02 -0700 (PDT) Received: from localhost ([95.148.214.18]) by smtp.gmail.com with ESMTPSA id g8sm6080134wmf.17.2019.07.05.10.07.01 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 05 Jul 2019 10:07:01 -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 v2 07/14] apply: make parse_git_header public Date: Fri, 5 Jul 2019 18:06:23 +0100 Message-Id: <20190705170630.27500-8-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190705170630.27500-1-t.gummerer@gmail.com> References: <20190414210933.20875-1-t.gummerer@gmail.com/> <20190705170630.27500-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 a "public" function in apply.h, so we can re-use it in range-diff in a subsequent commit. Signed-off-by: Thomas Gummerer --- I considered creating a separate struct for only the metadata here, and embedding that in 'struct patch'. As struct patch is mostly metadata fields though, I decided against that to avoid more code churn here. apply.c | 68 ++++++++++++++++----------------------------------------- apply.h | 48 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 49 deletions(-) diff --git a/apply.c b/apply.c index 468f1d3fee..04319c233f 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) { @@ -1321,11 +1287,13 @@ static int check_header_line(int linenr, struct patch *patch) } /* 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_header(struct strbuf *root, + int *linenr, + int p_value, + const char *line, + int len, + unsigned int size, + struct patch *patch) { unsigned long offset; struct parse_git_header_state parse_hdr_state; @@ -1340,21 +1308,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 parse_git_header_state *, const char *, struct patch *); @@ -1391,7 +1359,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 +1540,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_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..e7a1586b17 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 get 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_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 Fri Jul 5 17:06:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11033091 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 93276112C for ; Fri, 5 Jul 2019 17:07:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7AD7C28A48 for ; Fri, 5 Jul 2019 17:07:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F02828A86; Fri, 5 Jul 2019 17:07:08 +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 2530428A4A for ; Fri, 5 Jul 2019 17:07:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727506AbfGERHH (ORCPT ); Fri, 5 Jul 2019 13:07:07 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:37620 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727356AbfGERHG (ORCPT ); Fri, 5 Jul 2019 13:07:06 -0400 Received: by mail-wm1-f66.google.com with SMTP id f17so10392463wme.2 for ; Fri, 05 Jul 2019 10:07: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=ZK6F8I9MMRXb1nyoGtw4TkkqOifbnYF7o0+q1l/W/JM=; b=Iz1A6vcQH78syu9yuJQ4RbstvGdo/2dB/C1OkhNKQCJELLHiesnbhFVZsypIGM8/V8 umWv0vDWaWqVbljFC6u+XjT4LhxcyP5F+bWrmBucfbCJj7CZvEOvE7d1IaVENkrVSFrZ QV//7sf2x3rimh6L0zBH22d3hfUSIb3atQlpZb5/yCbcql9Xu8/h78zbt8etUR82AbVp 6q2dAE0uzs63Xc1yB92OjoZ7m8rNc0c1oxlP+n2SfnIGt2jk2hDBAdv4mdG7gb6NuRcs ojbkx2zDy9bIOaGVEMi/os2NG4ns+Jpl8kmjbQTYVer55Z8CqlXFBRS+LTS/lJCEf91e nhrA== 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=WFw9OBNisuRsgTpqFNj7OayoUi9qrPfCX8HaTAWjHsIB1WNAxxf9t5iyUxq7JBxlCQ pXU6bWMOEpP5xkyRNEoQoYE+FELcHApfIVL8i1o5T4c4aV3YNHmp2WQMH/63GM9WdIsD OqpmOo+5kKcbqDRHjX7SZswE7mWQX4LJnkxFG+em6+FG7he7oY8oH2GUcfC5DFM6utg8 WH4d5po8YlSN38Zv7rIERwOoMBtrufQdhOf5dFuN6yOWR4sMnTV6PDO3Zv+uL+iV7dG4 rcLTuMjmo0Q++BsR30GyLlO2Ic87h6//qCUyDh+eeAxNCi4yxGle2AFfe028b8oqE1Bh h/Mw== X-Gm-Message-State: APjAAAVJebecrAASidqc3knfv+8bmeUoS2JDX89F+UagJ1dzBU7D7R0D EZENDMXlQzEC4Gv9U4eEcftfBF8d X-Google-Smtp-Source: APXvYqw0C0Ep35IGaYJeC9UyCqQP/pQHbl00ei+ckdQP/GXpk7FrzAPoEIv4VUIcf0OV5waknhwpYA== X-Received: by 2002:a1c:7414:: with SMTP id p20mr4055010wmc.145.1562346423996; Fri, 05 Jul 2019 10:07:03 -0700 (PDT) Received: from localhost ([95.148.214.18]) by smtp.gmail.com with ESMTPSA id 2sm7544334wrn.29.2019.07.05.10.07.03 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 05 Jul 2019 10:07: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 v2 08/14] range-diff: fix function parameter indentation Date: Fri, 5 Jul 2019 18:06:24 +0100 Message-Id: <20190705170630.27500-9-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190705170630.27500-1-t.gummerer@gmail.com> References: <20190414210933.20875-1-t.gummerer@gmail.com/> <20190705170630.27500-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 Fri Jul 5 17:06:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11033093 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 E48F4138D for ; Fri, 5 Jul 2019 17:07:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE51E28A48 for ; Fri, 5 Jul 2019 17:07:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C123028A86; Fri, 5 Jul 2019 17:07:11 +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 4714428A48 for ; Fri, 5 Jul 2019 17:07:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727544AbfGERHK (ORCPT ); Fri, 5 Jul 2019 13:07:10 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:33745 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727436AbfGERHI (ORCPT ); Fri, 5 Jul 2019 13:07:08 -0400 Received: by mail-wr1-f66.google.com with SMTP id n9so10641896wru.0 for ; Fri, 05 Jul 2019 10:07:06 -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=+EJif8SwSYXiJzxVXEsUjNUyDz7SPbpi5OkkxWedsps=; b=NgO5EoD94f9Z/MCCLbdkFCGSkUCx/WUSo/BzSHys6eFMZiMc2QFs3T8VTIymD2EwDn RneRPTGSaoR1CBbI0FbUgq4XjhF31281cLjiWT8F8SSGf6J4eC3DCo6eVvWCx6sjHiqI lRYXNldFKR73QtnLH4LgsYe2EnaXmpPg6gQwDnWxEtE6zjXqPhkuNR8CZ+NNjCO64buw dInjxNJwLhyqInfDaAE6Ro3/ku5S2zE7ix9sob/AKCub1m9Jtfc29nRL/5YfCuB3AxMj eONKTsuHj3nsTFCMXMkMAwJsOMbxV1Fwc4gusNUl3sVScO+GUNTCj4ZnqpYJA2lkPhPB hyZw== 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=+EJif8SwSYXiJzxVXEsUjNUyDz7SPbpi5OkkxWedsps=; b=BeCV3McjrtsS3HqdgNLdO2fIR9yvFDJDdQCJE7vRfPhAP4oQJ6q1Q/7fYvIKdb93Mk 02luoDll3IqX67F9Gu5CxTS6+yqtCDUfID9O6jFKdzXYHOqwFfrjn+9/1xTxPMLmfaSq Xa28/RbiCmohS75+5dKBj9T89xJLpZ/Q8Ze1OoRdSRPQCP476cz1djUMGvhV3OX+xtwh PtXXmQiMav33w+mOhckuPB6xvBSO4jBpTqdxkMYWSjRxr+NfaWSkvMtHSMi/E0lG26+s M4/sUSYDoMbD5PZnxuqzpTeQIplp/wQGFyLq0oa7f6cet9f7N0cbFF0MBk2lhtwRCXOl JtXw== X-Gm-Message-State: APjAAAXXtHYM1daqxyvRFSDdX+RR4+Z532XXsIylVS0qeTDrAeqn/ElQ dlNf9Qzew6JFLqhSbcpcB/h2Ms3U X-Google-Smtp-Source: APXvYqxBiB1fy6CI2s4e0f3XjE1/8lXp++WMB+VCzSd9QyJ4TQopLvfNAAOYrrx21PsSdOY0UxF7/Q== X-Received: by 2002:adf:ce82:: with SMTP id r2mr4621769wrn.223.1562346425240; Fri, 05 Jul 2019 10:07:05 -0700 (PDT) Received: from localhost ([95.148.214.18]) by smtp.gmail.com with ESMTPSA id u6sm9427405wml.9.2019.07.05.10.07.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 05 Jul 2019 10:07:04 -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 v2 09/14] range-diff: split lines manually Date: Fri, 5 Jul 2019 18:06:25 +0100 Message-Id: <20190705170630.27500-10-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190705170630.27500-1-t.gummerer@gmail.com> References: <20190414210933.20875-1-t.gummerer@gmail.com/> <20190705170630.27500-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_header()' function, which does requires reading parts of the input from that function, which doesn't use strbufs. Switch range-diff to do our own line by line parsing, so we can re-use the parse_git_header function later. Signed-off-by: Thomas Gummerer --- Longer term it might be better to have both range-diff and apply code use strbufs. However I didn't feel it's worth making that change for this patch series. range-diff.c | 69 +++++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/range-diff.c b/range-diff.c index 9242b8975f..916afa44c0 100644 --- a/range-diff.c +++ b/range-diff.c @@ -24,6 +24,17 @@ struct patch_util { struct object_id oid; }; +static unsigned long linelen(const char *buffer, unsigned long size) +{ + unsigned long len = 0; + while (size--) { + len++; + if (*buffer++ == '\n') + break; + } + return len; +} + /* * 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, file = 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,15 @@ 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) { - error_errno(_("could not read `log` output")); - finish_command(&cp); - return -1; - } + strbuf_read(&file, cp.out, 0); - while (strbuf_getline(&line, in) != EOF) { + line = strbuf_detach(&file, &size); + for (offset = 0; size > 0; offset += len, size -= len, line += len) { const char *p; - if (skip_prefix(line.buf, "commit ", &p)) { + len = linelen(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 +86,6 @@ 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); finish_command(&cp); return -1; } @@ -85,26 +94,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 +128,23 @@ 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); if (util) string_list_append(list, buf.buf)->util = util; From patchwork Fri Jul 5 17:06:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11033095 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 CAF1E138D for ; Fri, 5 Jul 2019 17:07:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B473B28A48 for ; Fri, 5 Jul 2019 17:07:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A88C428A86; Fri, 5 Jul 2019 17:07:12 +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 47ABE28A48 for ; Fri, 5 Jul 2019 17:07:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727401AbfGERHK (ORCPT ); Fri, 5 Jul 2019 13:07:10 -0400 Received: from mail-wr1-f50.google.com ([209.85.221.50]:37201 "EHLO mail-wr1-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727509AbfGERHJ (ORCPT ); Fri, 5 Jul 2019 13:07:09 -0400 Received: by mail-wr1-f50.google.com with SMTP id n9so1461887wrr.4 for ; Fri, 05 Jul 2019 10:07: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=S/ueWbv3h2I/NDQO9J3kaQ5tAa9DjsWFQXjijZ6/KJ4=; b=Mrg5NKSIYMDWyQ9JgU4AT1sta2/GfXOgNIHyK52D8wGLZtam6M98idYOO0IZ9OjhCw LxX+oYuJhjzrYkVpzBmidc4r/aKEfQaIwqaSadOvXQOSDOtrOHWZ2M/meGcB+5dUX/er Y1q+1/RNurTTCqtfW5yyINtvqGpPc/af8XIHDHIUTKB/Y9EyEdmBLKc+THT26XbjgJY2 3GqwPxzofe1t9sS1weKqiCEwo8xPPmrMAXtklMjeffm3ug14yJzJqU54SUcBDxqFzqYZ IBuDnjCXyYAeGl0poSzO+QI7z1EHSC25/efCvkweYbmALFoGBJoroUBQzJUPEJBPdfVD fCVg== 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=S/ueWbv3h2I/NDQO9J3kaQ5tAa9DjsWFQXjijZ6/KJ4=; b=XLB+4tZj7wL61oJqDMKFTu/mrAVdVXk9nL81cdblc77MVLhGXXbXAzJlCizqHt4uUo RJnlmqQyaUMEEVDunn+ZmJJDw9iCL1dOZZkk6ejkYV22fpWoarCj/xNNZa1I7GiBntQL mPvEuz9mnsKuJI6+UqVqCaTYsc+ktydr/IwIBYhDY5OMVQ9R3VT/0wrJbTfcN53tYNeg DVN1xz3yi9zKkHY3zlMECILaTbIBgLNaGrDa7oxZYkayC7HdXDTp+wHr+osRoZNlJkmr LWp0F2sC5mZxanHrs3Osk9Ic2U0/64aXZetiwCEsjjWOIS0XltzRuK0ZH1aQMs0xKjub zjXQ== X-Gm-Message-State: APjAAAXJ6gmVrDGuZubeLPGdcGqZhlu51f3PB6ylUn7zj9rnIrpxF9yn YGNRsYKBC6cMnozL7oW4yfxO8xLX X-Google-Smtp-Source: APXvYqxH8FwO+DflJtN88UkI0z4VuYgqICyd35Kv+eVmxXduYkj5w5monWmasj0fh7u324d5lLNUWw== X-Received: by 2002:a5d:4f92:: with SMTP id d18mr4809440wru.132.1562346426496; Fri, 05 Jul 2019 10:07:06 -0700 (PDT) Received: from localhost ([95.148.214.18]) by smtp.gmail.com with ESMTPSA id v18sm11217128wrs.80.2019.07.05.10.07.05 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 05 Jul 2019 10:07:05 -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 v2 10/14] range-diff: don't remove funcname from inner diff Date: Fri, 5 Jul 2019 18:06:26 +0100 Message-Id: <20190705170630.27500-11-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190705170630.27500-1-t.gummerer@gmail.com> References: <20190414210933.20875-1-t.gummerer@gmail.com/> <20190705170630.27500-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 | 8 +++++--- t/t3206-range-diff.sh | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/range-diff.c b/range-diff.c index 916afa44c0..484b1ec5a9 100644 --- a/range-diff.c +++ b/range-diff.c @@ -113,9 +113,11 @@ 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)) { + if (!(p = strstr(p, "@@"))) + die(_("invalid hunk header in inner diff")); + strbuf_addstr(&buf, 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 Fri Jul 5 17:06:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11033097 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 C8F51112C for ; Fri, 5 Jul 2019 17:07:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B282128A48 for ; Fri, 5 Jul 2019 17:07:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A672E28A86; Fri, 5 Jul 2019 17:07:14 +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 3178928A48 for ; Fri, 5 Jul 2019 17:07:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727565AbfGERHN (ORCPT ); Fri, 5 Jul 2019 13:07:13 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:43096 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727510AbfGERHL (ORCPT ); Fri, 5 Jul 2019 13:07:11 -0400 Received: by mail-wr1-f66.google.com with SMTP id p13so10588516wru.10 for ; Fri, 05 Jul 2019 10:07:08 -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=bunykNaHGdrBJ0t7SVGYq/jV9WCVTSz1n9AuYq76KD8=; b=esHJ7iTIIMAMm2fmAVV+G6d0QKKfT27p77PHEckxlb7KUMFi47wTuwxhbpsyhbxM0m L6UxoGIvp9G+psZm2LWgA7VPXH93dAVLDN0UUph5OPGlk+iXlgyjFzYIpP3mLyZ1hxfK JL/27A6fevO4jMxGkDF1Yk2HeEqO0uddSDKJsPRQ+CryqM6LIENzBqTLOWAqfaOr7qtA 0brgIfExYMCJYpe7gjUoyVQX2hpAn6lv3C+gTiqY/AptNHkYLX6DbJuyrfbugmFP/jHW Im8QV4JP5nCIedcd0IxU5za+mMGUt0duM03aiD5G02hpAKVyqtcAbvYHUZQ+zBFU/eqt EQ6w== 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=bunykNaHGdrBJ0t7SVGYq/jV9WCVTSz1n9AuYq76KD8=; b=tLWLrH9CaB/cCW7tfzKGgPyycNifVB9pKFuseqD2+WJ+W79UNCRDSE6iCwGZSmW2bW qZuCY2t4s3qXxF+jc0Zs7s3xf6pw1sid6DcGSqchiGl7LnKuLCfpuWWOBYTd6xIIRaNd oPHMyNGYHN1XoGzWpUhJGPsF1mrKtsGLt9aeeHkEtwX//ZXDEcvdY5idG7nH1VblJCCw tTav5zvxrEngl5ejoqdg7j1cMsaigtNmjes3LlxPzDMLaAKcMIzNaYcY+MFjKDmJMvmp Wmt1lXBOyhmVHmvir+JW4Ap54H81hZjFFiwe8F3mFUeuSvTOWeXZTktUjjaIzNhiXfu3 baOA== X-Gm-Message-State: APjAAAXOqN1ss4HlpiiQjBzOCK+qmQH7UclSfESl+Q2HQ8hYQXDnfWg1 zP+Toa6LYS0n7qvT9zNAFgx9+YGJ X-Google-Smtp-Source: APXvYqzDBGHsraIhHsJG/SgtVZAV8/IZwEAvigQWxj5UTJXeMnAQjRpezLZJN3kNIDS7Z3Q3ajvIag== X-Received: by 2002:a5d:4ac3:: with SMTP id y3mr5053607wrs.187.1562346427843; Fri, 05 Jul 2019 10:07:07 -0700 (PDT) Received: from localhost ([95.148.214.18]) by smtp.gmail.com with ESMTPSA id g14sm9452104wro.11.2019.07.05.10.07.06 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 05 Jul 2019 10:07:07 -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 v2 11/14] range-diff: suppress line count in outer diff Date: Fri, 5 Jul 2019 18:06:27 +0100 Message-Id: <20190705170630.27500-12-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190705170630.27500-1-t.gummerer@gmail.com> References: <20190414210933.20875-1-t.gummerer@gmail.com/> <20190705170630.27500-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 484b1ec5a9..b31fbab026 100644 --- a/range-diff.c +++ b/range-diff.c @@ -480,6 +480,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 Fri Jul 5 17:06:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11033099 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 E3A72112C for ; Fri, 5 Jul 2019 17:07:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAEAC28A48 for ; Fri, 5 Jul 2019 17:07:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BECEF28A86; Fri, 5 Jul 2019 17:07:15 +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 0348F28A48 for ; Fri, 5 Jul 2019 17:07:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727538AbfGERHN (ORCPT ); Fri, 5 Jul 2019 13:07:13 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33750 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727508AbfGERHM (ORCPT ); Fri, 5 Jul 2019 13:07:12 -0400 Received: by mail-wr1-f65.google.com with SMTP id n9so10642047wru.0 for ; Fri, 05 Jul 2019 10:07:10 -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=rKS8urdBItbRr0HeEgG8ThxZLrSHodQXAYOsBJNUTt8=; b=upe+g2qjRpBYRb04XcdKdc2j1aEnQD7J9/BZ96ko8TPpvLmrq/4DxYOoPXEF8Ecxbs 2JK74PrNmOTN4WIcLPGEQ0bFSPE1hLe8GE1e7YrI8P7hZ5iYB6ZpKxHYK2xFg035G8uC M+P1t82mK21zUGyMsmRnKx3zQFv9gN373MK7yXcZ3dhHICP0m/reQb9zOEt1uhCLe8HD GY2O+dgWm1AM1gNcOUG/gs1ecdrTpd5HtjO5AhPnLVlQ+YFZoBw2tUoWJSEZ7Y0/FV7u XEd56eYqtksE2fEHyTnzqUEICt9DHt8K85DlSK1bNA6APidB+e5JNmsW4J4ONIRUcnY7 JjYQ== 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=rKS8urdBItbRr0HeEgG8ThxZLrSHodQXAYOsBJNUTt8=; b=mMeS07vrjrFO6O7mgescfpbd/5aE93+ODMMGWQRF/wm0/e5m82bb6j11023HD1zpnM 8SxZYn8yD3TqXQd7fJU0veyi9QON7jfs69A38QTS/mOmBeB1Ms8pD5Ip9/3zoFZeDUDJ z02h0+3eLsFj46jLPnMM2Ft3izvjtG96xZ4k5Qw0YQtUfD8LMs0fcEQbW1I6moazrZoX pn5tF841a76m5zNrcfWuW6oZaNQk3YXQ4dIOZUbn8v7Wm684uywMI/m6SoQBOKtANP3M 3Iq4T9LAzpJY6khqmvmxYCouXwnvVOJ+HZMPldyO7gcTx6n4trz/1ujr2yicPWQ4vGAu jNLw== X-Gm-Message-State: APjAAAUNtyRdLJ8JZi+MdAISqzEH3JRLIXtxepYqClneyxp2ajOnH6VS 2QOwa+YJezqOZWwHXfZmyesXteU1 X-Google-Smtp-Source: APXvYqxBWnxUAuRYXg5BU7M16OaYnAPU4CpHqKpgpY7/SV7VMBt2LsarnfHk0uLy/EQXh4By03/nPw== X-Received: by 2002:adf:db07:: with SMTP id s7mr4687456wri.10.1562346429233; Fri, 05 Jul 2019 10:07:09 -0700 (PDT) Received: from localhost ([95.148.214.18]) by smtp.gmail.com with ESMTPSA id o11sm9144796wmh.37.2019.07.05.10.07.08 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 05 Jul 2019 10:07: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 v2 12/14] range-diff: add section header instead of diff header Date: Fri, 5 Jul 2019 18:06:28 +0100 Message-Id: <20190705170630.27500-13-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190705170630.27500-1-t.gummerer@gmail.com> References: <20190414210933.20875-1-t.gummerer@gmail.com/> <20190705170630.27500-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. Additionaly, 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 | 35 ++++++++++++---- t/t3206-range-diff.sh | 91 +++++++++++++++++++++++++++++++++++++++--- t/t3206/history.export | 84 ++++++++++++++++++++++++++++++++++++-- 3 files changed, 193 insertions(+), 17 deletions(-) diff --git a/range-diff.c b/range-diff.c index b31fbab026..cc01f7f573 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 */ @@ -95,12 +96,36 @@ static int read_patches(const char *range, struct string_list *list) } if (starts_with(line, "diff --git")) { + struct patch patch; + 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); + memset(&patch, 0, sizeof(patch)); + line[len - 1] = '\n'; + len = parse_git_header(&root, &linenr, 1, line, + len, size, &patch); + if (len < 0) + die(_("could not parse git header")); + 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); @@ -117,17 +142,13 @@ static int read_patches(const char *range, struct string_list *list) if (!(p = strstr(p, "@@"))) die(_("invalid hunk header in inner diff")); strbuf_addstr(&buf, 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 Fri Jul 5 17:06:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11033101 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 F06A1138D for ; Fri, 5 Jul 2019 17:07:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA08828A48 for ; Fri, 5 Jul 2019 17:07:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDA8928A86; Fri, 5 Jul 2019 17:07: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 604C128A48 for ; Fri, 5 Jul 2019 17:07:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727586AbfGERHQ (ORCPT ); Fri, 5 Jul 2019 13:07:16 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:36427 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727459AbfGERHO (ORCPT ); Fri, 5 Jul 2019 13:07:14 -0400 Received: by mail-wr1-f67.google.com with SMTP id n4so10640636wrs.3 for ; Fri, 05 Jul 2019 10:07:12 -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=a6wvmiwcN1lbUJpds7stAZn9MZbr7FrfWJV7GJLqgEY=; b=E58O7tPVjZ28ZIB/BQV4pNUiBFCq5jvTI/6gle6qhNcqHAYTLE/Xk/il2qVWL3PIi5 d+F781cNCJ6vL4Kk+mhfqXsNxW7WIGoJrjlGbywF7gHmczEKDq7urHRXZCqDXaJpQQnb aBrMmmLb5MMYtGvvWWnIto45yh8z/QI1TMaEYqHmbFMi0nvNVvx09YqWB7YlSxlVv6KZ yyXqS///GHrQczvCPX+yOCYYcRpS1BHwEJKY2RXRClcMUz5LrvcK31CbiOou+7egQqGL +Z16kc4bUVv7+/a5XL79kRrUtJwkVNprpW12XavNtME99u1Vx4Ob0NDwkVNFQ66lzU3Q S0fg== 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=a6wvmiwcN1lbUJpds7stAZn9MZbr7FrfWJV7GJLqgEY=; b=gRNLXFmnmeXebZ2wiV5JRrywF29tWeJuvGJYV9+5+E1OhuSpwPYlHy4XprDPu2J9Ep EBLbsuRb/UEmufsgl6ydo9x1jnwInTjI5UWutsdgO/MGF7c5fzl3YVoaRc4/QAXgO8SB ioMbZneB8vl00LLODkcgDgyK9XLC/IJKcvvVqRc4fWaWW+8COOD61e3Y8tdKD61vdZTF yY2lcWz/x6MIN/v2fsrBiYt8L+/ErDqWwnrCowLXQC5C40RtBYLlUfjPUMGApWvUHmfE +n9WNfCHn80hLmG0WtpcaAsq+ERsO2PMVOZUmO0CREeja6jpIxPXiPYRYtCuseIea18l r7Fg== X-Gm-Message-State: APjAAAXOml3fTm/9+83SWwi575UtRSeRoolGuVEu4SPqUFNeLawdVdpV 5ThGoHyKRDk5nUfolU3kv5WKYsTf X-Google-Smtp-Source: APXvYqxWrMAsSAyLHX0tnCzU17/SZAahVwAre+h2FJ77rq0BwP5i7YrwRcqLzKmAoBe60NTaaPraWA== X-Received: by 2002:a5d:4403:: with SMTP id z3mr5004082wrq.29.1562346431041; Fri, 05 Jul 2019 10:07:11 -0700 (PDT) Received: from localhost ([95.148.214.18]) by smtp.gmail.com with ESMTPSA id o24sm12494988wmh.2.2019.07.05.10.07.09 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 05 Jul 2019 10:07:10 -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 v2 13/14] range-diff: add filename to inner diff Date: Fri, 5 Jul 2019 18:06:29 +0100 Message-Id: <20190705170630.27500-14-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190705170630.27500-1-t.gummerer@gmail.com> References: <20190414210933.20875-1-t.gummerer@gmail.com/> <20190705170630.27500-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 | 14 ++++++++++++-- t/t3206-range-diff.sh | 16 ++++++++++------ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/range-diff.c b/range-diff.c index cc01f7f573..09cb1ddbb1 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, file = STRBUF_INIT; struct patch_util *util = NULL; int in_header = 1; - char *line; + char *line, *current_filename = NULL; int offset, len; size_t size; @@ -120,6 +120,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)", @@ -141,7 +147,10 @@ static int read_patches(const char *range, struct string_list *list) } else if (skip_prefix(line, "@@ ", &p)) { if (!(p = strstr(p, "@@"))) die(_("invalid hunk header in inner diff")); - strbuf_addstr(&buf, p); + strbuf_addstr(&buf, "@@"); + if (current_filename && p[2]) + strbuf_addf(&buf, " %s:", current_filename); + strbuf_addstr(&buf, p + 2); } else if (!line[0]) /* * A completely blank (not ' \n', which is context) @@ -172,6 +181,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 Fri Jul 5 17:06:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gummerer X-Patchwork-Id: 11033103 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 1C178138D for ; Fri, 5 Jul 2019 17:07:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04E8728A48 for ; Fri, 5 Jul 2019 17:07:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED6AE28A86; Fri, 5 Jul 2019 17:07: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 5ED1428A48 for ; Fri, 5 Jul 2019 17:07:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727546AbfGERHQ (ORCPT ); Fri, 5 Jul 2019 13:07:16 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:39790 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727510AbfGERHP (ORCPT ); Fri, 5 Jul 2019 13:07:15 -0400 Received: by mail-wr1-f68.google.com with SMTP id x4so10598391wrt.6 for ; Fri, 05 Jul 2019 10:07: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=FwmKo5F9XWK+RATPlC8vHDBTyjgZ96P6m5HL8HY1oZc=; b=MT0CaelE4xt8NQbPuMM0LlxqDI0muPXH4Jix+LWMHFryHVHJbBWq0WMjzLD8zpMLVw 8uQ/SJajy/6dVQuvutJuYEKFDuBE7Jf+tGzqHnpowzpWSJQwIGPSUHkg0vcG41a41Lyp x4hFweOV4gLTdkmr0ZSRCFjqRwzWuf6jrORMFvf1ad7cXo4Wdmr+6iw5T5lToK1TxhWT eorJxySqdUF9ksv/BmQn/i3lUHn8pCdwdfm4frh1LezqJAwNtOtmxVTnH6TXc4hZ995H WX3i5YOO8v2lgAT6rBJBOebvQIkVtlmgkZK3Z/I1QkXK4tipyhubDNSCu6pj5PLAl2bf wJpg== 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=FwmKo5F9XWK+RATPlC8vHDBTyjgZ96P6m5HL8HY1oZc=; b=gLGoFtBIdhmmCuBWbZibjY9c1Lrv+4iA1sRhrB7sBOBsCC8kQBu0iSanQY3gAitRML EIiRN/AfoRmmC8bWzLovEXf/jCb9OBWnmDMAG5p3fQTNxC7j8cRrQxnMiPkwQQ36xSyk Q/l+foYtDg53/IZu46vCY4JF8i2/xIBhxlbX5g9laeG5wr8Y5XXbfz/BkDHC5lWQEpJF 5rpL6/8N1tcLHeOHRug7nZGBf7gHq3JWNfpmOio9YIAhbqjD2qNNuijMevjP5E6qi3oP 8Z3VdizZx95vFs3IGgkvOwryj7nQKPc36k4TI6PQsJEBRFQQ56lRu/N58hPrnWEIKbtM sMSQ== X-Gm-Message-State: APjAAAXTPS6lM5CFwxmVkGW1DVpf5VjaHBXHf/dQclSnMkTanB0DwydW lBYCLZcNjjtZsz+rN4NZZrgXwoqP X-Google-Smtp-Source: APXvYqwE7gRPJDLueoCkoDw7KJ31AlnwdqDtlmN0FVTY9VaCLnt06SobioNqIvrq0AxQ0xGvGNll7w== X-Received: by 2002:a5d:55cc:: with SMTP id i12mr5012569wrw.201.1562346432544; Fri, 05 Jul 2019 10:07:12 -0700 (PDT) Received: from localhost ([95.148.214.18]) by smtp.gmail.com with ESMTPSA id b15sm1061294wrt.77.2019.07.05.10.07.11 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 05 Jul 2019 10:07: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 v2 14/14] range-diff: add headers to the outer hunk header Date: Fri, 5 Jul 2019 18:06:30 +0100 Message-Id: <20190705170630.27500-15-t.gummerer@gmail.com> X-Mailer: git-send-email 2.22.0.510.g264f2c817a In-Reply-To: <20190705170630.27500-1-t.gummerer@gmail.com> References: <20190414210933.20875-1-t.gummerer@gmail.com/> <20190705170630.27500-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 09cb1ddbb1..f43b229031 100644 --- a/range-diff.c +++ b/range-diff.c @@ -134,8 +134,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) @@ -396,8 +398,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) @@ -409,7 +412,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