From patchwork Tue May 9 00:44:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13235259 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52922C77B7F for ; Tue, 9 May 2023 00:44:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229797AbjEIAoM (ORCPT ); Mon, 8 May 2023 20:44:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229690AbjEIAoK (ORCPT ); Mon, 8 May 2023 20:44:10 -0400 Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C53416188 for ; Mon, 8 May 2023 17:44:09 -0700 (PDT) Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-38ded2d8bcaso2962392b6e.0 for ; Mon, 08 May 2023 17:44:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683593049; x=1686185049; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZFJ+p8tOTy270hdJxBpEn7dvYHCTDRbvOCibg0nhmTs=; b=SL/ln81LDL48a2yQZV1wcinR915RdxiDlIhD8mVWnmDo4fefs3O9hMoaslknFE9AiP Hm1zaaPjJ6wMVyuvg9WlKIXX8+J6WRZ6kwqaARr9ACn6KjLGe/xQafhuZt5qvv51OasB 91s1F5uOoeN+egsZNLWjuq3U4ZbEUzeNIQc4JuKwFptuYsd5ZNc2bgsKXXsAvTa5tNni 8FugPvk9PHRCsTzKc6kkhXxHBN6RX795A/Iok89olMUlUbI1UmXetKeCpqdP4i69b8i6 IPir0fM9eCFqAA3E3/68qXX+nSq9O0Axwh+Iu3Kj9Jj5HB2nXq9gyjqE2v2gdX60qVk4 6Bzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683593049; x=1686185049; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZFJ+p8tOTy270hdJxBpEn7dvYHCTDRbvOCibg0nhmTs=; b=N5aIXb9eumOu/IkWRe3u1UUvBsMoxU443cb3yFpCDipDWRiBfSt+cn0FqU207VcIfW H1mQ8OepvTAWXpg1+IgrzuAQeeyIyZRvqxayVvop44lIF8MxJyw4YcsFmhWXBrHiG9Y7 sAjlkKBrqEutD5GhHhUYA/1jj0V+rZT0WO5G/SZMkJD/kji3+FNeeN8TpKd4OeBs2iz3 Fhw9KDtomkMMYQnsPEDnkwT20om84g27g8si4XbdlKPrYXpUXls/ord/0nFbg6/CjKfj QlIy0KmRgqu6Zac+b12Kniba4dyz2gisTfgilaIvwjb2NRdzjFa9KcnpsX0MTtp3oq5B 6GMA== X-Gm-Message-State: AC+VfDwluvNfGNh1eJReA7ujUX0GEeUFaghx82mnxaxwRmFbHEnbs986 +C4i7Smm7oz5u8bvdW54kZQsZPxowtc= X-Google-Smtp-Source: ACHHUZ5w//rKW9p6lNrSRXdUGQD8Upd8dUD8XM0SOSTCZViOEOwf47kguSHbdzsbWHdBC4OlbXGBJg== X-Received: by 2002:a05:6808:3a8b:b0:388:fff3:61e6 with SMTP id fb11-20020a0568083a8b00b00388fff361e6mr452828oib.38.1683593048831; Mon, 08 May 2023 17:44:08 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id i1-20020aca0c41000000b003908004b37dsm597407oiy.26.2023.05.08.17.44.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 May 2023 17:44:08 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Sergey Organov , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 1/4] t4013: add expected failure for "log --patch --no-patch" Date: Mon, 8 May 2023 18:44:03 -0600 Message-Id: <20230509004406.1786033-2-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.40.0+fc1 In-Reply-To: <20230509004406.1786033-1-felipe.contreras@gmail.com> References: <20230509004406.1786033-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Sergey Organov --patch followed by --no-patch is to be a no-op according to the "git log" manual page. In reality this sequence breaks --raw output though (and who knows what else?) Add a test_expected_failure case for the issue. Signed-off-by: Sergey Organov Signed-off-by: Felipe Contreras --- t/t4013-diff-various.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index 5de1d19075..f876b0cc8e 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -457,6 +457,17 @@ diff-tree --stat --compact-summary initial mode diff-tree -R --stat --compact-summary initial mode EOF +# This should succeed as --patch followed by --no-patch sequence is to +# be a no-op according to the manual page. In reality it breaks --raw +# though. Needs to be fixed. +test_expect_failure '--no-patch cancels --patch only' ' + git log --raw master >result && + process_diffs result >expected && + git log --patch --no-patch --raw >result && + process_diffs result >actual && + test_cmp expected actual +' + test_expect_success 'log -m matches pure log' ' git log master >result && process_diffs result >expected && From patchwork Tue May 9 00:44:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13235260 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C89CC7EE22 for ; Tue, 9 May 2023 00:44:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230093AbjEIAoQ (ORCPT ); Mon, 8 May 2023 20:44:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229845AbjEIAoM (ORCPT ); Mon, 8 May 2023 20:44:12 -0400 Received: from mail-oo1-xc30.google.com (mail-oo1-xc30.google.com [IPv6:2607:f8b0:4864:20::c30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16FFF59EE for ; Mon, 8 May 2023 17:44:11 -0700 (PDT) Received: by mail-oo1-xc30.google.com with SMTP id 006d021491bc7-54cbb666aa5so2759025eaf.1 for ; Mon, 08 May 2023 17:44:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683593050; x=1686185050; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NeTtSvLWvKq63jLFgDFyDhx6WIlw4bVy6Kht1V0/E5s=; b=fWNCLr1DOD+eHkUpU7zUXbHVt1AaMmgTxlc9lLjjB14X1T9Oubjjcvzg68K2lF6gJP Nbif2+YCv6KHtrbtNeC/pMP+8R5fY2jPhQtFfhNb9uLKvW+x21Vt7JJT3UPaza8SCtmh 871iZO6hlZgawYR5uJnm95J93rUQLPRXYKLtPP6fbCK88QTHEr1u4Dbt2olxX9Z1iWp1 hF5M566blK+aKRdA37U4l1CiNfw9+0AqVKujZ6jWzkdexTzwuf491UFTi9QsQocvICnS /EuAAVZT0AXSrEEz34BsZR2oRD5e+thSGbvEGGq5hTpF0B5WXsVgXJPndaLJ12sXgAPq AwXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683593050; x=1686185050; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NeTtSvLWvKq63jLFgDFyDhx6WIlw4bVy6Kht1V0/E5s=; b=R8ZMe7G3r++NT1v2+LynYlmjQ9MFp++4KDrOU7Uoeok/IKf1Ve02Hq94x+4IigsKyq w0CkX1NNkmxuqm4NKg8OsQQ/XQom+l64jFguGZdZN/u/yF63jBwPp90pmcxKYlPmTMj9 W1wgIB4868TPEZfWOVUzMEXNvsc/lUdxKQpu0rRlkMiQLuuK+PPzOePll6SS+u5GiDsq 1f2BmM2BGoiwdps9f4JcuotX8kCeiyalIzgh2DKpLkV5OrVNBs66+2kTeGj1GlpOESev LDVpnGHkcIkqZqFVD/Zp6V0alF7Y6S4kUoEHytNFe0QupY60dNSOTDV+gHfk4hKoLV9u 5g8Q== X-Gm-Message-State: AC+VfDyZU3em/OFJh0rL1kZsJrtAbcwgj9gImODJpepbvDAyVjmubqTR a9Vq8dRKWGT2dlxCwkeEJDnrLZ5+SEo= X-Google-Smtp-Source: ACHHUZ643xk0qHhs+x4hdLErSUwG5/9w9etH6Izf7BFImZywp1wzZW61uzcMtNB+T3W9/ay9fJNBaQ== X-Received: by 2002:a4a:9c4d:0:b0:54f:629a:f581 with SMTP id c13-20020a4a9c4d000000b0054f629af581mr393633ook.7.1683593050082; Mon, 08 May 2023 17:44:10 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id f17-20020a9d5e91000000b006a647f65d03sm4836564otl.41.2023.05.08.17.44.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 May 2023 17:44:09 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Sergey Organov , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 2/4] line-log: set patch format explicitly by default Date: Mon, 8 May 2023 18:44:04 -0600 Message-Id: <20230509004406.1786033-3-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.40.0+fc1 In-Reply-To: <20230509004406.1786033-1-felipe.contreras@gmail.com> References: <20230509004406.1786033-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Will help further changes. No functional changes. Signed-off-by: Felipe Contreras --- builtin/log.c | 5 +++++ line-log.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/builtin/log.c b/builtin/log.c index 4f162ff4d0..568207916b 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -889,6 +889,11 @@ int cmd_log(int argc, const char **argv, const char *prefix) opt.revarg_opt = REVARG_COMMITTISH; opt.tweak = log_setup_revisions_tweak; cmd_log_init(argc, argv, prefix, &rev, &opt); + + if (!rev.diffopt.output_format) + if (rev.line_level_traverse) + rev.diffopt.output_format = DIFF_FORMAT_PATCH; + return cmd_log_deinit(cmd_log_walk(&rev), &rev); } diff --git a/line-log.c b/line-log.c index 10c19daec4..4499fd0c59 100644 --- a/line-log.c +++ b/line-log.c @@ -1140,7 +1140,7 @@ int line_log_print(struct rev_info *rev, struct commit *commit) { show_log(rev); - if (!(rev->diffopt.output_format & DIFF_FORMAT_NO_OUTPUT)) { + if (rev->diffopt.output_format & DIFF_FORMAT_PATCH) { struct line_log_data *range = lookup_line_range(rev, commit); dump_diff_hacky(rev, range); } From patchwork Tue May 9 00:44:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13235261 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BBE86C7EE22 for ; Tue, 9 May 2023 00:44:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230099AbjEIAoV (ORCPT ); Mon, 8 May 2023 20:44:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229884AbjEIAoP (ORCPT ); Mon, 8 May 2023 20:44:15 -0400 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7683B72A6 for ; Mon, 8 May 2023 17:44:12 -0700 (PDT) Received: by mail-oi1-x22a.google.com with SMTP id 5614622812f47-38e7ce73ca0so2575775b6e.2 for ; Mon, 08 May 2023 17:44:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683593051; x=1686185051; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2Jvf09mIbxCSwWervwM0gqUIUoW/eOPVTzLRShPiJHc=; b=A+AcFgTiurCwY/s+VUhMUcK7T7nTxaJIS2tEMvoHlzICPVR3VmtLgiNUMK0i85fjbs cWUECzYkVqGAKAOZ5vKLsTG7GTI6iRoKa9+Hk5GW9ZDOFxtQt2BddQU8cWuGmnh04Oq0 QmJPhRaC5D7PW+pxDsdwFLeDM8adqEqdLqANhJsYj8vuANxreuwkiu19o2KlFvaSpW86 j6s5+e5+8acMTrROiwZCl8iDqgY7coh0VunhP1DbzAc9291avhB6ijBwTeX4NiWoJ6OM cyTFFTmBu/dUqgHXU2IzJmUp/OY4HeVqU8mXsmTh/DAta+f2GJyUXbBaHdeKB+WwOWf6 mt2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683593051; x=1686185051; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2Jvf09mIbxCSwWervwM0gqUIUoW/eOPVTzLRShPiJHc=; b=kA11bBi5QU/FGlmmxJ52oIWOUAzITnpWp+qsQMGYjiSYA2l4wlOst7Pg6PXgY/ypIP CP00/uhvn5DtWieaQ+5wTyl5obDm8GA3SXsX988C9Ya2gENwo8WU1fvgDbb4EBwbkWwH 8ghQ9rY2yMV4O3o53p/RByliiGtDGjRr/3xFCDb56coN1qOXgVL6nAZPufSKYFSz8cXi 67GOrL2MJXbI8/d83yBZFwqfl8cEw3wl5z/ampCukW/ltFBEgMroW6GdmiXY7dagkbRt 9mttg90ldh4RuHVgA7Uf5xPRfAmCYgmUmO1/7hG19PO9/i+DQlxOliawEyLZHi7xZAjj XDzw== X-Gm-Message-State: AC+VfDzwt0nspL4jY0pZx+A7nIvUCtJ6ZtYdQM6olW8J39wgd1FEXVoT mf7eSc3DhS98vRESpzXBkmPRZX0dSB4= X-Google-Smtp-Source: ACHHUZ4ulvyolO8gGtHXbkicoDP+BSDo/6XNqvrKIt8JY2KwIe6bbonWa00VbMgnzNveSpJOHPg7nA== X-Received: by 2002:aca:1803:0:b0:392:3ba:3a28 with SMTP id h3-20020aca1803000000b0039203ba3a28mr476404oih.11.1683593051331; Mon, 08 May 2023 17:44:11 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id x132-20020acae08a000000b0038c66c39131sm647533oig.5.2023.05.08.17.44.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 May 2023 17:44:10 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Sergey Organov , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 3/4] diff: introduce DIFF_FORMAT_DEFAULT Date: Mon, 8 May 2023 18:44:05 -0600 Message-Id: <20230509004406.1786033-4-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.40.0+fc1 In-Reply-To: <20230509004406.1786033-1-felipe.contreras@gmail.com> References: <20230509004406.1786033-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org As the name suggests this is the default format, which means no format was specified. This is not the same as DIFF_FORMAT_PATCH, as some commands like `git diff-files` use a different default. This makes it possible to distinguish `git diff` (DEFAULT) from `git diff --no-patch` (0). Will help further changes. There should be no functional changes. Signed-off-by: Felipe Contreras --- builtin/diff-files.c | 2 +- builtin/diff-index.c | 2 +- builtin/diff-tree.c | 2 +- builtin/diff.c | 2 +- builtin/log.c | 13 ++++++++----- builtin/stash.c | 2 +- diff-merges.c | 2 +- diff-no-index.c | 2 +- diff.c | 39 ++++++++++++++++++++------------------- diff.h | 1 + range-diff.c | 2 +- revision.c | 4 ++-- 12 files changed, 39 insertions(+), 34 deletions(-) diff --git a/builtin/diff-files.c b/builtin/diff-files.c index dc991f753b..b831b89236 100644 --- a/builtin/diff-files.c +++ b/builtin/diff-files.c @@ -52,7 +52,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix) usage(diff_files_usage); argv++; argc--; } - if (!rev.diffopt.output_format) + if (rev.diffopt.output_format == DIFF_FORMAT_DEFAULT) rev.diffopt.output_format = DIFF_FORMAT_RAW; rev.diffopt.rotate_to_strict = 1; diff --git a/builtin/diff-index.c b/builtin/diff-index.c index b9a19bb7d3..863c51c9b5 100644 --- a/builtin/diff-index.c +++ b/builtin/diff-index.c @@ -48,7 +48,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix) else usage(diff_cache_usage); } - if (!rev.diffopt.output_format) + if (rev.diffopt.output_format == DIFF_FORMAT_DEFAULT) rev.diffopt.output_format = DIFF_FORMAT_RAW; rev.diffopt.rotate_to_strict = 1; diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c index 385c2d0230..75e5e96d05 100644 --- a/builtin/diff-tree.c +++ b/builtin/diff-tree.c @@ -99,7 +99,7 @@ COMMON_DIFF_OPTIONS_HELP; static void diff_tree_tweak_rev(struct rev_info *rev, struct setup_revision_opt *opt) { - if (!rev->diffopt.output_format) { + if (rev->diffopt.output_format == DIFF_FORMAT_DEFAULT) { if (rev->dense_combined_merges) rev->diffopt.output_format = DIFF_FORMAT_PATCH; else diff --git a/builtin/diff.c b/builtin/diff.c index 5a6a5d7f4b..a01de13194 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -504,7 +504,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix) if (nongit) die(_("Not a git repository")); argc = setup_revisions(argc, argv, &rev, NULL); - if (!rev.diffopt.output_format) { + if (rev.diffopt.output_format == DIFF_FORMAT_DEFAULT) { rev.diffopt.output_format = DIFF_FORMAT_PATCH; diff_setup_done(&rev.diffopt); } diff --git a/builtin/log.c b/builtin/log.c index 568207916b..13c196c391 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -276,7 +276,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix, PARSE_OPT_KEEP_DASHDASH); if (quiet) - rev->diffopt.output_format |= DIFF_FORMAT_NO_OUTPUT; + rev->diffopt.output_format = DIFF_FORMAT_NO_OUTPUT; argc = setup_revisions(argc, argv, rev, opt); /* Any arguments at this point are not recognized */ @@ -632,7 +632,7 @@ int cmd_whatchanged(int argc, const char **argv, const char *prefix) opt.def = "HEAD"; opt.revarg_opt = REVARG_COMMITTISH; cmd_log_init(argc, argv, prefix, &rev, &opt); - if (!rev.diffopt.output_format) + if (rev.diffopt.output_format == DIFF_FORMAT_DEFAULT) rev.diffopt.output_format = DIFF_FORMAT_RAW; return cmd_log_deinit(cmd_log_walk(&rev), &rev); } @@ -724,7 +724,7 @@ static void show_setup_revisions_tweak(struct rev_info *rev, diff_merges_default_to_first_parent(rev); else diff_merges_default_to_dense_combined(rev); - if (!rev->diffopt.output_format) + if (rev->diffopt.output_format == DIFF_FORMAT_DEFAULT) rev->diffopt.output_format = DIFF_FORMAT_PATCH; } @@ -890,9 +890,12 @@ int cmd_log(int argc, const char **argv, const char *prefix) opt.tweak = log_setup_revisions_tweak; cmd_log_init(argc, argv, prefix, &rev, &opt); - if (!rev.diffopt.output_format) + if (rev.diffopt.output_format == DIFF_FORMAT_DEFAULT) { if (rev.line_level_traverse) rev.diffopt.output_format = DIFF_FORMAT_PATCH; + else + rev.diffopt.output_format = 0; + } return cmd_log_deinit(cmd_log_walk(&rev), &rev); } @@ -2125,7 +2128,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) die(_("--remerge-diff does not make sense")); if (!use_patch_format && - (!rev.diffopt.output_format || + (rev.diffopt.output_format == DIFF_FORMAT_DEFAULT || rev.diffopt.output_format == DIFF_FORMAT_PATCH)) rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_SUMMARY; if (!rev.diffopt.stat_width) diff --git a/builtin/stash.c b/builtin/stash.c index a7e17ffe38..398e3c9f61 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -944,7 +944,7 @@ static int show_stash(int argc, const char **argv, const char *prefix) argc = setup_revisions(revision_args.nr, revision_args.v, &rev, NULL); if (argc > 1) goto usage; - if (!rev.diffopt.output_format) { + if (rev.diffopt.output_format == DIFF_FORMAT_DEFAULT) { rev.diffopt.output_format = DIFF_FORMAT_PATCH; diff_setup_done(&rev.diffopt); } diff --git a/diff-merges.c b/diff-merges.c index ec97616db1..9960d7cc36 100644 --- a/diff-merges.c +++ b/diff-merges.c @@ -183,7 +183,7 @@ void diff_merges_setup_revs(struct rev_info *revs) if (revs->merges_imply_patch) revs->diff = 1; if (revs->merges_imply_patch || revs->merges_need_diff) { - if (!revs->diffopt.output_format) + if (revs->diffopt.output_format == DIFF_FORMAT_DEFAULT) revs->diffopt.output_format = DIFF_FORMAT_PATCH; } } diff --git a/diff-no-index.c b/diff-no-index.c index 4296940f90..45596cb1be 100644 --- a/diff-no-index.c +++ b/diff-no-index.c @@ -282,7 +282,7 @@ int diff_no_index(struct rev_info *revs, fixup_paths(paths, &replacement); revs->diffopt.skip_stat_unmatch = 1; - if (!revs->diffopt.output_format) + if (revs->diffopt.output_format == DIFF_FORMAT_DEFAULT) revs->diffopt.output_format = DIFF_FORMAT_PATCH; revs->diffopt.flags.no_index = 1; diff --git a/diff.c b/diff.c index 1e83aaee6b..c9077bfed6 100644 --- a/diff.c +++ b/diff.c @@ -4667,6 +4667,7 @@ void repo_diff_setup(struct repository *r, struct diff_options *options) options->file = stdout; options->repo = r; + options->output_format = DIFF_FORMAT_DEFAULT; options->output_indicators[OUTPUT_INDICATOR_NEW] = '+'; options->output_indicators[OUTPUT_INDICATOR_OLD] = '-'; options->output_indicators[OUTPUT_INDICATOR_CONTEXT] = ' '; @@ -4985,7 +4986,7 @@ static int diff_opt_diff_filter(const struct option *option, static void enable_patch_output(int *fmt) { - *fmt &= ~DIFF_FORMAT_NO_OUTPUT; + *fmt &= ~(DIFF_FORMAT_DEFAULT | DIFF_FORMAT_NO_OUTPUT); *fmt |= DIFF_FORMAT_PATCH; } @@ -5490,13 +5491,13 @@ struct option *add_diff_options(const struct option *opts, OPT_GROUP(N_("Diff output format options")), OPT_BITOP('p', "patch", &options->output_format, N_("generate patch"), - DIFF_FORMAT_PATCH, DIFF_FORMAT_NO_OUTPUT), - OPT_BIT_F('s', "no-patch", &options->output_format, + DIFF_FORMAT_PATCH, DIFF_FORMAT_DEFAULT | DIFF_FORMAT_NO_OUTPUT), + OPT_BITOP('s', "no-patch", &options->output_format, N_("suppress diff output"), - DIFF_FORMAT_NO_OUTPUT, PARSE_OPT_NONEG), + DIFF_FORMAT_NO_OUTPUT, DIFF_FORMAT_DEFAULT | DIFF_FORMAT_PATCH), OPT_BITOP('u', NULL, &options->output_format, N_("generate patch"), - DIFF_FORMAT_PATCH, DIFF_FORMAT_NO_OUTPUT), + DIFF_FORMAT_PATCH, DIFF_FORMAT_DEFAULT | DIFF_FORMAT_NO_OUTPUT), OPT_CALLBACK_F('U', "unified", options, N_(""), N_("generate diffs with lines context"), PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_unified), @@ -5508,17 +5509,17 @@ struct option *add_diff_options(const struct option *opts, OPT_BITOP(0, "patch-with-raw", &options->output_format, N_("synonym for '-p --raw'"), DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW, - DIFF_FORMAT_NO_OUTPUT), + DIFF_FORMAT_DEFAULT | DIFF_FORMAT_NO_OUTPUT), OPT_BITOP(0, "patch-with-stat", &options->output_format, N_("synonym for '-p --stat'"), DIFF_FORMAT_PATCH | DIFF_FORMAT_DIFFSTAT, - DIFF_FORMAT_NO_OUTPUT), - OPT_BIT_F(0, "numstat", &options->output_format, + DIFF_FORMAT_DEFAULT | DIFF_FORMAT_NO_OUTPUT), + OPT_BITOP(0, "numstat", &options->output_format, N_("machine friendly --stat"), - DIFF_FORMAT_NUMSTAT, PARSE_OPT_NONEG), - OPT_BIT_F(0, "shortstat", &options->output_format, + DIFF_FORMAT_NUMSTAT, DIFF_FORMAT_DEFAULT), + OPT_BITOP(0, "shortstat", &options->output_format, N_("output only the last line of --stat"), - DIFF_FORMAT_SHORTSTAT, PARSE_OPT_NONEG), + DIFF_FORMAT_SHORTSTAT, DIFF_FORMAT_DEFAULT), OPT_CALLBACK_F('X', "dirstat", options, N_("..."), N_("output the distribution of relative amount of changes for each sub-directory"), PARSE_OPT_NONEG | PARSE_OPT_OPTARG, @@ -5531,18 +5532,18 @@ struct option *add_diff_options(const struct option *opts, N_("synonym for --dirstat=files,param1,param2..."), PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_dirstat), - OPT_BIT_F(0, "check", &options->output_format, + OPT_BITOP(0, "check", &options->output_format, N_("warn if changes introduce conflict markers or whitespace errors"), - DIFF_FORMAT_CHECKDIFF, PARSE_OPT_NONEG), - OPT_BIT_F(0, "summary", &options->output_format, + DIFF_FORMAT_CHECKDIFF, DIFF_FORMAT_DEFAULT), + OPT_BITOP(0, "summary", &options->output_format, N_("condensed summary such as creations, renames and mode changes"), - DIFF_FORMAT_SUMMARY, PARSE_OPT_NONEG), - OPT_BIT_F(0, "name-only", &options->output_format, + DIFF_FORMAT_SUMMARY, DIFF_FORMAT_DEFAULT), + OPT_BITOP(0, "name-only", &options->output_format, N_("show only names of changed files"), - DIFF_FORMAT_NAME, PARSE_OPT_NONEG), - OPT_BIT_F(0, "name-status", &options->output_format, + DIFF_FORMAT_NAME, DIFF_FORMAT_DEFAULT), + OPT_BITOP(0, "name-status", &options->output_format, N_("show only names and status of changed files"), - DIFF_FORMAT_NAME_STATUS, PARSE_OPT_NONEG), + DIFF_FORMAT_NAME_STATUS, DIFF_FORMAT_DEFAULT), OPT_CALLBACK_F(0, "stat", options, N_("[,[,]]"), N_("generate diffstat"), PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_stat), diff --git a/diff.h b/diff.h index 6a0737b9c3..35bdbc40fa 100644 --- a/diff.h +++ b/diff.h @@ -102,6 +102,7 @@ typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data) #define DIFF_FORMAT_PATCH 0x0010 #define DIFF_FORMAT_SHORTSTAT 0x0020 #define DIFF_FORMAT_DIRSTAT 0x0040 +#define DIFF_FORMAT_DEFAULT 0x0080 /* These override all above */ #define DIFF_FORMAT_NAME 0x0100 diff --git a/range-diff.c b/range-diff.c index a1e0cffb9f..240f13d8dd 100644 --- a/range-diff.c +++ b/range-diff.c @@ -492,7 +492,7 @@ static void output(struct string_list *a, struct string_list *b, repo_diff_setup(the_repository, &opts); opts.no_free = 1; - if (!opts.output_format) + if (opts.output_format == DIFF_FORMAT_DEFAULT) opts.output_format = DIFF_FORMAT_PATCH; opts.flags.suppress_diff_headers = 1; opts.flags.dual_color_diffed_diffs = diff --git a/revision.c b/revision.c index b33cc1d106..cf68b533fd 100644 --- a/revision.c +++ b/revision.c @@ -2966,7 +2966,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s } /* Did the user ask for any diff output? Run the diff! */ - if (revs->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT) + if (revs->diffopt.output_format & ~(DIFF_FORMAT_DEFAULT | DIFF_FORMAT_NO_OUTPUT)) revs->diff = 1; /* Pickaxe, diff-filter and rename following need diffs */ @@ -3030,7 +3030,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s die(_("the option '%s' requires '%s'"), "--grep-reflog", "--walk-reflogs"); if (revs->line_level_traverse && - (revs->diffopt.output_format & ~(DIFF_FORMAT_PATCH | DIFF_FORMAT_NO_OUTPUT))) + (revs->diffopt.output_format & ~(DIFF_FORMAT_DEFAULT | DIFF_FORMAT_PATCH | DIFF_FORMAT_NO_OUTPUT))) die(_("-L does not yet support diff formats besides -p and -s")); if (revs->expand_tabs_in_log < 0) From patchwork Tue May 9 00:44:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13235262 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3069C77B7F for ; Tue, 9 May 2023 00:44:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232875AbjEIAo0 (ORCPT ); Mon, 8 May 2023 20:44:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231372AbjEIAoU (ORCPT ); Mon, 8 May 2023 20:44:20 -0400 Received: from mail-oo1-xc2a.google.com (mail-oo1-xc2a.google.com [IPv6:2607:f8b0:4864:20::c2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51A999023 for ; Mon, 8 May 2023 17:44:14 -0700 (PDT) Received: by mail-oo1-xc2a.google.com with SMTP id 006d021491bc7-54cb8d72c0bso2764741eaf.3 for ; Mon, 08 May 2023 17:44:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683593053; x=1686185053; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MgSHoxbWGvqPfS/3t7TICHJ3cxYsmnuZQ++iCu7WvtE=; b=g+/wykQsLT3+c+W1o8niJT4y/Aco9y/4Wa1v7YEzCUgVmyn8oqARCt66Friztp10Th vf20QgjpKymvYgQx15eXSFfQoXKjbxJBTnL1yF3fOIMpcniey/tfalKuHfpvZmWSHiC9 ti6LAQhypLAzKpB2niDgOtLMkAUUyrpF1KWfmcUK9Xdu8swOOjI734WNbSZqThI+Vx++ OgG3IW8STWIJjcsyBOB/nlMKxFAEPWn6f8wS8/iSTOXtUnWSu1KGXY2Y5wyPgYU8UTCY beDcSBVKQ0/fN2Zv0rw8VLUptncuHIj8G44MwpzLFzDuRH6NKOFq5TaVxwd8+zuNvbqy l8XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683593053; x=1686185053; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MgSHoxbWGvqPfS/3t7TICHJ3cxYsmnuZQ++iCu7WvtE=; b=Cy2jnggOSozvuMaE4nz9OG38iUVz4TFthK9377rAaKn+swi9hElIwMgBgdZxSYLEA1 PdXcaxjrptslfWXlSdDEqXPoWfLLS+DbTCjZ+7l7b7VnsHCtignIw/lZtnP5TcdwxIaj ZE/SO3RVJGFLNulHnS9UC3cyhnEfFDuRT0mXSp/Pk/NyigFod6nu1bd7jIjnpiv2qBpi L450mQ07PMObwzwDgwSuE3J2e+HxEYZSJiSuunrLGnIWi4zDXKIkeTfrN06A1At54SAE k5Lgh9+v9CRvkpqT6R7UqyXyGSirDa+kcozkYsEKpmrG9vVRWh7bwPHgt1YL+DcHIqBr g4+Q== X-Gm-Message-State: AC+VfDxPsbVLHQeGnptCwmz3gCBHH7OaqlaOqyp7WUfzlQecyWUmilXn 7JRkWKg2xmZsnnHQn/hieZ1t3r1o93U= X-Google-Smtp-Source: ACHHUZ6+/UNl60Yc7aa/QcEFj1/zfNQLolcLdtC/qvhvWM6NA+R87ut/CnTWsQWTospMc7DdjThpLg== X-Received: by 2002:a05:6808:311:b0:38c:4943:9f0f with SMTP id i17-20020a056808031100b0038c49439f0fmr408507oie.40.1683593053035; Mon, 08 May 2023 17:44:13 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id n206-20020acabdd7000000b0038cabdbe3a7sm641716oif.3.2023.05.08.17.44.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 May 2023 17:44:12 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Sergey Organov , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 4/4] diff: remove DIFF_FORMAT_NO_OUTPUT Date: Mon, 8 May 2023 18:44:06 -0600 Message-Id: <20230509004406.1786033-5-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.40.0+fc1 In-Reply-To: <20230509004406.1786033-1-felipe.contreras@gmail.com> References: <20230509004406.1786033-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Instead use an empty output_format (0) as NO_OUTPUT. This makes it so `--no-patch` only negates the effect of `--patch`, not shut down all output. So now `git diff --no-patch --raw` works correctly, as it's the opposite of `git diff --patch --raw`. Semantically `--no-patch` used to be considered a format, now it's the opposite of the `--patch` format. Cc: Sergey Organov Signed-off-by: Felipe Contreras --- blame.c | 6 +++--- builtin/log.c | 2 +- builtin/stash.c | 2 +- builtin/submodule--helper.c | 2 +- combine-diff.c | 10 ++++------ diff.c | 26 ++++++++++++-------------- diff.h | 5 ----- log-tree.c | 4 ++-- merge-ort.c | 4 ++-- merge-recursive.c | 4 ++-- notes-merge.c | 4 ++-- range-diff.c | 2 +- revision.c | 6 +++--- t/t4013-diff-various.sh | 5 +---- tree-diff.c | 2 +- 15 files changed, 36 insertions(+), 48 deletions(-) diff --git a/blame.c b/blame.c index b830654062..d382af6798 100644 --- a/blame.c +++ b/blame.c @@ -1337,7 +1337,7 @@ static struct blame_origin *find_origin(struct repository *r, repo_diff_setup(r, &diff_opts); diff_opts.flags.recursive = 1; diff_opts.detect_rename = 0; - diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT; + diff_opts.output_format = 0; paths[0] = origin->path; paths[1] = NULL; @@ -1420,7 +1420,7 @@ static struct blame_origin *find_rename(struct repository *r, repo_diff_setup(r, &diff_opts); diff_opts.flags.recursive = 1; diff_opts.detect_rename = DIFF_DETECT_RENAME; - diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT; + diff_opts.output_format = 0; diff_opts.single_follow = origin->path; diff_setup_done(&diff_opts); @@ -2242,7 +2242,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb, repo_diff_setup(sb->repo, &diff_opts); diff_opts.flags.recursive = 1; - diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT; + diff_opts.output_format = 0; diff_setup_done(&diff_opts); diff --git a/builtin/log.c b/builtin/log.c index 13c196c391..b3e6ee8782 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -276,7 +276,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix, PARSE_OPT_KEEP_DASHDASH); if (quiet) - rev->diffopt.output_format = DIFF_FORMAT_NO_OUTPUT; + rev->diffopt.output_format = 0; argc = setup_revisions(argc, argv, rev, opt); /* Any arguments at this point are not recognized */ diff --git a/builtin/stash.c b/builtin/stash.c index 398e3c9f61..d7a4ade8d4 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -437,7 +437,7 @@ static void unstage_changes_unless_new(struct object_id *orig_tree) repo_diff_setup(the_repository, &diff_opts); diff_opts.flags.recursive = 1; diff_opts.detect_rename = 0; - diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT; + diff_opts.output_format = 0; diff_setup_done(&diff_opts); do_diff_cache(orig_tree, &diff_opts); diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 6bf8d666ce..885cd57e90 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1120,7 +1120,7 @@ static int compute_summary_module_list(struct object_id *head_oid, rev.abbrev = 0; precompose_argv_prefix(diff_args.nr, diff_args.v, NULL); setup_revisions(diff_args.nr, diff_args.v, &rev, &opt); - rev.diffopt.output_format = DIFF_FORMAT_NO_OUTPUT | DIFF_FORMAT_CALLBACK; + rev.diffopt.output_format = DIFF_FORMAT_CALLBACK; rev.diffopt.format_callback = submodule_summary_callback; rev.diffopt.format_callback_data = &list; diff --git a/combine-diff.c b/combine-diff.c index f7e9fb5747..86e01b2634 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -1393,7 +1393,7 @@ static struct combine_diff_path *find_paths_generic(const struct object_id *oid, int output_format = opt->output_format; const char *orderfile = opt->orderfile; - opt->output_format = DIFF_FORMAT_NO_OUTPUT; + opt->output_format = 0; /* tell diff_tree to emit paths in sorted (=tree) order */ opt->orderfile = NULL; @@ -1407,17 +1407,15 @@ static struct combine_diff_path *find_paths_generic(const struct object_id *oid, if (i == 0 && stat_opt) opt->output_format = stat_opt; else - opt->output_format = DIFF_FORMAT_NO_OUTPUT; + opt->output_format = 0; diff_tree_oid(&parents->oid[i], oid, "", opt); diffcore_std(opt); paths = intersect_paths(paths, i, num_parent, combined_all_paths); /* if showing diff, show it in requested order */ - if (opt->output_format != DIFF_FORMAT_NO_OUTPUT && - orderfile) { + if (opt->output_format && orderfile) diffcore_order(orderfile); - } diff_flush(opt); } @@ -1520,7 +1518,7 @@ void diff_tree_combined(const struct object_id *oid, show_log(rev); if (rev->verbose_header && opt->output_format && - opt->output_format != DIFF_FORMAT_NO_OUTPUT && + opt->output_format && !commit_format_is_empty(rev->commit_format)) printf("%s%c", diff_line_prefix(opt), opt->line_termination); diff --git a/diff.c b/diff.c index c9077bfed6..afe2f849b0 100644 --- a/diff.c +++ b/diff.c @@ -4748,8 +4748,7 @@ void diff_setup_done(struct diff_options *options) { unsigned check_mask = DIFF_FORMAT_NAME | DIFF_FORMAT_NAME_STATUS | - DIFF_FORMAT_CHECKDIFF | - DIFF_FORMAT_NO_OUTPUT; + DIFF_FORMAT_CHECKDIFF; /* * This must be signed because we're comparing against a potentially * negative value. @@ -4760,8 +4759,8 @@ void diff_setup_done(struct diff_options *options) options->set_default(options); if (HAS_MULTI_BITS(options->output_format & check_mask)) - die(_("options '%s', '%s', '%s', and '%s' cannot be used together"), - "--name-only", "--name-status", "--check", "-s"); + die(_("options '%s', '%s', and '%s' cannot be used together"), + "--name-only", "--name-status", "--check"); if (HAS_MULTI_BITS(options->pickaxe_opts & DIFF_PICKAXE_KINDS_MASK)) die(_("options '%s', '%s', and '%s' cannot be used together"), @@ -4800,8 +4799,7 @@ void diff_setup_done(struct diff_options *options) if (options->output_format & (DIFF_FORMAT_NAME | DIFF_FORMAT_NAME_STATUS | - DIFF_FORMAT_CHECKDIFF | - DIFF_FORMAT_NO_OUTPUT)) + DIFF_FORMAT_CHECKDIFF)) options->output_format &= ~(DIFF_FORMAT_RAW | DIFF_FORMAT_NUMSTAT | DIFF_FORMAT_DIFFSTAT | @@ -4845,7 +4843,7 @@ void diff_setup_done(struct diff_options *options) * exit code in such a case either. */ if (options->flags.quick) { - options->output_format = DIFF_FORMAT_NO_OUTPUT; + options->output_format = 0; options->flags.exit_with_status = 1; } @@ -4986,7 +4984,7 @@ static int diff_opt_diff_filter(const struct option *option, static void enable_patch_output(int *fmt) { - *fmt &= ~(DIFF_FORMAT_DEFAULT | DIFF_FORMAT_NO_OUTPUT); + *fmt &= ~DIFF_FORMAT_DEFAULT; *fmt |= DIFF_FORMAT_PATCH; } @@ -5491,13 +5489,13 @@ struct option *add_diff_options(const struct option *opts, OPT_GROUP(N_("Diff output format options")), OPT_BITOP('p', "patch", &options->output_format, N_("generate patch"), - DIFF_FORMAT_PATCH, DIFF_FORMAT_DEFAULT | DIFF_FORMAT_NO_OUTPUT), + DIFF_FORMAT_PATCH, DIFF_FORMAT_DEFAULT), OPT_BITOP('s', "no-patch", &options->output_format, N_("suppress diff output"), - DIFF_FORMAT_NO_OUTPUT, DIFF_FORMAT_DEFAULT | DIFF_FORMAT_PATCH), + 0, DIFF_FORMAT_DEFAULT | DIFF_FORMAT_PATCH), OPT_BITOP('u', NULL, &options->output_format, N_("generate patch"), - DIFF_FORMAT_PATCH, DIFF_FORMAT_DEFAULT | DIFF_FORMAT_NO_OUTPUT), + DIFF_FORMAT_PATCH, DIFF_FORMAT_DEFAULT), OPT_CALLBACK_F('U', "unified", options, N_(""), N_("generate diffs with lines context"), PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_unified), @@ -5509,11 +5507,11 @@ struct option *add_diff_options(const struct option *opts, OPT_BITOP(0, "patch-with-raw", &options->output_format, N_("synonym for '-p --raw'"), DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW, - DIFF_FORMAT_DEFAULT | DIFF_FORMAT_NO_OUTPUT), + DIFF_FORMAT_DEFAULT), OPT_BITOP(0, "patch-with-stat", &options->output_format, N_("synonym for '-p --stat'"), DIFF_FORMAT_PATCH | DIFF_FORMAT_DIFFSTAT, - DIFF_FORMAT_DEFAULT | DIFF_FORMAT_NO_OUTPUT), + DIFF_FORMAT_DEFAULT), OPT_BITOP(0, "numstat", &options->output_format, N_("machine friendly --stat"), DIFF_FORMAT_NUMSTAT, DIFF_FORMAT_DEFAULT), @@ -6644,7 +6642,7 @@ void diff_flush(struct diff_options *options) separator++; } - if (output_format & DIFF_FORMAT_NO_OUTPUT && + if (!output_format && options->flags.exit_with_status && options->flags.diff_from_contents) { /* diff --git a/diff.h b/diff.h index 35bdbc40fa..31375b7e8a 100644 --- a/diff.h +++ b/diff.h @@ -109,11 +109,6 @@ typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data) #define DIFF_FORMAT_NAME_STATUS 0x0200 #define DIFF_FORMAT_CHECKDIFF 0x0400 -/* Same as output_format = 0 but we know that -s flag was given - * and we should not give default value to output_format. - */ -#define DIFF_FORMAT_NO_OUTPUT 0x0800 - #define DIFF_FORMAT_CALLBACK 0x1000 #define DIFF_FLAGS_INIT { 0 } diff --git a/log-tree.c b/log-tree.c index 143b86fecf..0b1097c0bf 100644 --- a/log-tree.c +++ b/log-tree.c @@ -873,7 +873,7 @@ int log_tree_diff_flush(struct rev_info *opt) if (diff_queue_is_empty(&opt->diffopt)) { int saved_fmt = opt->diffopt.output_format; - opt->diffopt.output_format = DIFF_FORMAT_NO_OUTPUT; + opt->diffopt.output_format = 0; diff_flush(&opt->diffopt); opt->diffopt.output_format = saved_fmt; return 0; @@ -881,7 +881,7 @@ int log_tree_diff_flush(struct rev_info *opt) if (opt->loginfo && !opt->no_commit_id) { show_log(opt); - if ((opt->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT) && + if (opt->diffopt.output_format && opt->verbose_header && opt->commit_format != CMIT_FMT_ONELINE && !commit_format_is_empty(opt->commit_format)) { diff --git a/merge-ort.c b/merge-ort.c index 34ec2675a2..f1d1db4970 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -3247,7 +3247,7 @@ static int detect_regular_renames(struct merge_options *opt, diff_opts.rename_limit = 7000; diff_opts.rename_score = opt->rename_score; diff_opts.show_rename_progress = opt->show_rename_progress; - diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT; + diff_opts.output_format = 0; diff_setup_done(&diff_opts); diff_queued_diff = renames->pairs[side_index]; @@ -3268,7 +3268,7 @@ static int detect_regular_renames(struct merge_options *opt, renames->pairs[side_index] = diff_queued_diff; - diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT; + diff_opts.output_format = 0; diff_queued_diff.nr = 0; diff_queued_diff.queue = NULL; diff_flush(&diff_opts); diff --git a/merge-recursive.c b/merge-recursive.c index 9875bdb11c..3cc8c956eb 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -1902,7 +1902,7 @@ static struct diff_queue_struct *get_diffpairs(struct merge_options *opt, opts.rename_limit = (opt->rename_limit >= 0) ? opt->rename_limit : 7000; opts.rename_score = opt->rename_score; opts.show_rename_progress = opt->show_rename_progress; - opts.output_format = DIFF_FORMAT_NO_OUTPUT; + opts.output_format = 0; diff_setup_done(&opts); diff_tree_oid(&o_tree->object.oid, &tree->object.oid, "", &opts); diffcore_std(&opts); @@ -1912,7 +1912,7 @@ static struct diff_queue_struct *get_diffpairs(struct merge_options *opt, ret = xmalloc(sizeof(*ret)); *ret = diff_queued_diff; - opts.output_format = DIFF_FORMAT_NO_OUTPUT; + opts.output_format = 0; diff_queued_diff.nr = 0; diff_queued_diff.queue = NULL; diff_flush(&opts); diff --git a/notes-merge.c b/notes-merge.c index 233e49e319..9a8bac2579 100644 --- a/notes-merge.c +++ b/notes-merge.c @@ -139,7 +139,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o, repo_diff_setup(o->repo, &opt); opt.flags.recursive = 1; - opt.output_format = DIFF_FORMAT_NO_OUTPUT; + opt.output_format = 0; diff_setup_done(&opt); diff_tree_oid(base, remote, "", &opt); diffcore_std(&opt); @@ -201,7 +201,7 @@ static void diff_tree_local(struct notes_merge_options *o, repo_diff_setup(o->repo, &opt); opt.flags.recursive = 1; - opt.output_format = DIFF_FORMAT_NO_OUTPUT; + opt.output_format = 0; diff_setup_done(&opt); diff_tree_oid(base, local, "", &opt); diffcore_std(&opt); diff --git a/range-diff.c b/range-diff.c index 240f13d8dd..db3f2a4958 100644 --- a/range-diff.c +++ b/range-diff.c @@ -542,7 +542,7 @@ static void output(struct string_list *a, struct string_list *b, a_util = a->items[b_util->matching].util; output_pair_header(&opts, patch_no_width, &buf, &dashes, a_util, b_util); - if (!(opts.output_format & DIFF_FORMAT_NO_OUTPUT)) + if (opts.output_format) patch_diff(a->items[b_util->matching].string, b->items[j].string, &opts); a_util->shown = 1; diff --git a/revision.c b/revision.c index cf68b533fd..52c2f415c7 100644 --- a/revision.c +++ b/revision.c @@ -2966,7 +2966,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s } /* Did the user ask for any diff output? Run the diff! */ - if (revs->diffopt.output_format & ~(DIFF_FORMAT_DEFAULT | DIFF_FORMAT_NO_OUTPUT)) + if (revs->diffopt.output_format & ~DIFF_FORMAT_DEFAULT) revs->diff = 1; /* Pickaxe, diff-filter and rename following need diffs */ @@ -3030,8 +3030,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s die(_("the option '%s' requires '%s'"), "--grep-reflog", "--walk-reflogs"); if (revs->line_level_traverse && - (revs->diffopt.output_format & ~(DIFF_FORMAT_DEFAULT | DIFF_FORMAT_PATCH | DIFF_FORMAT_NO_OUTPUT))) - die(_("-L does not yet support diff formats besides -p and -s")); + (revs->diffopt.output_format & ~(DIFF_FORMAT_DEFAULT | DIFF_FORMAT_PATCH))) + die(_("-L does not yet support diff formats besides -p")); if (revs->expand_tabs_in_log < 0) revs->expand_tabs_in_log = revs->expand_tabs_in_log_default; diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index f876b0cc8e..3a43edb8d8 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -457,10 +457,7 @@ diff-tree --stat --compact-summary initial mode diff-tree -R --stat --compact-summary initial mode EOF -# This should succeed as --patch followed by --no-patch sequence is to -# be a no-op according to the manual page. In reality it breaks --raw -# though. Needs to be fixed. -test_expect_failure '--no-patch cancels --patch only' ' +test_expect_success '--no-patch cancels --patch only' ' git log --raw master >result && process_diffs result >expected && git log --patch --no-patch --raw >result && diff --git a/tree-diff.c b/tree-diff.c index 69031d7cba..a2e872fbe7 100644 --- a/tree-diff.c +++ b/tree-diff.c @@ -613,7 +613,7 @@ static void try_to_follow_renames(const struct object_id *old_oid, repo_diff_setup(opt->repo, &diff_opts); diff_opts.flags.recursive = 1; diff_opts.flags.find_copies_harder = 1; - diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT; + diff_opts.output_format = 0; diff_opts.single_follow = opt->pathspec.items[0].match; diff_opts.break_opt = opt->break_opt; diff_opts.rename_score = opt->rename_score;