From patchwork Fri Nov 9 10:18:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 10675681 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 11C0017D4 for ; Fri, 9 Nov 2018 10:18:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 028B12BC88 for ; Fri, 9 Nov 2018 10:18:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB02F2E87F; Fri, 9 Nov 2018 10:18:20 +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 89F382BC88 for ; Fri, 9 Nov 2018 10:18:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727700AbeKIT6O (ORCPT ); Fri, 9 Nov 2018 14:58:14 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39507 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727537AbeKIT6O (ORCPT ); Fri, 9 Nov 2018 14:58:14 -0500 Received: by mail-wr1-f66.google.com with SMTP id b13so1267857wrx.6 for ; Fri, 09 Nov 2018 02:18:18 -0800 (PST) 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=A+nUIoM+0aHiMZhJpgNsCn4eCKjDIuAVir5KDwfCs6Y=; b=VihBJLzT0IHdo28E9mvZ+WHi2W1DQqB9MLr2ckdGmt7im0RoU2vXdoqztxlg3UlPy/ wAwnpMZNhbEXFSkU0QJEoNidAKpdHo5DdoKzcVE9yLclOw+dss6mhbGcsEZUzcSExln/ CrpPvtiwMt6Jh4VpVY9UCE9RPOoBy3/f33esy/1l/jE8knmE+CgBz6/6/qb6TNS9Uv0s LdmGQ4ufGLIy3KaZ/r7/GV2le0YYEFjpkFk/0BfGtg0Xt1IUSV/HcpNjeAWJB/KJHZGF 63bmudMGXVNs0w0R6e8/IEhi8PptqeANfv4t5+ho9GFvHQuxNO8WHHszfswPB39U0wRE vmOQ== 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=A+nUIoM+0aHiMZhJpgNsCn4eCKjDIuAVir5KDwfCs6Y=; b=puh2mQ+ubVU/cy5p4fmRvwIR7BTZ47lwUsRrYRejIRiI4oqjFyBeNxS6ctLvgXS6pg QsX3pVNaJYQnN6uWJsDUS1E8FpBpG5y4ZcCKYSfa9buWwBAApTkkYC4z41pYLgf5Wsnm g15ZI60HKAHJzGKG8qEpH1Ct68Y3a7cKkoHy66NdZcs+gBaFsdJOOcY1BG1sZWSE4lez jZ+/Vk4/wPGlmFos4Ic9FflaHeGRmXmYPxjKGjPEuPXLcGo6+PHvYkIduwOyZICJf7t0 Xb88NDXGAimcaIdO5Mfy4/XdUxkFu+VFSczeJ/2Qw1oXlPV9e8g4+L6bEo3AsdVJ7jQM Lwkw== X-Gm-Message-State: AGRZ1gL3Tx4Pscrmd1db/PZbJpHaboTVrp3AdmeGjPgsjg2uiHqBoKcZ vXLO/c6ZJ6nQuceS2Uf/8E9AQKSvQRk= X-Google-Smtp-Source: AJdET5fs8lY5JO5DadnizpqBT3GhVnHw2hXz9fr6rEhMmF9rFq2Ardch0X81KIldFX24TNFefmlGdw== X-Received: by 2002:adf:da41:: with SMTP id r1-v6mr5307211wrl.129.1541758697193; Fri, 09 Nov 2018 02:18:17 -0800 (PST) Received: from u.nix.is ([2a01:4f8:190:5095::2]) by smtp.gmail.com with ESMTPSA id h4-v6sm5662020wrt.76.2018.11.09.02.18.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Nov 2018 02:18:16 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Lucas De Marchi , Stefan Beller , Eric Sunshine , Johannes Schindelin , Stephen & Linda Smith , =?utf-8?q?Martin_=C3=85gren?= , =?utf-8?b?w4Z2YXIg?= =?utf-8?b?QXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v4 1/3] range-diff doc: add a section about output stability Date: Fri, 9 Nov 2018 10:18:01 +0000 Message-Id: <20181109101803.3038-2-avarab@gmail.com> X-Mailer: git-send-email 2.19.1.1182.g4ecb1133ce In-Reply-To: <20181107122202.1813-3-avarab@gmail.com> References: <20181107122202.1813-3-avarab@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 range-diff command is already advertised as porcelain, but let's make it really clear that the output is completely subject to change, particularly when it comes to diff options such as --stat. Right now that option doesn't work, but fixing that is the subject of a later change. Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/git-range-diff.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Documentation/git-range-diff.txt b/Documentation/git-range-diff.txt index f693930fdb..8a6ea2c6c5 100644 --- a/Documentation/git-range-diff.txt +++ b/Documentation/git-range-diff.txt @@ -78,6 +78,23 @@ between patches", i.e. to compare the author, commit message and diff of corresponding old/new commits. There is currently no means to tweak the diff options passed to `git log` when generating those patches. +OUTPUT STABILITY +---------------- + +The output of the `range-diff` command is subject to change. It is +intended to be human-readable porcelain output, not something that can +be used across versions of Git to get a textually stable `range-diff` +(as opposed to something like the `--stable` option to +linkgit:git-patch-id[1]). There's also no equivalent of +linkgit:git-apply[1] for `range-diff`, the output is not intended to +be machine-readable. + +This is particularly true when passing in diff options. Currently some +options like `--stat` can, as an emergent effect, produce output +that's quite useless in the context of `range-diff`. Future versions +of `range-diff` may learn to interpret such options in a manner +specific to `range-diff` (e.g. for `--stat` producing human-readable +output which summarizes how the diffstat changed). CONFIGURATION ------------- From patchwork Fri Nov 9 10:18:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 10675683 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 DF9F413AD for ; Fri, 9 Nov 2018 10:18:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDEF92D192 for ; Fri, 9 Nov 2018 10:18:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2BE12E875; Fri, 9 Nov 2018 10:18:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DFC32E87F for ; Fri, 9 Nov 2018 10:18:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727752AbeKIT6Q (ORCPT ); Fri, 9 Nov 2018 14:58:16 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:46393 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727537AbeKIT6Q (ORCPT ); Fri, 9 Nov 2018 14:58:16 -0500 Received: by mail-wr1-f66.google.com with SMTP id 74-v6so1267402wrb.13 for ; Fri, 09 Nov 2018 02:18:19 -0800 (PST) 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=FfVr+AlR+GLQAFqd/HyREFZ07DF/QlSd1crf+snlTo0=; b=V3kZjZuS9VCwtMV5Hvjk1z/NOPAm4Eyk5vSnHxLdllq43pzVobgVZrOfBxZ22xaRq7 darI/fUegN7A4xfRUKD/xhXhvg2qGYnokYSfFf14KUQI8JmVuFC7yVsdccK01k6qWPGg zjCj8W5niykCBc5vTPdQ9BAS3Xp0L0yoHn540/csH9Tu4NERsplHb9XHPcaUwRSMxlj4 ksDSs2aWR4KSwGDIlRPa/xLRszJmlpZKyQGzNaK6aQ1VaJFp+ymFrvpHzUiV+7RiZF4E B6oZmPbhBcjsk6yMQJg00it/V8H/rCPoe8JkjkagrIEwEZANUJKbxMemCGNM3ajgL/gw eDYA== 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=FfVr+AlR+GLQAFqd/HyREFZ07DF/QlSd1crf+snlTo0=; b=KiK1A7GxvyMyI8XLRhhvakjLoaHH+bMahs7/H/InpfEhsNj8MCiJEVtkALqJycWNeW DgjCsZPlcsG6vrhDaSTa5MRs4zMOCHE49xbKqR5wE5CfyZXwq0mcZRMGEkxOhPmnx99j 5tEDl1d+vyoD2AWngfK6RCBp+jfV0gvlLerrHf3+gN3OAvGSbz3yoQu3zBjFf0dSGwtO eLRjhW7SJ/Ph1kY+q5n0h2yVyL6a/DOVKkKl3sql2UTJ6JKJvsoBqhtfU6Tl0kUwYIbd hEsOURfNubKNzNmE9CwzxJMnrI/I8GvHgRVn7v21o5qOzp/XfBGbdASj56jXFz9vDdNE Tqew== X-Gm-Message-State: AGRZ1gJVACnX2h72D0gyInUOh+HzLV6ulo4H2wwaQ0ns19S7orsBeiGc wJFbqtV4fGqShWCRXQiH/Ft6ty2Cyn8= X-Google-Smtp-Source: AJdET5eH/g+aseNVRxgFAXXuIR1JAw3oZ5iu2g0L+20Tq52xsn/j487Dfj35FtdmFZ5JKFazfmhyKg== X-Received: by 2002:adf:b612:: with SMTP id f18-v6mr6946193wre.120.1541758698716; Fri, 09 Nov 2018 02:18:18 -0800 (PST) Received: from u.nix.is ([2a01:4f8:190:5095::2]) by smtp.gmail.com with ESMTPSA id h4-v6sm5662020wrt.76.2018.11.09.02.18.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Nov 2018 02:18:18 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Lucas De Marchi , Stefan Beller , Eric Sunshine , Johannes Schindelin , Stephen & Linda Smith , =?utf-8?q?Martin_=C3=85gren?= , =?utf-8?b?w4Z2YXIg?= =?utf-8?b?QXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v4 2/3] range-diff: fix regression in passing along diff options Date: Fri, 9 Nov 2018 10:18:02 +0000 Message-Id: <20181109101803.3038-3-avarab@gmail.com> X-Mailer: git-send-email 2.19.1.1182.g4ecb1133ce In-Reply-To: <20181107122202.1813-3-avarab@gmail.com> References: <20181107122202.1813-3-avarab@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 73a834e9e2 ("range-diff: relieve callers of low-level configuration burden", 2018-07-22) we broke passing down options like --no-patch, --stat etc. Fix that regression, and add a test asserting the pre-73a834e9e2 behavior for some of these diff options. As noted in a change leading up to this ("range-diff doc: add a section about output stability", 2018-11-07) the output is not meant to be stable. So this regression test will likely need to be tweaked once we get a "proper" --stat option. See https://public-inbox.org/git/nycvar.QRO.7.76.6.1811071202480.39@tvgsbejvaqbjf.bet/ for a further explanation of the regression. The fix here is not the same as in Johannes's on-list patch, for reasons that'll be explained in a follow-up commit. The quoting of "EOF" here mirrors that of an earlier test. Perhaps that should be fixed, but let's leave that up to a later cleanup change. Signed-off-by: Ævar Arnfjörð Bjarmason --- range-diff.c | 2 +- t/t3206-range-diff.sh | 53 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/range-diff.c b/range-diff.c index bd8083f2d1..ea317f92f9 100644 --- a/range-diff.c +++ b/range-diff.c @@ -453,7 +453,7 @@ int show_range_diff(const char *range1, const char *range2, struct strbuf indent = STRBUF_INIT; memcpy(&opts, diffopt, sizeof(opts)); - opts.output_format = DIFF_FORMAT_PATCH; + opts.output_format |= DIFF_FORMAT_PATCH; opts.flags.suppress_diff_headers = 1; opts.flags.dual_color_diffed_diffs = dual_color; opts.output_prefix = output_prefix_cb; diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh index 6aae364171..ab44e085d5 100755 --- a/t/t3206-range-diff.sh +++ b/t/t3206-range-diff.sh @@ -122,6 +122,59 @@ test_expect_success 'changed commit' ' test_cmp expected actual ' +test_expect_success 'changed commit with --no-patch diff option' ' + git range-diff --no-color --no-patch topic...changed >actual && + cat >expected <<-EOF && + 1: 4de457d = 1: a4b3333 s/5/A/ + 2: fccce22 = 2: f51d370 s/4/A/ + 3: 147e64e ! 3: 0559556 s/11/B/ + 4: a63e992 ! 4: d966c5c s/12/B/ + EOF + test_cmp expected actual +' + +test_expect_success 'changed commit with --stat diff option' ' + four_spaces=" " && + git range-diff --no-color --stat topic...changed >actual && + cat >expected <<-EOF && + 1: 4de457d = 1: a4b3333 s/5/A/ + a => b | 0 + 1 file changed, 0 insertions(+), 0 deletions(-) + $four_spaces + 2: fccce22 = 2: f51d370 s/4/A/ + a => b | 0 + 1 file changed, 0 insertions(+), 0 deletions(-) + $four_spaces + 3: 147e64e ! 3: 0559556 s/11/B/ + a => b | 0 + 1 file changed, 0 insertions(+), 0 deletions(-) + $four_spaces + @@ -10,7 +10,7 @@ + 9 + 10 + -11 + -+B + ++BB + 12 + 13 + 14 + 4: a63e992 ! 4: d966c5c s/12/B/ + a => b | 0 + 1 file changed, 0 insertions(+), 0 deletions(-) + $four_spaces + @@ -8,7 +8,7 @@ + @@ + 9 + 10 + - B + + BB + -12 + +B + 13 + EOF + test_cmp expected actual +' + test_expect_success 'changed commit with sm config' ' git range-diff --no-color --submodule=log topic...changed >actual && cat >expected <<-EOF && From patchwork Fri Nov 9 10:18:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 10675685 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 58E3C1709 for ; Fri, 9 Nov 2018 10:18:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49D8E2DC36 for ; Fri, 9 Nov 2018 10:18:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E74C2E875; Fri, 9 Nov 2018 10:18:24 +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 D09E02E87F for ; Fri, 9 Nov 2018 10:18:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727789AbeKIT6R (ORCPT ); Fri, 9 Nov 2018 14:58:17 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:42892 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727537AbeKIT6R (ORCPT ); Fri, 9 Nov 2018 14:58:17 -0500 Received: by mail-wr1-f68.google.com with SMTP id y15-v6so1278687wru.9 for ; Fri, 09 Nov 2018 02:18:21 -0800 (PST) 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=mMdrYOHSkzOerqOqrJjJZiWtLionYi5tvdp5oyWnnI4=; b=idIDR6jAyz8dzCSwivBqH1BPlxuUiT904w1Wt1Y8Aa1KruXbecG9qkFMxWC+PHoveO K6Q8vhC+25OCmqERjabRbRX8oNLj1Tcr+wzdz+nRtECy+50inh6FEHsnh1ydwN9L7PAK BGzjisVqusZvmnpvqs1lfovKVrD2wmyLHEpx3N2VU9aL4RRw1kIjUZ1xX/kB2NLmviiO uJAhwh77qioGGtaOzhS12zNSjDlVtt+KHElAQNUH9A8d475/D6W1Uh3+RhYHj92p9Qvq QTqbMN1HymCGcZWe5tjb4m7fiLEBjH5+CgjNiFKgf+dpycIVwgHNEiD6E8aKDcj0NemW CElQ== 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=mMdrYOHSkzOerqOqrJjJZiWtLionYi5tvdp5oyWnnI4=; b=H6eWZQ9rYAO8U/UuT8n3c7n8lLbp8mJaoGkZNHZ1Jl5RZA2ACN2BDYfR7r2f3P2J18 1lhJeS87GMNvgtLRF0lMJQMnK4AOClNAYlf6ugEsWWi9FMJ1LlVNBAxTwCQrcv8E7/Hr XTFOtzubK5KDMCnO20WNTSLDqln70DwVH1LLazIuypwzMWx144xNri1DN+/zUB9d8n9d Q7JHwvdxlWKd/q5NRFwvWMzvJjiihX0lGHEu0vujVBjn0yU2mfiO+cD754b7JrLMI9vk +Or9j91QU7m6lOBN2jYS7SZUKqqfw1lZ3n2ecqDIr9IjL5MfqN/zfO1fvppoRI10hAmU qSxg== X-Gm-Message-State: AGRZ1gKM5Z15PPkaDsrj2ScKjoZZ3E1bNyiXCVd1UlvqEl4fmQAEaRqL Yth5LWi/P9feLo4/tZbAj7sm6/3bRD0= X-Google-Smtp-Source: AJdET5cKaJ5WX9mG89RbJo+ZL81l3YwxFEgdgTS4jN2GEaK+eaReLZP8fFvPxGo4HHfKB+sba9F7Kg== X-Received: by 2002:adf:8b0a:: with SMTP id n10-v6mr6978983wra.282.1541758700223; Fri, 09 Nov 2018 02:18:20 -0800 (PST) Received: from u.nix.is ([2a01:4f8:190:5095::2]) by smtp.gmail.com with ESMTPSA id h4-v6sm5662020wrt.76.2018.11.09.02.18.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Nov 2018 02:18:19 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Lucas De Marchi , Stefan Beller , Eric Sunshine , Johannes Schindelin , Stephen & Linda Smith , =?utf-8?q?Martin_=C3=85gren?= , =?utf-8?b?w4Z2YXIg?= =?utf-8?b?QXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v4 3/3] range-diff: make diff option behavior (e.g. --stat) consistent Date: Fri, 9 Nov 2018 10:18:03 +0000 Message-Id: <20181109101803.3038-4-avarab@gmail.com> X-Mailer: git-send-email 2.19.1.1182.g4ecb1133ce In-Reply-To: <20181107122202.1813-3-avarab@gmail.com> References: <20181107122202.1813-3-avarab@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 the behavior when diff options (e.g. "--stat") are passed consistent with how "diff" behaves. Before 73a834e9e2 ("range-diff: relieve callers of low-level configuration burden", 2018-07-22) running range-diff with "--stat" would produce stat output and the diff output, as opposed to how "diff" behaves where once "--stat" is specified "--patch" also needs to be provided to emit the patch output. As noted in a previous change ("range-diff doc: add a section about output stability", 2018-11-07) the "--stat" output with "range-diff" is useless at the moment. But we should behave consistently with "diff" in anticipation of such output being useful in the future, because it would make for confusing UI if two "diff" and "range-diff" behaved differently when it came to how they interpret diff options. The new behavior is also consistent with the existing documentation added in ba931edd28 ("range-diff: populate the man page", 2018-08-13). See "[...]also accepts the regular diff options[...]" in git-range-diff(1). Signed-off-by: Ævar Arnfjörð Bjarmason --- range-diff.c | 3 ++- t/t3206-range-diff.sh | 22 ---------------------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/range-diff.c b/range-diff.c index ea317f92f9..72bde281f3 100644 --- a/range-diff.c +++ b/range-diff.c @@ -453,7 +453,8 @@ int show_range_diff(const char *range1, const char *range2, struct strbuf indent = STRBUF_INIT; memcpy(&opts, diffopt, sizeof(opts)); - opts.output_format |= DIFF_FORMAT_PATCH; + if (!opts.output_format) + opts.output_format |= DIFF_FORMAT_PATCH; opts.flags.suppress_diff_headers = 1; opts.flags.dual_color_diffed_diffs = dual_color; opts.output_prefix = output_prefix_cb; diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh index ab44e085d5..9352f65280 100755 --- a/t/t3206-range-diff.sh +++ b/t/t3206-range-diff.sh @@ -140,37 +140,15 @@ test_expect_success 'changed commit with --stat diff option' ' 1: 4de457d = 1: a4b3333 s/5/A/ a => b | 0 1 file changed, 0 insertions(+), 0 deletions(-) - $four_spaces 2: fccce22 = 2: f51d370 s/4/A/ a => b | 0 1 file changed, 0 insertions(+), 0 deletions(-) - $four_spaces 3: 147e64e ! 3: 0559556 s/11/B/ a => b | 0 1 file changed, 0 insertions(+), 0 deletions(-) - $four_spaces - @@ -10,7 +10,7 @@ - 9 - 10 - -11 - -+B - ++BB - 12 - 13 - 14 4: a63e992 ! 4: d966c5c s/12/B/ a => b | 0 1 file changed, 0 insertions(+), 0 deletions(-) - $four_spaces - @@ -8,7 +8,7 @@ - @@ - 9 - 10 - - B - + BB - -12 - +B - 13 EOF test_cmp expected actual '