From patchwork Fri May 12 08:03:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13238819 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 B467CC77B75 for ; Fri, 12 May 2023 08:03:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240129AbjELIDp (ORCPT ); Fri, 12 May 2023 04:03:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240103AbjELIDn (ORCPT ); Fri, 12 May 2023 04:03:43 -0400 Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E1CF2D46 for ; Fri, 12 May 2023 01:03:42 -0700 (PDT) Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-392116ae103so4946842b6e.0 for ; Fri, 12 May 2023 01:03:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683878621; x=1686470621; 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=mNDdc/JH/4Jq+Ldo4fv8pu7IHguxkA5oDJjQTKV9K+s=; b=Z9r+BiSeHTWBskKUWv83ItRSwW8lJCIp+vTsOX84xJgyDoOf5T7yNQVJ1NFklv2rta U2QqZDz0Tu7rfrNKplukDPnBORmcWpCMfE181zRhjMUvyjdH6ivXkn2rfqFLZBdXT5Tx vNoz/jdKuQayRdYhy4SCMop3WBpFQJxMPhC38UFCN4UlX6HL4WblyshLVXziVa9MnUTJ QcqDCmkWDtk2nzStAN2OkVz0+nuarBKzlhvcX+67CkfOuSvzY1m2UnwxL4NfvMD4HCxU lxLxdZUaDs4KtEnp1tQKWQ9mwwB5JyO0bL5uMhhvRq4dYkMBRpfv3RPk7+XW26Ac8yBD z7Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683878621; x=1686470621; 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=mNDdc/JH/4Jq+Ldo4fv8pu7IHguxkA5oDJjQTKV9K+s=; b=PqMU01yz1QoG66BaV32+1qO0NEH4ClZZLGkCSP4waYe4HnMy0l0/d3rIa3VrQBNYhV JPzC3qOvAEu0P8fHtgXNbW0UgiLc5tzPfF6ZrlBLghR2AP+kh+c418gX49l76Jb8ygm5 2vIJdA0DBXSHoi4n3S9EuKnwLDlkFVdiBPoURrEIuKpQvepR0gV8Rn+5Jryi2K904yrl RS66BWqU9ntdyVtPFOEuz76qUSNL+v/OG6E/NLCpGJ2Xv+fFRsOypzpcqN48ZgEVPAtz sgYEGFtLsns+2lVTMKucARaSjwh7PA9W/+4unqgnyn71hGCEi2H7n/nhMCbqw5HgJPcY 49eQ== X-Gm-Message-State: AC+VfDwOGMkdJ+hPpOBmOcFXj28kIxdoBwHK0G/bTJVBch5O7v5zECJ+ vDnBWaa3cn5pDacKYr+daW3Af/6BHS8= X-Google-Smtp-Source: ACHHUZ4/C6dap/Z1BrmNc28eQSyvmoZrGoKaTX2ptNvlzVCI2RSRvx+ziDS29OafJ7uMa9vw7Wqc3w== X-Received: by 2002:a05:6808:6341:b0:38c:581f:6c90 with SMTP id eb1-20020a056808634100b0038c581f6c90mr5690676oib.57.1683878621609; Fri, 12 May 2023 01:03:41 -0700 (PDT) Received: from localhost ([2806:2f0:4000:e8a3:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id i3-20020aca3b03000000b0039208555951sm4294320oia.29.2023.05.12.01.03.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 01:03:41 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Sergey Organov , Junio C Hamano , Felipe Contreras Subject: [PATCH v1 1/7] line-log: set patch format explicitly by default Date: Fri, 12 May 2023 02:03:33 -0600 Message-Id: <20230512080339.2186324-2-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.40.0+fc1 In-Reply-To: <20230512080339.2186324-1-felipe.contreras@gmail.com> References: <20230512080339.2186324-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 676de107d6..712bfbf5c2 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -890,6 +890,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 6a7ac312a4..7466366860 100644 --- a/line-log.c +++ b/line-log.c @@ -1141,7 +1141,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 Fri May 12 08:03:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13238821 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 1F423C77B7C for ; Fri, 12 May 2023 08:03:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240183AbjELIDv (ORCPT ); Fri, 12 May 2023 04:03:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240136AbjELIDq (ORCPT ); Fri, 12 May 2023 04:03:46 -0400 Received: from mail-oa1-x36.google.com (mail-oa1-x36.google.com [IPv6:2001:4860:4864:20::36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A8801BFA for ; Fri, 12 May 2023 01:03:44 -0700 (PDT) Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-1929818d7faso56105626fac.0 for ; Fri, 12 May 2023 01:03:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683878623; x=1686470623; 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=rVjmBB5YDIDifLGj1oI9I78bKgR6D8yOOd6FyYOfyw8=; b=sOV2OHC0k6gpVVPDsxSNUOnEU9SkixP3heaZrnQoTRdALXePodOT17Qbadsbjtg4QI 2HWJGal7O7fk6PsNLjcmjHlWLCZvHYzlmmVdIyo08a5Lxy+ZvrCse5RRQBM+m3lcIe1i dw676K7NqP1tGbLrtJ/vnP1eDwuXs+syf/geSVqKFhqVF490Yk0Olnk4xJCwO2lQJtKM FzFRXrI4+eTL56RCSfiSkptqmaJIduewUafUWBie44cinVtFNvTaJsAkNnKaj78iz4tI iK7NnidMJRRTgxRQe0PJyK7GbGKIhynhO/5IK6a90ojlpGnsa4c1C0ZHGZHHWfqSC/BK z6Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683878623; x=1686470623; 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=rVjmBB5YDIDifLGj1oI9I78bKgR6D8yOOd6FyYOfyw8=; b=bUe4WozzlkLX0sLqk+FSEmHMsPZpdqT/L35Fwsoy0gfTcjwGkrx7tjxaLRWY157f1F eW2iCeGL4aR5ZHx6u2lGQGY4QE1ALbeWpvwHBjBqeg5lUno8ubmTK05ny0euujSEAGYY svmLMJNMLeGf/gx2tuDUirdt3UHdZQW3alj3JtswPXC99GbP4HkBY5jFXzjr6Hf4uvzL vA3IOoyxYefkwOFkV3PvsYWRGcGNVN4yyeTxL/5Y4Vfg0J3Ib5zNalZGP/gp1XwS7sjM Ywsk7YpsHFstEZemqwxrE5FOMIasH8parvQ9ofIeTsuL/juvCIrz0xzrVzUhmBdIYrwf 5LwQ== X-Gm-Message-State: AC+VfDyaF7ludD2nJfJleQadLvGECfL4+mw/LWRRg59+yKH6ejo8pezy y7iQ8ElFhL43IbXdjxgcdnT6hslHpvU= X-Google-Smtp-Source: ACHHUZ42s6Z0W5odv47quMOaiHLGuKgsHnrQHYjeO9GeEDmtQ6PrFPBjOOY6FmqDjrk/K12davUTpQ== X-Received: by 2002:aca:bdc4:0:b0:38e:a925:8f95 with SMTP id n187-20020acabdc4000000b0038ea9258f95mr5592794oif.26.1683878622927; Fri, 12 May 2023 01:03:42 -0700 (PDT) Received: from localhost ([2806:2f0:4000:e8a3:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id v3-20020acade03000000b0038dd5bf922bsm4281300oig.22.2023.05.12.01.03.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 01:03:42 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Sergey Organov , Junio C Hamano , Felipe Contreras Subject: [PATCH v1 2/7] diff: introduce DIFF_FORMAT_DEFAULT Date: Fri, 12 May 2023 02:03:34 -0600 Message-Id: <20230512080339.2186324-3-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.40.0+fc1 In-Reply-To: <20230512080339.2186324-1-felipe.contreras@gmail.com> References: <20230512080339.2186324-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 0b02c62b85..7e9164187c 100644 --- a/builtin/diff-tree.c +++ b/builtin/diff-tree.c @@ -100,7 +100,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 7b64659fe7..2decf5e531 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -505,7 +505,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 712bfbf5c2..d2a81f36c2 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -277,7 +277,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 */ @@ -633,7 +633,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); } @@ -725,7 +725,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; } @@ -891,9 +891,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); } @@ -2126,7 +2129,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 71513d92e8..387944f289 100644 --- a/diff.c +++ b/diff.c @@ -4669,6 +4669,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] = ' '; @@ -4987,7 +4988,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; } @@ -5492,13 +5493,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), @@ -5510,17 +5511,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, @@ -5533,18 +5534,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 3a7a9e8b88..15a7bf2c9f 100644 --- a/diff.h +++ b/diff.h @@ -101,6 +101,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 6a704e6f47..6c1ae9dd34 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 Fri May 12 08:03:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13238822 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 868E8C77B75 for ; Fri, 12 May 2023 08:03:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240205AbjELIDx (ORCPT ); Fri, 12 May 2023 04:03:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240164AbjELIDs (ORCPT ); Fri, 12 May 2023 04:03:48 -0400 Received: from mail-oa1-x2b.google.com (mail-oa1-x2b.google.com [IPv6:2001:4860:4864:20::2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E5F62133 for ; Fri, 12 May 2023 01:03:45 -0700 (PDT) Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-1929818d7faso56105684fac.0 for ; Fri, 12 May 2023 01:03:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683878624; x=1686470624; 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=z9MVM5hMWjav3OgczHiblWNEY2ACazmMHVpb/tauHi0=; b=fSX11ajR8kGjAyVyQRoDbs4fZo0/Yo6XMvy0zjjKFyDuIN9lLkwfwQ1ISoZecvTXEv cdiFpDzhZrAZPHYCHwt9HO+KEqZk2AEAWn/XCq7XE9ORQTM8drkpJi7UFKFODN8HW+aH WimQCwuqnz6gnIFcI3lQ4J4A5y4SUaenIM+ZMJRxu2YjPwOyzawgseVY5rmqODtgpZe5 kwBfojq14j1A5rgDeK8eDulOFyDr0W1exlfg5fs10MRbgzJdD/YySHKFsFGkJ/7qRqR5 zUTgCmXBbpzI0hQz0wG0ObUWYJdDUzCetPuzC8KYexWPqfWl7Q3g4s5FxdKUuZwF9Wvd VWIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683878624; x=1686470624; 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=z9MVM5hMWjav3OgczHiblWNEY2ACazmMHVpb/tauHi0=; b=FI6Ip0Wce1LVZwW7bXsrU0s/ZniPoGA5YTV/ttbUrGh6IsXulc8OYIa9FNxtZeU9Vh krbpP0pczxfGWEOavAYgpdRQoUohu2xmZcJXpcEnxUQ2U2HujnP057mvLHBusJuUqRvZ SlCCOIH8jo1MltrDpIRJvpNvM/xIB6jIxbrpKtGSj7AgSAILpsx0GbMhzBa8ffzcFxi1 ti1qgUI+nnnioJH3R24HwZt5goUErjfdlCDGNe+pgTJizDImpXm9TFf1wxmcBhOgrz6r 5VloEvKxFirRpZy10cQTb7SUEmwuBwbydVKW9UVooh1sj7GjrDIGs7bL7Mmsu9FgFo9l 6sZg== X-Gm-Message-State: AC+VfDz/K4kz9OQGKoy9AobZIJ5sZqh3HcCqjYOV2JUYee8uCK4QzX9T noCiNfpeKaKlkdoxu99REpXJrbPXP2E= X-Google-Smtp-Source: ACHHUZ4oY4H2Pzqk8PCZ5fs0cD8WOFqRfsxsP7SL81Lh4NKpeFPkappzYI/+6DJDHMW787sOZBXubA== X-Received: by 2002:a05:6830:135a:b0:6ac:9b94:10a8 with SMTP id r26-20020a056830135a00b006ac9b9410a8mr53654otq.16.1683878624208; Fri, 12 May 2023 01:03:44 -0700 (PDT) Received: from localhost ([2806:2f0:4000:e8a3:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id i7-20020a9d6247000000b006aaff32ac36sm5393978otk.66.2023.05.12.01.03.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 01:03:43 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Sergey Organov , Junio C Hamano , Felipe Contreras Subject: [PATCH v1 3/7] diff: make DIFF_FORMAT_NO_OUTPUT 0 Date: Fri, 12 May 2023 02:03:35 -0600 Message-Id: <20230512080339.2186324-4-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.40.0+fc1 In-Reply-To: <20230512080339.2186324-1-felipe.contreras@gmail.com> References: <20230512080339.2186324-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org `-s` is considered a format, but if we change the meaning to absence of a format it now becomes possible to distinguish `git diff` from `git diff --no-patch`, although that isn't done in this commit. This also fixes a bug in which specifying an output format did not clear the NO_OUTPUT flag. For example this now works correctly: git show -s --raw Signed-off-by: Felipe Contreras --- diff.c | 13 ++++++------- diff.h | 6 +----- range-diff.c | 2 +- revision.c | 4 ++-- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/diff.c b/diff.c index 387944f289..4f4b1d7e13 100644 --- a/diff.c +++ b/diff.c @@ -4750,8 +4750,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. @@ -4762,8 +4761,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"), @@ -5494,9 +5493,9 @@ struct option *add_diff_options(const struct option *opts, OPT_BITOP('p', "patch", &options->output_format, N_("generate patch"), DIFF_FORMAT_PATCH, DIFF_FORMAT_DEFAULT | DIFF_FORMAT_NO_OUTPUT), - OPT_BITOP('s', "no-patch", &options->output_format, + OPT_SET_INT_F('s', "no-patch", &options->output_format, N_("suppress diff output"), - DIFF_FORMAT_NO_OUTPUT, DIFF_FORMAT_DEFAULT | DIFF_FORMAT_PATCH), + DIFF_FORMAT_NO_OUTPUT, PARSE_OPT_NONEG), OPT_BITOP('u', NULL, &options->output_format, N_("generate patch"), DIFF_FORMAT_PATCH, DIFF_FORMAT_DEFAULT | DIFF_FORMAT_NO_OUTPUT), @@ -6646,7 +6645,7 @@ void diff_flush(struct diff_options *options) separator++; } - if (output_format & DIFF_FORMAT_NO_OUTPUT && + if (output_format == DIFF_FORMAT_NO_OUTPUT && options->flags.exit_with_status && options->flags.diff_from_contents) { /* diff --git a/diff.h b/diff.h index 15a7bf2c9f..44da1a4ca7 100644 --- a/diff.h +++ b/diff.h @@ -94,6 +94,7 @@ typedef void (*diff_format_fn_t)(struct diff_queue_struct *q, typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data); +#define DIFF_FORMAT_NO_OUTPUT 0x0000 #define DIFF_FORMAT_RAW 0x0001 #define DIFF_FORMAT_DIFFSTAT 0x0002 #define DIFF_FORMAT_NUMSTAT 0x0004 @@ -108,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/range-diff.c b/range-diff.c index 6c1ae9dd34..00ff5dc160 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..07d653c197 100644 --- a/revision.c +++ b/revision.c @@ -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; From patchwork Fri May 12 08:03:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13238823 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 17A0BC7EE24 for ; Fri, 12 May 2023 08:03:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240180AbjELIDz (ORCPT ); Fri, 12 May 2023 04:03:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240171AbjELIDs (ORCPT ); Fri, 12 May 2023 04:03:48 -0400 Received: from mail-oa1-x2a.google.com (mail-oa1-x2a.google.com [IPv6:2001:4860:4864:20::2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB03C106C5 for ; Fri, 12 May 2023 01:03:46 -0700 (PDT) Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-190d4f2f943so7559463fac.3 for ; Fri, 12 May 2023 01:03:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683878626; x=1686470626; 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=bNk0SOiEmVxan2pChk6RXCegBynqH0jK3A+WuF/KI/s=; b=emMSz7xgDz1KDoNba/IksUu4EFAAfrwHtS7dOcgc2P1LyeltJ71GA1KwHsIS2e9kPt 3zVeDHsY6Q757yP24gjbSMQ1q+yCO17lOuFNq05rbnnx7WXoWzH6DSwWFdTXh6AnWPX7 sQne/CXLCDegdLxNrOzS2c97XHkyc/mFrxT6YCb0p2GsN2zNvtflDfCc+x2EFcGgdlgx OhY0iISPvKN01Y9mn/0RHjD3/PHYcVVngkVkdlJl64moBn1+OD0X6SfaIEu2cVBnSQ0O gS2p/BOJb0IQbyp2Ij8DEy6QNwGp7212cOjhKJqsJz8sHXlz2eujOfNPq9lQJBZMpRhc DIqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683878626; x=1686470626; 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=bNk0SOiEmVxan2pChk6RXCegBynqH0jK3A+WuF/KI/s=; b=GmJAJB9gd9puTALfYfufsNFFVyUtyZjp11SPVrOaHMvCoinlUclQNUFtWlkC3y1EiY 5Rc8xyKWEMq2Rp9mGe6slkdRcolzGNT1FlZXdpdLe+eVtc9sODTcYiqaoJYLJFFcAR4I gLZaORBtMjEZ5WPgPkcAuaOq09Xb94/xyF01ylbb6+p06ZavjSop+PAeQ3NdsmILbAqb tZQI89hA8bYLwJvDxxTM98MUpdZXXo/ihz10LTcm0Rp9h7arFYSqaovMvPDj9AfHvOVD DNjwWiiwi42VFLIJ+tkmEZg/edBf3Tn8ChJacuTBKrZDV4pGt4FXGTsejUWerI8IQ7E4 4Img== X-Gm-Message-State: AC+VfDwyCRiPmlKsuDpC/yo9Mc7t1Vm5BE0zikVrtcbBV8wY2Og4sE3F g90Rb1wZF3T84zqzr4PLaYrjdoaWQIs= X-Google-Smtp-Source: ACHHUZ5R0cv68rJskoy+pxikmtZPBa8in+DJt2op8oL1ZxxCu1i2zA0LkzG7mVvqFwe/+gS6dv8JVg== X-Received: by 2002:a05:6870:b304:b0:18f:558a:1f34 with SMTP id a4-20020a056870b30400b0018f558a1f34mr10657087oao.40.1683878625744; Fri, 12 May 2023 01:03:45 -0700 (PDT) Received: from localhost ([2806:2f0:4000:e8a3:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id o5-20020a05687072c500b00183f77dcdadsm8806514oak.33.2023.05.12.01.03.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 01:03:45 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Sergey Organov , Junio C Hamano , Felipe Contreras Subject: [PATCH v1 4/7] test: add various tests for diff formats with -s Date: Fri, 12 May 2023 02:03:36 -0600 Message-Id: <20230512080339.2186324-5-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.40.0+fc1 In-Reply-To: <20230512080339.2186324-1-felipe.contreras@gmail.com> References: <20230512080339.2186324-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There used to be a bug when -s was used with different formats, for example `-s --raw`. Originally-by: Junio C Hamano Signed-off-by: Felipe Contreras --- t/t4000-diff-format.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/t/t4000-diff-format.sh b/t/t4000-diff-format.sh index bfcaae390f..7829cc810d 100755 --- a/t/t4000-diff-format.sh +++ b/t/t4000-diff-format.sh @@ -91,4 +91,23 @@ test_expect_success 'git diff-files --patch --no-patch does not show the patch' test_must_be_empty err ' + +echo 'reset' >path1 + +for format in stat raw numstat shortstat summary dirstat cumulative \ + dirstat-by-file patch-with-raw patch-with-stat compact-summary +do + test_expect_success "-s before --$format' is a no-op" ' + git diff-files -s "--$format" >actual && + git diff-files "--$format" >expect && + test_cmp expect actual + ' + + test_expect_success "-s clears --$format" ' + git diff-files --$format -s --patch >actual && + git diff-files --patch >expect && + test_cmp expect actual + ' +done + test_done From patchwork Fri May 12 08:03:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13238824 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 AF201C77B7C for ; Fri, 12 May 2023 08:03:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240235AbjELID6 (ORCPT ); Fri, 12 May 2023 04:03:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240186AbjELIDv (ORCPT ); Fri, 12 May 2023 04:03:51 -0400 Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07D8910E4D for ; Fri, 12 May 2023 01:03:47 -0700 (PDT) Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-18f4a6d2822so55982429fac.1 for ; Fri, 12 May 2023 01:03:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683878627; x=1686470627; 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=+iskKttoJoPOXmYyPXxtFS/pQk5D3EW8uml4F8kNG64=; b=B11Ad6qTXR7iyQOf8UJ/K3uCBp+qyJAizEzH/v5zUoePVjQHKwCqfc4S4P/K83TPnF ToeuDuwSltphUrjJasqvncR11lV958HFJAlY9oaNgp2T1f0etxiq7j7vOsYIuLWqo8dJ VdVqzRC28+lwTYUEa9fx7zfSqgbB1oa3QsUYQXKa2LroS0gkK5cXNAqn4SjHiJlEaZCC NPDGobH0dFZlf0k5qn8QovYPM8JtexoE9zoKxqdOSkf4TUAPxE/HwM5aw6beEEVxOoMF Ni/vzxG/K13WSyhaUx0JDoI0UtYOFYLhZ5pmdTfZIfbiA1xZkva1Gkw7+7Ues3mvlcYd TDbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683878627; x=1686470627; 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=+iskKttoJoPOXmYyPXxtFS/pQk5D3EW8uml4F8kNG64=; b=jMcEEwLXa9SaCbv7FUrAUaOpn86+XkU0hL3T6Hk6z3TO2++9CjGqsw8bY70PDCQBhQ TWfPm2XeJmz7bDVaNIt1EasSZ40kSmBUv0ZqWyVPM4D238vMow/lMr+E89eTkMJLuPaK a5Glju/U0rbLIUNN7aDsyqob7Pxra+fWuAOTuJeHz2RKB2U88lyQzU+WTLgs25JwHi2v olcfBIaHK7e+eWNnDH6OcVVy8Jfnyq6ZKK9IUVYbh0kOXSZSKWT2/ID9MzHcNkmW02DI Z3O3WskMNMbU6d/pNVeIesXuWRtY680L2Ujv6p82rZxnYyktgRz+jtNL9Wh0/9BOebbV lDrQ== X-Gm-Message-State: AC+VfDwe4G+B0Hn+FvvHIFhWxSvpkUjE0xCdtVOxZ1rFC9f2ay1A7jnp QrBc0Hi4COdO5fe/nthQ9+fBTipTYNc= X-Google-Smtp-Source: ACHHUZ4qjx6w0HrnllIsN63RS6bR5pBpOcrxJNJp8lMCXPCvF0Jrijpz7oYvmQbesnD3Rr96IKK8Zw== X-Received: by 2002:a9d:19aa:0:b0:6ab:2d66:6b92 with SMTP id k39-20020a9d19aa000000b006ab2d666b92mr3615436otk.11.1683878627001; Fri, 12 May 2023 01:03:47 -0700 (PDT) Received: from localhost ([2806:2f0:4000:e8a3:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id q24-20020a9d7c98000000b006a43519523fsm886813otn.1.2023.05.12.01.03.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 01:03:46 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Sergey Organov , Junio C Hamano , Felipe Contreras Subject: [PATCH v1 5/7] diff: split --no-patch from -s Date: Fri, 12 May 2023 02:03:37 -0600 Message-Id: <20230512080339.2186324-6-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.40.0+fc1 In-Reply-To: <20230512080339.2186324-1-felipe.contreras@gmail.com> References: <20230512080339.2186324-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org It should silence only the --patch output, not all output. When --no-patch was introduced in d09cd15d19 (diff: allow --no-patch as synonym for -s, 2013-07-16), the idea was to have a more accessible shortcut to silence the output of `git show`. However, the interaction with other options was not considered, for example `--raw --no-patch`. The original intention remains, as `git show --no-patch` still produces the same: no output. Signed-off-by: Felipe Contreras --- Documentation/diff-options.txt | 5 ++--- diff.c | 5 ++++- t/t4000-diff-format.sh | 7 ++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index 08ab86189a..ba04b8292a 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -21,7 +21,7 @@ endif::git-format-patch[] ifndef::git-format-patch[] -p:: -u:: ---patch:: +--[no-]patch:: Generate patch (see section titled ifdef::git-log[] <>). @@ -34,9 +34,8 @@ ifdef::git-diff[] endif::git-diff[] -s:: ---no-patch:: Suppress diff output. Useful for commands like `git show` that - show the patch by default, or to cancel the effect of `--patch`. + show output by default. endif::git-format-patch[] ifdef::git-log[] diff --git a/diff.c b/diff.c index 4f4b1d7e13..45c860496f 100644 --- a/diff.c +++ b/diff.c @@ -5493,9 +5493,12 @@ struct option *add_diff_options(const struct option *opts, OPT_BITOP('p', "patch", &options->output_format, N_("generate patch"), DIFF_FORMAT_PATCH, DIFF_FORMAT_DEFAULT | DIFF_FORMAT_NO_OUTPUT), - OPT_SET_INT_F('s', "no-patch", &options->output_format, + OPT_SET_INT_F('s', NULL, &options->output_format, N_("suppress diff output"), DIFF_FORMAT_NO_OUTPUT, PARSE_OPT_NONEG), + OPT_BITOP(0, "no-patch", &options->output_format, + N_("negate --patch"), + DIFF_FORMAT_NO_OUTPUT, DIFF_FORMAT_PATCH | DIFF_FORMAT_DEFAULT), OPT_BITOP('u', NULL, &options->output_format, N_("generate patch"), DIFF_FORMAT_PATCH, DIFF_FORMAT_DEFAULT | DIFF_FORMAT_NO_OUTPUT), diff --git a/t/t4000-diff-format.sh b/t/t4000-diff-format.sh index 7829cc810d..d7b9a2dab8 100755 --- a/t/t4000-diff-format.sh +++ b/t/t4000-diff-format.sh @@ -67,9 +67,10 @@ test_expect_success 'git diff-files -s after editing work tree' ' test_must_be_empty err ' -test_expect_success 'git diff-files --no-patch as synonym for -s' ' - git diff-files --no-patch >actual 2>err && - test_must_be_empty actual && +test_expect_success 'git diff-files --no-patch negates --patch' ' + git diff-files >expected_raw && + git diff-files --raw --patch --no-patch >actual 2>err && + test_cmp expected_raw actual && test_must_be_empty err ' From patchwork Fri May 12 08:03:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13238825 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 1FE5DC77B75 for ; Fri, 12 May 2023 08:04:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240297AbjELIES (ORCPT ); Fri, 12 May 2023 04:04:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240175AbjELIDz (ORCPT ); Fri, 12 May 2023 04:03:55 -0400 Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75D9A106C7 for ; Fri, 12 May 2023 01:03:49 -0700 (PDT) Received: by mail-ot1-x334.google.com with SMTP id 46e09a7af769-6ab38a85a1eso1878709a34.1 for ; Fri, 12 May 2023 01:03:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683878628; x=1686470628; 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=g1Z0cfAq0aabBm8FzgeQmq6D+BvEWRX37KEkRzg2W1M=; b=AWimjRy78NekLONnfVj+e8s/cAAaXTX3BqiTaoaneKjz9LLxTbFgbNLx8LvlvOjni3 IbFoqnSZDC/RCXQeMk+VOkXIz+CZueD3Ctnp5B/fJ4XD+i6QjPGmsjzE/t3G82PHLeyk TkVkLt6gm6ktmRyyxbqexW7ZWivbM3r/8aHe5ij4ZPiYHOh2SVmKcXj3Rh9l/gHbOuvD P/WiBldM50aBXnW3svW5g5ANlgjLyED3KbThKMQSNBeL8H/mck0UWbB9zfhJQ0DQkoYU nm0QH4tI8ky/8cjDI1frQDzDij9YSPSF+HORI2hK+6bpGcsjblzYiUUAIXjTQ/Lr57LP OEsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683878628; x=1686470628; 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=g1Z0cfAq0aabBm8FzgeQmq6D+BvEWRX37KEkRzg2W1M=; b=d0y+T9hjpYIGZAHVGBzb3/HPN8deVPFcegs/FpKNYQTGr6lUd6TSjxo5tWtLX7av8X GMoOtlf30z7k/10B32bBRnPhffJaxNNwI6eHhJbcVHcgdEq2QBL2NYC4oKXulq6hvhLB xcpPMtVkDpkei3KZt7R98Y/8HREseo+iwkbs5CgnqVH7hDpXhkYSbllhcchvSFDs3qxj 1BjNonQOkEsoziBJEryo4l1+e41cUFPCvpAB9u3gjAtTan0/idIgBqBx/qv1h383mVNV /AecXNOfjNAOBnhvafqjHZv72Je6ZP76lFoiCVFx2zRQ8ksdfsCtb8tLyxQm5P/1zipK 8fBw== X-Gm-Message-State: AC+VfDwSoBrDag6wgQizy1STHEC9TeUKfPP5alWYhz6KhzTgByHiiJpU 0JokGg6YhxSyREf6x6uX3yPdhcARk9s= X-Google-Smtp-Source: ACHHUZ6oSvywhaiqyRxXLr75ZMYwdgKJXpgZfh+Y/i+qFAo7x5Je+giTlxBCWHUDS/d+7uNLj4Gb6A== X-Received: by 2002:aca:1c14:0:b0:392:5882:69c7 with SMTP id c20-20020aca1c14000000b00392588269c7mr5535276oic.52.1683878628236; Fri, 12 May 2023 01:03:48 -0700 (PDT) Received: from localhost ([2806:2f0:4000:e8a3:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id z83-20020aca3356000000b0039466db554dsm895238oiz.18.2023.05.12.01.03.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 01:03:47 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Sergey Organov , Junio C Hamano , Felipe Contreras Subject: [PATCH v1 6/7] diff: add --silent as alias of -s Date: Fri, 12 May 2023 02:03:38 -0600 Message-Id: <20230512080339.2186324-7-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.40.0+fc1 In-Reply-To: <20230512080339.2186324-1-felipe.contreras@gmail.com> References: <20230512080339.2186324-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Ever since 2e5e98a40 ([PATCH] Silent flag for show-diff, 2005-04-13) -s meant silent. Signed-off-by: Felipe Contreras --- Documentation/diff-options.txt | 1 + diff.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index ba04b8292a..a402b6f9b6 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -34,6 +34,7 @@ ifdef::git-diff[] endif::git-diff[] -s:: +--silent:: Suppress diff output. Useful for commands like `git show` that show output by default. endif::git-format-patch[] diff --git a/diff.c b/diff.c index 45c860496f..d171f155b1 100644 --- a/diff.c +++ b/diff.c @@ -5493,7 +5493,7 @@ struct option *add_diff_options(const struct option *opts, OPT_BITOP('p', "patch", &options->output_format, N_("generate patch"), DIFF_FORMAT_PATCH, DIFF_FORMAT_DEFAULT | DIFF_FORMAT_NO_OUTPUT), - OPT_SET_INT_F('s', NULL, &options->output_format, + OPT_SET_INT_F('s', "silent", &options->output_format, N_("suppress diff output"), DIFF_FORMAT_NO_OUTPUT, PARSE_OPT_NONEG), OPT_BITOP(0, "no-patch", &options->output_format, From patchwork Fri May 12 08:03:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13238826 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 5143CC77B75 for ; Fri, 12 May 2023 08:04:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240136AbjELIEW (ORCPT ); Fri, 12 May 2023 04:04:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240240AbjELIEM (ORCPT ); Fri, 12 May 2023 04:04:12 -0400 Received: from mail-oo1-xc35.google.com (mail-oo1-xc35.google.com [IPv6:2607:f8b0:4864:20::c35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8542EE73C for ; Fri, 12 May 2023 01:03:50 -0700 (PDT) Received: by mail-oo1-xc35.google.com with SMTP id 006d021491bc7-54fdc9b8351so2116184eaf.0 for ; Fri, 12 May 2023 01:03:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683878629; x=1686470629; 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=7FFEGWOkTDRTYD+pNddx00TPC1Btt47YBQd8AoEYSpA=; b=M/a8ym21sI06yVYJhHNyqhp0Q5KkWYSSzxxHKfxtRp/vyuJ9M69Q+bM3CllVUCxDTS Uv5P1X6d2c6/Dr6oVlA7keGWAj3u1ZvLCaR2RHfAML0iwz84K8NDGaQ+yFlp6zLK8ri8 61Cy+QssoEtqDLB9C0KYbTLGMXk2G+tgmTqH8dDFR9auCKj+ml+kqfx91ZKOWnbPcdj2 V11QuCMG01cGWsAL2pkxYNaMGy+fCV6/MS3U14yylbYK8gMcvAvckmPgte73aM1npjyb /QHYpHtcGR+KH+86vCz4CckH38dsUwsJWmVprb8kXn/Q2z24YbCUcZCMIdQ4jOnut5Z4 qqnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683878629; x=1686470629; 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=7FFEGWOkTDRTYD+pNddx00TPC1Btt47YBQd8AoEYSpA=; b=XHOOq1mAPmYXZweneqyJPyz0XxWjtrXWRnOz4wC/LF8kJhWAUZNG4i9O1MBX3DvI3q al3RnzqJNDqPOGUKnsb2K+fI4ZmRd2/yf9YXAh8v9F/6KSSjUCWX0TRHEI6XNZOgGowj m3I5WllGL7WAZ89vwQ/vLQHua8mWwBB/XvkMsfCojbIOMpLC0hNUf/i/55n9hS5bBI6G F8XYqERyTYz+ZBgeLWgam2ZxCvHkX97koTkG0OV69a+Zi/VffONTIisVLg3I89nWRgJS +wJr+2pEY7aOt84LKukPyIkeWYWgY9opwIOQT7agunlG2xNkM1kiJB93X3curpDuiT1p RhrA== X-Gm-Message-State: AC+VfDzIhY2tIzYE368TMfhpRGi2j2kxpzXiddPrisKoblsujq3EkvAx hT24lp4KceoAIEskvn2L1ov29UkkTQ8= X-Google-Smtp-Source: ACHHUZ7RlXZnqjlRf4aLaAddXifXY7Tt96HKkzTFCkWnEB1kVVPbXGG1OXowHij2B12vzIQLMprRPA== X-Received: by 2002:a05:6808:302a:b0:395:1c40:64b5 with SMTP id ay42-20020a056808302a00b003951c4064b5mr218477oib.7.1683878629528; Fri, 12 May 2023 01:03:49 -0700 (PDT) Received: from localhost ([2806:2f0:4000:e8a3:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id h12-20020a056808014c00b00394627263a0sm1080504oie.57.2023.05.12.01.03.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 01:03:49 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Sergey Organov , Junio C Hamano , Felipe Contreras Subject: [PATCH v1 7/7] diff: remove DIFF_FORMAT_NO_OUTPUT Date: Fri, 12 May 2023 02:03:39 -0600 Message-Id: <20230512080339.2186324-8-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.40.0+fc1 In-Reply-To: <20230512080339.2186324-1-felipe.contreras@gmail.com> References: <20230512080339.2186324-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. No functional changes. 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 | 21 ++++++++++----------- diff.h | 1 - log-tree.c | 4 ++-- merge-ort.c | 4 ++-- merge-recursive.c | 4 ++-- notes-merge.c | 4 ++-- revision.c | 2 +- tree-diff.c | 2 +- 13 files changed, 30 insertions(+), 34 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 d2a81f36c2..4fbdbd349d 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -277,7 +277,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 1e3cd7fb17..b054177b20 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -1394,7 +1394,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; @@ -1408,17 +1408,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); } @@ -1521,7 +1519,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 d171f155b1..1f87127a93 100644 --- a/diff.c +++ b/diff.c @@ -4801,8 +4801,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 | @@ -4846,7 +4845,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; } @@ -4987,7 +4986,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; } @@ -5492,16 +5491,16 @@ 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_SET_INT_F('s', "silent", &options->output_format, N_("suppress diff output"), - DIFF_FORMAT_NO_OUTPUT, PARSE_OPT_NONEG), + 0, PARSE_OPT_NONEG), OPT_BITOP(0, "no-patch", &options->output_format, N_("negate --patch"), - DIFF_FORMAT_NO_OUTPUT, DIFF_FORMAT_PATCH | DIFF_FORMAT_DEFAULT), + 0, DIFF_FORMAT_PATCH | DIFF_FORMAT_DEFAULT), 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), @@ -5513,11 +5512,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), @@ -6648,7 +6647,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 44da1a4ca7..48e8ff962e 100644 --- a/diff.h +++ b/diff.h @@ -94,7 +94,6 @@ typedef void (*diff_format_fn_t)(struct diff_queue_struct *q, typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data); -#define DIFF_FORMAT_NO_OUTPUT 0x0000 #define DIFF_FORMAT_RAW 0x0001 #define DIFF_FORMAT_DIFFSTAT 0x0002 #define DIFF_FORMAT_NUMSTAT 0x0004 diff --git a/log-tree.c b/log-tree.c index f4b22a60cc..b073e1dea4 100644 --- a/log-tree.c +++ b/log-tree.c @@ -874,7 +874,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; @@ -882,7 +882,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 a50b095c47..392549a24b 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -3248,7 +3248,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]; @@ -3269,7 +3269,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 8e87b6386d..d5678424f3 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -1904,7 +1904,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); @@ -1914,7 +1914,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/revision.c b/revision.c index 07d653c197..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 */ diff --git a/tree-diff.c b/tree-diff.c index 20bb15f38d..757a271348 100644 --- a/tree-diff.c +++ b/tree-diff.c @@ -627,7 +627,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;