From patchwork Tue Nov 13 18:55:56 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: 10681371 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 D1499109C for ; Tue, 13 Nov 2018 18:56:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C640B2B021 for ; Tue, 13 Nov 2018 18:56:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA99A2B36E; Tue, 13 Nov 2018 18:56: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 635FD2B021 for ; Tue, 13 Nov 2018 18:56:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730755AbeKNEzh (ORCPT ); Tue, 13 Nov 2018 23:55:37 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:54910 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726535AbeKNEzh (ORCPT ); Tue, 13 Nov 2018 23:55:37 -0500 Received: by mail-wm1-f66.google.com with SMTP id r63-v6so13118462wma.4 for ; Tue, 13 Nov 2018 10:56:11 -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=ki1B8XIaWQ3Wnqn0vuXbsgQ6UWyyXiUO+eEEqh6pCoo2tOperATMBfrEY2XkUp+2uG R11wVPJFt17Dg6Pj4JbOwX2NmIKVk+uDXCOFdFnxJGYQLfcNiI2wzOwTiuhKU3G7Bw4f U6tNquAc7l/TtAOx1Lqis1SEz6Ml28SXa6PfhMn+iTwalvfzoDxY6YM8XLwb1oQCUB9f YrSWlFI5rMEvwmZlIAj40Oy9sIlzgtnZ3MsxZB0/D/IKoyFiFOHsqULgtYSvqotRROPC 9lT7d1niQnCCphxzfQJticFK3SY7PtRwJUNYRcBbZcHKumb0XBCxEKKHHPavCVlT5h7o ikag== 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=ehLDIAVbltucchjybyAAq0kBDFNSoi0AtpIWN5bQOzgy/AKBOte71rIG+srr5RPBxm xZ8Me0uBoNaD5SpDGnrZX2LV4pHqVxi0npoBW9R1JkK2Qq6VQRNETvM3n741wZAfoEh+ IeJ5hu/AsOzL+FlUmAu3UkpZ+SGdxeberGQLGDzd22KUIxbRsVCFERLympZaVljo9FoG 4+jSga8j9O4bsdoaIwJs/9tTJV++w3u+4TtRT8FyI/0dygOkjiT8oPTVTe+NR66heZ/c N/ONWai/C+ai8zdGLcumuuS2KObs+Di5RiCBCpDzWvT7RjRyZA+tG4wJTWHSZFMq4lJz o84g== X-Gm-Message-State: AGRZ1gJs3cZDssjWWs3avGlbL5rtbel/ygMko8Hl9RnoXX5FXSxXEGgF 1yfejVXigwP1MBgzsgV3Y+FL3mMpjdE= X-Google-Smtp-Source: AJdET5e7iKdnUOlNtZtEdm+/iiqREU9HHoV7xOjpBVj/qGb9pcAgQHZ/LLa01lw2p7Nq1yCE3/fRgg== X-Received: by 2002:a1c:b7c4:: with SMTP id h187-v6mr4148176wmf.70.1542135370075; Tue, 13 Nov 2018 10:56:10 -0800 (PST) Received: from u.nix.is ([2a01:4f8:190:5095::2]) by smtp.gmail.com with ESMTPSA id y81-v6sm9908268wmd.11.2018.11.13.10.56.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Nov 2018 10:56:09 -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 v5 1/3] range-diff doc: add a section about output stability Date: Tue, 13 Nov 2018 18:55:56 +0000 Message-Id: <20181113185558.23438-2-avarab@gmail.com> X-Mailer: git-send-email 2.19.1.1182.g4ecb1133ce In-Reply-To: References: 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 Tue Nov 13 18:55:57 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: 10681373 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 94BF914E2 for ; Tue, 13 Nov 2018 18:56:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8975E2B021 for ; Tue, 13 Nov 2018 18:56:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E0052B36E; Tue, 13 Nov 2018 18:56:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F2492B021 for ; Tue, 13 Nov 2018 18:56:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730782AbeKNEzi (ORCPT ); Tue, 13 Nov 2018 23:55:38 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:43354 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730730AbeKNEzi (ORCPT ); Tue, 13 Nov 2018 23:55:38 -0500 Received: by mail-wr1-f66.google.com with SMTP id y3-v6so14505190wrh.10 for ; Tue, 13 Nov 2018 10:56:13 -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=O900/9S0+Zrc3mC8BVjTc2xhTYthoDDcnXjTO41Nkpk=; b=coWm3IT+8mZm4AgSjOW8wYsmjUiS/5MQz2Gzi6EvI5v2g7vG8E/zxF0ZS2q1/DNFAq ROKVUenKPi+pbwbrTXYaM2rRtXSznmWV74W4hGAVxuUaS32ayHy/jRYaVipfxG6RI/ak UVEVFqzahM/N3Qxx4I+cpnNG8phAQGI9xjwq5OsEj7slcWi/QEsWrDmo/09P2rzpS/AD j+7Sb8MHH99/2coqAPHLdLNwgPd1K8UoENv1gPaQuh6NY3wjQPKR+3J0B70HkSB95knr 8raZ3s1OHi2y6UABA0t3aVcXEs/qv2/S8dZeyl/RDJAssumAcLXJbtIe6xK2DMhXS9v7 n54A== 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=O900/9S0+Zrc3mC8BVjTc2xhTYthoDDcnXjTO41Nkpk=; b=Wo5QpWb+WsZyOoOBqIRieB37nhB0sKR/d8nLquBFk257gfLA2lUGjWXYtkj1VpCTAm lK9rBlP+p9fDvyEoN2BUXPoMQjsuVaC5MMiqR6zzEj2Nq7JpPHQE7mXLsf0OlfobCsBl mWNotoDycBk0oLv5S1VDApYrTP/B24+vN+k2c6DyS2UTOYWnppc6t3jkESwYey5qL3CT iBk/pAO62ydtYlxqLH3Ii8wGE95UNdB2nNZPCcUSt9oLxWqQTWCSMRNcu4rqQ923XT6E hhWGxNW+CYkEshpjA/4KjorPIiiWyDyQ7hQPFVuTNPsRnwF01ldyliAQ08qIbV+KR92u CYvw== X-Gm-Message-State: AGRZ1gIxUx7/T/jRJF7BFwwAaZYr9HbjrFVS1IjgfDGR+r6oa3AC90pE tYn9JRQg+q1in7CNJni91xwFjzMbDos= X-Google-Smtp-Source: AJdET5dJPm8IQI6r6XSbqpFDp+jJ/0zq+zZOCEwFi0o5jaahF7beedMivN32trB/qBmMQXPRd4TsSQ== X-Received: by 2002:adf:fa04:: with SMTP id m4-v6mr6269040wrr.155.1542135371937; Tue, 13 Nov 2018 10:56:11 -0800 (PST) Received: from u.nix.is ([2a01:4f8:190:5095::2]) by smtp.gmail.com with ESMTPSA id y81-v6sm9908268wmd.11.2018.11.13.10.56.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Nov 2018 10:56:11 -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 v5 2/3] range-diff: fix regression in passing along diff options Date: Tue, 13 Nov 2018 18:55:57 +0000 Message-Id: <20181113185558.23438-3-avarab@gmail.com> X-Mailer: git-send-email 2.19.1.1182.g4ecb1133ce In-Reply-To: References: 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 3958720f00..ec937008d0 100644 --- a/range-diff.c +++ b/range-diff.c @@ -461,7 +461,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 Tue Nov 13 18:55:58 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: 10681375 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 6FB7A14E2 for ; Tue, 13 Nov 2018 18:56:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 64D922B021 for ; Tue, 13 Nov 2018 18:56:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5929D2B36E; Tue, 13 Nov 2018 18:56: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 E62602B021 for ; Tue, 13 Nov 2018 18:56:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730848AbeKNEzl (ORCPT ); Tue, 13 Nov 2018 23:55:41 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:38223 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730730AbeKNEzk (ORCPT ); Tue, 13 Nov 2018 23:55:40 -0500 Received: by mail-wm1-f65.google.com with SMTP id f2-v6so12435084wme.3 for ; Tue, 13 Nov 2018 10:56:14 -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=IqWk7WSGS2xsaSuUsc3hwt34fNRZrZC9512AG9QgIrY=; b=bi0Wamg8xzw3gi2Mug4rupXfJDEsKovrLkuSS7LFCsaPkB+lspdwBsGB4P5qOdBtPM 5neHpM0NbuCN6I5uOyyaMDcp1ZAO/isPxTOo5AYegQYvhCg68oEiQKelQolfCo3R1cRo KNIAdHaMKDcTc4zC9cNUAMJN2Y4TJCZCJboODZs8zXn30pqHIJgD1WNQsJawBejHuMyR 5vfZrlrPMyzDZy9bhbqNhW3D/8iPKtbesLw1zq0AxTo8REnMx3Hc0TlEdXo8egn0zSJP ud4HUhdtMZ6WD+JaTTV+ckz0dFNNQxXJOJdVFIhVmYTcmT7uoBoW3kUiW1jfq796OMli eXqg== 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=IqWk7WSGS2xsaSuUsc3hwt34fNRZrZC9512AG9QgIrY=; b=d1//imrNCLPiR2RR5aXF5mqQwA7+5t1I2sudEhVh8jETjpNF5SuQmk72GjI8YItbco yvrHr1+JZDbj2KKoa5ZtRTNaqiPapGvUcpHzqhHYufQ0IZToRq+28aWEZMH3752A4o7b OcFzj2msGbebGEH0H0zgP+m5Xh0If7XPQA0FCrkD3PRoyUSS/69yCTiBYt09sEQ1BWDo 5lj5KkCNqguAUI2oV9tINxXokLvGwcrr/uyjrezFL1MhJiJvYwbqiSFsEfyiacLJtwnT mU3AKKzvH6ejnaK3rXNFXWN6vGO4TrYMCAUcUeUJPKXyDS4v0JlzThB6Ra9bmb11ftfR 8NCQ== X-Gm-Message-State: AGRZ1gIYMa9x7AwA0iKCBDwSb88b9vfdVvzdrr9Kv7tSUwAvrWYPiRfJ RvTJpHT7FJBiquWWdUZOQyBdjHDCbJc= X-Google-Smtp-Source: AJdET5cdGsJWI07FXADO4tO7PMDcYglbJPtvkv4cr7tGy4OVRDEeJumkjnmzYnWfk8HoiDvs0Z9MVg== X-Received: by 2002:a1c:2104:: with SMTP id h4-v6mr4116667wmh.130.1542135373609; Tue, 13 Nov 2018 10:56:13 -0800 (PST) Received: from u.nix.is ([2a01:4f8:190:5095::2]) by smtp.gmail.com with ESMTPSA id y81-v6sm9908268wmd.11.2018.11.13.10.56.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Nov 2018 10:56:12 -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 v5 3/3] range-diff: make diff option behavior (e.g. --stat) consistent Date: Tue, 13 Nov 2018 18:55:58 +0000 Message-Id: <20181113185558.23438-4-avarab@gmail.com> X-Mailer: git-send-email 2.19.1.1182.g4ecb1133ce In-Reply-To: References: 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 "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 | 23 ----------------------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/range-diff.c b/range-diff.c index ec937008d0..767af8c5bb 100644 --- a/range-diff.c +++ b/range-diff.c @@ -461,7 +461,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..e497c1358f 100755 --- a/t/t3206-range-diff.sh +++ b/t/t3206-range-diff.sh @@ -134,43 +134,20 @@ test_expect_success 'changed commit with --no-patch diff option' ' ' 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 '