From patchwork Sat Dec 17 13:29:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 13075823 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 CF0CBC4167B for ; Sat, 17 Dec 2022 13:30:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230342AbiLQNaR (ORCPT ); Sat, 17 Dec 2022 08:30:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229841AbiLQNaN (ORCPT ); Sat, 17 Dec 2022 08:30:13 -0500 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D39F0E0DD for ; Sat, 17 Dec 2022 05:30:11 -0800 (PST) Received: by mail-lf1-x12c.google.com with SMTP id 1so7520459lfz.4 for ; Sat, 17 Dec 2022 05:30:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=CB24dgm+kWM+tJeOmjM6R+xFRuJgy4tRr6MqIu+pcl4=; b=QMwjn0ftBilFAuOcstj0RhYy0o1f9f3O1BWjLCs1omAJf3BZxpjQqZyK1j4l+4Sl9p W0JHGhyTBxgayaVC3TWWXFmTYzowXjtyTjZKqWqhLFPEANlRdYL1IdNo1yhxTU0d+1sa O6rjW4b8N4okX7s8T/gdh7EP787/VYPkgMv5yPFMbMpzEyjsMU9I87zUQxGCKiG5pqRv S0oQLl0QSf1PKO2Z6q1gBtSsQoAT8CbdltPxtWkJaFIALasXYvr0vSKjE5T/O4IpNpYv 9rvaV7osf04Q5TIPLXXSEWxyOteT8DHa3KTJYIttZNusP6Pttn1cL80OILwEbo8NCApV CMNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=CB24dgm+kWM+tJeOmjM6R+xFRuJgy4tRr6MqIu+pcl4=; b=fLdj69jpYzUj/6cwcMYJuyntLqH2kdPqjNyuGuZMjW7WixekZolmV3TztTqR6RaG6U Ah8hfdcAxKJLS78r5UGGeT5Ajm1cAnzPOwbYRobxKZjqzEWyWEBHjhtmXlKEJHpB+GCW 431lYhowCD6laBTVg6dtwMAz7ndWrffsV0dcFiuyZ1G5ahm5tocssgAzVQwNEIFenG2s G77LFT4xs8tqXjYnLkA623vwOWuecls1NPNMnbZqOfGBIbIisOk3Sgt7ck6cIw5dR2xZ i32+HQd3zex4TuZIv6Jp30ph95wZp8E1Z3HLwZtmfJmqMnWEb7Wl7ofmvFqi5cJFJCwc dUkg== X-Gm-Message-State: ANoB5pmJnROHoUYfy0sQ2MHWOKU04Y1ToOac1AHBIehiiuv7SvPX/jky /pInyI0/33R6IOuk4gho06Y= X-Google-Smtp-Source: AA0mqf7OrnIMsyvqRPbPfvOVRxpIbkVQQ5Zn7oF1d8MpeIDoFdpiUfLwDqtQmXzeP0w1qLVylLQUpw== X-Received: by 2002:a05:6512:25a4:b0:4b5:87da:8b35 with SMTP id bf36-20020a05651225a400b004b587da8b35mr11555154lfb.61.1671283810149; Sat, 17 Dec 2022 05:30:10 -0800 (PST) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id q6-20020a056512210600b004a100c21eaesm512420lfr.97.2022.12.17.05.30.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 05:30:09 -0800 (PST) From: Sergey Organov To: Junio C Hamano Cc: Jeff King , Philip Oakley , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= , Alex Henrie , Jonathan Nieder , huang guanlong , Glen Choo , git@vger.kernel.org, Sergey Organov Subject: [PATCH v1 1/5] diff-merges: implement [no-]hide option and log.diffMergesHide config Date: Sat, 17 Dec 2022 16:29:51 +0300 Message-Id: <20221217132955.108542-2-sorganov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221217132955.108542-1-sorganov@gmail.com> References: <20221217132955.108542-1-sorganov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The set of diff-merges options happened to be incomplete, and failed to implement exact semantics of -m option that hides output of diffs for merge commits unless -p option is active as well. The new "hide" option fixes this issue, so that now --diff-merges=on --diff-merges=hide combo is the exact synonym for -m. The log.diffMerges configuration also accepts "hide" and "no-hide" values, and governs the default value for the hide bit. The configuration behaves as if "--diff-merges=[no-]hide" is inserted first in the command-line. New log.diffMergesHide boolean configuration is implemented as well, for the case when log.diffMerges is already in use for specifying the format. Signed-off-by: Sergey Organov --- Documentation/config/log.txt | 6 +++ Documentation/diff-options.txt | 13 +++-- builtin/log.c | 2 + diff-merges.c | 40 ++++++++++++-- diff-merges.h | 2 + t/t4013-diff-various.sh | 54 ++++++++++++++++++- ...ges=first-parent_--diff-merges=hide_master | 34 ++++++++++++ t/t9902-completion.sh | 3 ++ 8 files changed, 147 insertions(+), 7 deletions(-) create mode 100644 t/t4013/diff.log_--diff-merges=first-parent_--diff-merges=hide_master diff --git a/Documentation/config/log.txt b/Documentation/config/log.txt index cbe34d759221..9c6be643bcf6 100644 --- a/Documentation/config/log.txt +++ b/Documentation/config/log.txt @@ -33,6 +33,12 @@ log.diffMerges:: Set diff format to be used when `--diff-merges=on` is specified, see `--diff-merges` in linkgit:git-log[1] for details. Defaults to `separate`. ++ +When used with 'hide' or 'no-hide', sets the default hiding of +diffs for merge commits when `-p` option is not used. + +log.diffMergesHide:: + `true` implies `--diff-merges=hide` option. log.follow:: If `true`, `git log` will act as if the `--follow` option was used when diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index 3674ac48e92c..b062bdab04d9 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -34,7 +34,7 @@ endif::git-diff[] endif::git-format-patch[] ifdef::git-log[] ---diff-merges=(off|none|on|first-parent|1|separate|m|combined|c|dense-combined|cc|remerge|r):: +--diff-merges=(off|none|on|first-parent|1|separate|m|combined|c|dense-combined|cc|remerge|r|[no-]hide):: --no-diff-merges:: Specify diff format to be used for merge commits. Default is {diff-merges-default} unless `--first-parent` is in use, in which case @@ -49,10 +49,11 @@ ifdef::git-log[] --diff-merges=m::: -m::: This option makes diff output for merge commits to be shown in - the default format. `-m` will produce the output only if `-p` - is given as well. The default format could be changed using + the default format. The default format could be changed using `log.diffMerges` configuration parameter, which default value is `separate`. ++ + `-m` is a shortcut for '--diff-merges=on --diff-merges=hide' + --diff-merges=first-parent::: --diff-merges=1::: @@ -94,6 +95,12 @@ documented). uninteresting hunks whose contents in the parents have only two variants and the merge result picks one of them without modification. `--cc` implies `-p`. ++ +--diff-merges=hide::: +--diff-merges=no-hide::: + Hide (do not hide) the diff for merge commits unless `-p` options is given + as well. The default `no-hide` could be changed using `log.diffMerges` + configuration parameter. --combined-all-paths:: This flag causes combined diffs (used for merge commits) to diff --git a/builtin/log.c b/builtin/log.c index 56e2d95e869d..e031021e53b2 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -581,6 +581,8 @@ static int git_log_config(const char *var, const char *value, void *cb) } if (!strcmp(var, "log.diffmerges")) return diff_merges_config(value); + if (!strcmp(var, "log.diffmergeshide")) + return diff_merges_hide_config(git_config_bool(var, value)); if (!strcmp(var, "log.showroot")) { default_show_root = git_config_bool(var, value); return 0; diff --git a/diff-merges.c b/diff-merges.c index 85cbefa5afd7..55fe5b70c102 100644 --- a/diff-merges.c +++ b/diff-merges.c @@ -7,6 +7,7 @@ static void set_separate(struct rev_info *revs); static diff_merges_setup_func_t set_to_default = set_separate; static int suppress_m_parsing; +static int hide = 0; static void suppress(struct rev_info *revs) { @@ -20,10 +21,15 @@ static void suppress(struct rev_info *revs) revs->remerge_diff = 0; } +static void set_need_diff(struct rev_info *revs) +{ + revs->merges_need_diff = !hide; +} + static void common_setup(struct rev_info *revs) { suppress(revs); - revs->merges_need_diff = 1; + set_need_diff(revs); } static void set_none(struct rev_info *revs) @@ -31,6 +37,18 @@ static void set_none(struct rev_info *revs) suppress(revs); } +static void set_hide(struct rev_info *revs) +{ + hide = 1; + set_need_diff(revs); +} + +static void set_no_hide(struct rev_info *revs) +{ + hide = 0; + set_need_diff(revs); +} + static void set_separate(struct rev_info *revs) { common_setup(revs); @@ -69,6 +87,10 @@ static diff_merges_setup_func_t func_by_opt(const char *optarg) { if (!strcmp(optarg, "off") || !strcmp(optarg, "none")) return set_none; + if (!strcmp(optarg, "hide")) + return set_hide; + if (!strcmp(optarg, "no-hide")) + return set_no_hide; if (!strcmp(optarg, "1") || !strcmp(optarg, "first-parent")) return set_first_parent; if (!strcmp(optarg, "separate")) @@ -105,7 +127,19 @@ int diff_merges_config(const char *value) if (!func) return -1; - set_to_default = func; + if (func == set_hide) + hide = 1; + else if (func == set_no_hide) + hide = 0; + else + set_to_default = func; + + return 0; +} + +int diff_merges_hide_config(int on) +{ + hide = on; return 0; } @@ -122,7 +156,7 @@ int diff_merges_parse_opts(struct rev_info *revs, const char **argv) if (!suppress_m_parsing && !strcmp(arg, "-m")) { set_to_default(revs); - revs->merges_need_diff = 0; + set_hide(revs); } else if (!strcmp(arg, "-c")) { set_combined(revs); revs->merges_imply_patch = 1; diff --git a/diff-merges.h b/diff-merges.h index 19639689bb05..e86e5381693b 100644 --- a/diff-merges.h +++ b/diff-merges.h @@ -11,6 +11,8 @@ struct rev_info; int diff_merges_config(const char *value); +int diff_merges_hide_config(int hide); + void diff_merges_suppress_m_parsing(void); int diff_merges_parse_opts(struct rev_info *revs, const char **argv); diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index dfcf3a0aaae3..4fc8ba2fc59c 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -334,6 +334,7 @@ log --first-parent --diff-merges=off -p master log -p --first-parent master log -p --diff-merges=first-parent master log --diff-merges=first-parent master +log --diff-merges=first-parent --diff-merges=hide master log -m -p --first-parent master log -m -p master log --cc -m -p master @@ -460,7 +461,18 @@ EOF test_expect_success 'log -m matches pure log' ' git log master >result && process_diffs result >expected && - git log -m >result && + git log -m master >result && + process_diffs result >actual && + test_cmp expected actual +' + +test_expect_success 'log --diff-merges=on matches -m only with --diff-merges=hide' ' + git log -m master >result && + process_diffs result >expected && + git log --diff-merges=on master >result && + process_diffs result >actual && + ! test_cmp expected actual && + git log --diff-merges=on --diff-merges=hide master >result && process_diffs result >actual && test_cmp expected actual ' @@ -496,6 +508,46 @@ test_expect_success 'git config log.diffMerges first-parent vs -m' ' test_cmp expected actual ' +test_expect_success 'git config log.diffMerges hide: has effect' ' + git log --diff-merges=on master >result && + process_diffs result >no-hide && + test_config log.diffMerges hide && + git log --diff-merges=on master >result && + process_diffs result >hide && + ! test_cmp no-hide hide +' + +test_expect_success 'git config log.diffMerges no-hide: is the default' ' + git log --diff-merges=on master >result && + process_diffs result >default && + test_config log.diffMerges no-hide && + git log --diff-merges=on master >result && + process_diffs result >no-hide && + test_cmp default no-hide +' + +# As "-m" is synonym for "--diff-merges=hide --diff-merges=on", the +# "log.diffMerges=hide" configuration should have no effect on "-m" +test_expect_success 'git config log.diffMerges hide: has no effect on -m' ' + git log -m master >result && + process_diffs result >expected && + test_config log.diffMerges hide && + git log -m master >result && + process_diffs result >actual && + test_cmp expected actual +' + +# As "--cc" implies "-p", the "log.diffMerges=hide" configuration +# should have no effect on "--cc" +test_expect_success 'git config log.diffMerges hide: has no effect on --cc' ' + git log --cc master >result && + process_diffs result >expected && + test_config log.diffMerges hide && + git log --cc master >result && + process_diffs result >actual && + test_cmp expected actual +' + # -m in "git diff-index" means "match missing", that differs # from its meaning in "git diff". Let's check it in diff-index. # The line in the output for removed file should disappear when diff --git a/t/t4013/diff.log_--diff-merges=first-parent_--diff-merges=hide_master b/t/t4013/diff.log_--diff-merges=first-parent_--diff-merges=hide_master new file mode 100644 index 000000000000..596caec64298 --- /dev/null +++ b/t/t4013/diff.log_--diff-merges=first-parent_--diff-merges=hide_master @@ -0,0 +1,34 @@ +$ git log --diff-merges=first-parent --diff-merges=hide master +commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 +Merge: 9a6d494 c7a2ab9 +Author: A U Thor +Date: Mon Jun 26 00:04:00 2006 +0000 + + Merge branch 'side' + +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a +Author: A U Thor +Date: Mon Jun 26 00:03:00 2006 +0000 + + Side + +commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 +Author: A U Thor +Date: Mon Jun 26 00:02:00 2006 +0000 + + Third + +commit 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44 +Author: A U Thor +Date: Mon Jun 26 00:01:00 2006 +0000 + + Second + + This is the second commit. + +commit 444ac553ac7612cc88969031b02b3767fb8a353a +Author: A U Thor +Date: Mon Jun 26 00:00:00 2006 +0000 + + Initial +$ diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 43de868b8005..fc6b0722216a 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -2497,6 +2497,7 @@ test_expect_success 'git config - variable name' ' log.date Z log.decorate Z log.diffMerges Z + log.diffMergesHide Z EOF ' @@ -2525,6 +2526,7 @@ test_expect_success 'git -c - variable name' ' log.date=Z log.decorate=Z log.diffMerges=Z + log.diffMergesHide=Z EOF ' @@ -2547,6 +2549,7 @@ test_expect_success 'git clone --config= - variable name' ' log.date=Z log.decorate=Z log.diffMerges=Z + log.diffMergesHide=Z EOF ' From patchwork Sat Dec 17 13:29:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 13075824 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 58F1EC4332F for ; Sat, 17 Dec 2022 13:30:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230344AbiLQNaV (ORCPT ); Sat, 17 Dec 2022 08:30:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230328AbiLQNaO (ORCPT ); Sat, 17 Dec 2022 08:30:14 -0500 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2412BE0F8 for ; Sat, 17 Dec 2022 05:30:13 -0800 (PST) Received: by mail-lf1-x129.google.com with SMTP id o6so2631948lfi.5 for ; Sat, 17 Dec 2022 05:30:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=UIYMQ9Nax2Lz3kFOp+oM7WUww5g8ylKVgs4UvB+znX8=; b=afpGKdDY4rklDKaNZRJuHdAVQeskLsfsJGYWWCeTCgVumi9gwDLcTdJnFQaOaKR2nD 4BLHbpFk8SZeCZkKlhGMUxAPA1cB1RI+OU7h75xLhyTlrAquODwsigxgkC+VnaYvbMsk 4t1Uc5FvOTojXIcDjttSGWu+vidan9VacbHwpj1sgosvfwBiy+BsH/Aj45IxasP6GtPP adnh3MWrlKDFGbkINum+HQNmE0SLi82oDiaxoXqX2ZR5u7NWK7DfvWkyUlcD1Hs64uoV UsHycuVcA2F7C+6GpZfSeL9+RCYEwDSVU2mMoNH8nOfrEi3GM6380D8CKhTVoaqeWaqc Bb1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=UIYMQ9Nax2Lz3kFOp+oM7WUww5g8ylKVgs4UvB+znX8=; b=qkpVZbYwH2Hm5a9+ntY0rlXDrnF4alH+eARmt4Fe2DUq5ZU1Hdn/toqmUfKbU8vH0/ 8FRSOKTiWSJuCJWpvNxy5VP+n7aZlemQylHjhjXl4vhdVGLtN/84+nUchGu1JdT+lAWi 83xgiGDcmM9KigBvfJWo3EO942mIfHvaKJFeRVFF3gqU/cCgKm1p4ZBPkHcpG7rl/wgs vNjWGRdKGcB3ewnAFJ5yRHHmeUmvOBfxui9U02iH5B0lScclWk6D5+VhboxbS8rMRrZS RrEEuCTvUIvdlSFOdF5guxSpy4F0ODmFKDl0aQ6xUGUtHdrKhZNvxviX5aToXfcDkq6s HHkQ== X-Gm-Message-State: ANoB5pkhFtlGIlJaYE3gKP2n8UvtaR9DgklAFO2njkVHnUt1RG6ReaW6 hrTAngkDimMxC2L9V6OdroI= X-Google-Smtp-Source: AA0mqf4KLUdNkqzL1131t+ZXYlemACWR01B1Nbdoo5rg9CzQX/TomygbyxiIwV/YcAAhqCMGUnb+Ug== X-Received: by 2002:a05:6512:304b:b0:4b5:892:3987 with SMTP id b11-20020a056512304b00b004b508923987mr20928766lfb.9.1671283811462; Sat, 17 Dec 2022 05:30:11 -0800 (PST) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id q6-20020a056512210600b004a100c21eaesm512420lfr.97.2022.12.17.05.30.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 05:30:10 -0800 (PST) From: Sergey Organov To: Junio C Hamano Cc: Jeff King , Philip Oakley , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= , Alex Henrie , Jonathan Nieder , huang guanlong , Glen Choo , git@vger.kernel.org, Sergey Organov Subject: [PATCH v1 2/5] diff-merges: implement log.diffMerges-m-imply-p config Date: Sat, 17 Dec 2022 16:29:52 +0300 Message-Id: <20221217132955.108542-3-sorganov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221217132955.108542-1-sorganov@gmail.com> References: <20221217132955.108542-1-sorganov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Historically, `-m` doesn't imply `-p` whereas similar `-c` and `--cc` options do. Simply fixing this inconsistency by unconditional modification of `-m` semantics appeared to be a bad idea, as it broke some legacy scripts. Implement "log.diffMerges-m-imply-p" boolean configuration variable that allows user to enable implication of `-p` by `-m`. Signed-off-by: Sergey Organov --- Documentation/config/log.txt | 3 +++ Documentation/diff-options.txt | 6 ++++-- builtin/log.c | 2 ++ diff-merges.c | 8 ++++++++ diff-merges.h | 2 ++ t/t4013-diff-various.sh | 9 +++++++++ t/t9902-completion.sh | 3 +++ 7 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Documentation/config/log.txt b/Documentation/config/log.txt index 9c6be643bcf6..265a57312e58 100644 --- a/Documentation/config/log.txt +++ b/Documentation/config/log.txt @@ -40,6 +40,9 @@ diffs for merge commits when `-p` option is not used. log.diffMergesHide:: `true` implies `--diff-merges=hide` option. +log.diffMerges-m-imply-p:: + `true` enables implication of `-p` by `-m`. + log.follow:: If `true`, `git log` will act as if the `--follow` option was used when a single is given. This has the same limitations as `--follow`, diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index b062bdab04d9..fe15693492a2 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -48,12 +48,14 @@ ifdef::git-log[] --diff-merges=on::: --diff-merges=m::: -m::: - This option makes diff output for merge commits to be shown in + These options make diff output for merge commits to be shown in the default format. The default format could be changed using `log.diffMerges` configuration parameter, which default value is `separate`. + - `-m` is a shortcut for '--diff-merges=on --diff-merges=hide' + `-m` is a shortcut for '--diff-merges=on --diff-merges=hide'. + In addition it implies `-p` when `log.diffMerges-m-imply-p` is + active. + --diff-merges=first-parent::: --diff-merges=1::: diff --git a/builtin/log.c b/builtin/log.c index e031021e53b2..332b5e478cc5 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -583,6 +583,8 @@ static int git_log_config(const char *var, const char *value, void *cb) return diff_merges_config(value); if (!strcmp(var, "log.diffmergeshide")) return diff_merges_hide_config(git_config_bool(var, value)); + if (!strcmp(var, "log.diffmerges-m-imply-p")) + return diff_merges_m_imply_p_config(git_config_bool(var, value)); if (!strcmp(var, "log.showroot")) { default_show_root = git_config_bool(var, value); return 0; diff --git a/diff-merges.c b/diff-merges.c index 55fe5b70c102..1fbf476d378e 100644 --- a/diff-merges.c +++ b/diff-merges.c @@ -8,6 +8,7 @@ static void set_separate(struct rev_info *revs); static diff_merges_setup_func_t set_to_default = set_separate; static int suppress_m_parsing; static int hide = 0; +static int m_imply_p = 0; static void suppress(struct rev_info *revs) { @@ -143,6 +144,12 @@ int diff_merges_hide_config(int on) return 0; } +int diff_merges_m_imply_p_config(int on) +{ + m_imply_p = on; + return 0; +} + void diff_merges_suppress_m_parsing(void) { suppress_m_parsing = 1; @@ -157,6 +164,7 @@ int diff_merges_parse_opts(struct rev_info *revs, const char **argv) if (!suppress_m_parsing && !strcmp(arg, "-m")) { set_to_default(revs); set_hide(revs); + revs->merges_imply_patch = m_imply_p; } else if (!strcmp(arg, "-c")) { set_combined(revs); revs->merges_imply_patch = 1; diff --git a/diff-merges.h b/diff-merges.h index e86e5381693b..9f0b3901fe82 100644 --- a/diff-merges.h +++ b/diff-merges.h @@ -13,6 +13,8 @@ int diff_merges_config(const char *value); int diff_merges_hide_config(int hide); +int diff_merges_m_imply_p_config(int on); + void diff_merges_suppress_m_parsing(void); int diff_merges_parse_opts(struct rev_info *revs, const char **argv); diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index 4fc8ba2fc59c..1789dd6063c5 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -548,6 +548,15 @@ test_expect_success 'git config log.diffMerges hide: has no effect on --cc' ' test_cmp expected actual ' +test_expect_success 'git config log.diffMerges-m-imply-p has proper effect' ' + git log -m -p master >result && + process_diffs result >expected && + test_config log.diffMerges-m-imply-p true && + git log -m master >result && + process_diffs result >actual && + test_cmp expected actual +' + # -m in "git diff-index" means "match missing", that differs # from its meaning in "git diff". Let's check it in diff-index. # The line in the output for removed file should disappear when diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index fc6b0722216a..26a7e4ff877c 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -2498,6 +2498,7 @@ test_expect_success 'git config - variable name' ' log.decorate Z log.diffMerges Z log.diffMergesHide Z + log.diffMerges-m-imply-p Z EOF ' @@ -2527,6 +2528,7 @@ test_expect_success 'git -c - variable name' ' log.decorate=Z log.diffMerges=Z log.diffMergesHide=Z + log.diffMerges-m-imply-p=Z EOF ' @@ -2550,6 +2552,7 @@ test_expect_success 'git clone --config= - variable name' ' log.decorate=Z log.diffMerges=Z log.diffMergesHide=Z + log.diffMerges-m-imply-p=Z EOF ' From patchwork Sat Dec 17 13:29:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 13075825 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 87F99C4167B for ; Sat, 17 Dec 2022 13:30:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230348AbiLQNaW (ORCPT ); Sat, 17 Dec 2022 08:30:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230333AbiLQNaP (ORCPT ); Sat, 17 Dec 2022 08:30:15 -0500 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E5E0CE27 for ; Sat, 17 Dec 2022 05:30:14 -0800 (PST) Received: by mail-lf1-x12e.google.com with SMTP id m29so7281967lfo.11 for ; Sat, 17 Dec 2022 05:30:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=6tg7Sc6A7HRHCGAHZaDm1ezvbQt7uXm61tcUxVCYI1k=; b=kQYd3ICk+ArqAD0dFNxqapenJfgnssK5xuV6ohEFX+R5S7WkEg+NGpdhV01WqFRlUh U6CgbdMyZEoruVksS6OOIQ1303gUYreVPGqrgGHyWdf6OIh7iMKx3qMviCkEakfp7hCa 9C5I3pC+C0RTdDODUsoqEMPR6X5hr8u+l0Js8hKmHMGTa4obHnRAafQpxIcCo9j1Dy+9 X+zV9rUbfF1LuRiBJFcmWBITtDo+VQV8GN5J0x4Vqfoct/uZ8NFzLDFSgxPcwllKsrsX UglxyoxnPRXWDGHfx/dYSL+b57Xhwxa3BTp261Wf4wNz76qwPRtl3AIqhkB58yyRm+fd rdLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=6tg7Sc6A7HRHCGAHZaDm1ezvbQt7uXm61tcUxVCYI1k=; b=rplCEkxoxlSt2tNBqO1RnFpL1yDlxSXcNtr0ZVb57Z+Y3lXmUH2wnD7Cc+7L0DuG4w +DXq7/mBW5LQD2evmbeq6wQUp5fPvcrFr2NqEn6KC74+OYFp8uzMY0rxzai0ibPGL1+T ZkMHXyKND2GrIVWWw71eSFP5oU1kkGNRZfK2mmxzkAdq5eHuzoXmmKATzKTHXcqDoUS9 RULv9ZynUEFpz9mHnttvTPJE5BipEDsHMDY7biJ/TwjJIeTYiRo60LaGsxJ4EjiJ+M/8 t20hVrTsA3+7+Nwzzj+Wfp6HMujeOhGCH+3LnuqdfpvgN6sB23XQYto9e/XJJJT6h7LJ mFSw== X-Gm-Message-State: ANoB5pkteiL+XBOajgCQO7OPuoJEKyOMrh2lthaClE9WiFsKr2mBsGGV uPQz4zbJNizb74Dpl3v8zmE= X-Google-Smtp-Source: AA0mqf6d9u3IG1yTjVMShj2o4RUjKLboQifs28DkleBGDc+rlZeqecl1j3VmXBUrBAxK3WS6cuxiLw== X-Received: by 2002:ac2:5310:0:b0:4b5:b46d:e52 with SMTP id c16-20020ac25310000000b004b5b46d0e52mr8047263lfh.50.1671283812555; Sat, 17 Dec 2022 05:30:12 -0800 (PST) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id q6-20020a056512210600b004a100c21eaesm512420lfr.97.2022.12.17.05.30.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 05:30:12 -0800 (PST) From: Sergey Organov To: Junio C Hamano Cc: Jeff King , Philip Oakley , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= , Alex Henrie , Jonathan Nieder , huang guanlong , Glen Choo , git@vger.kernel.org, Sergey Organov Subject: [PATCH v1 3/5] diff-merges: support list of values for --diff-merges Date: Sat, 17 Dec 2022 16:29:53 +0300 Message-Id: <20221217132955.108542-4-sorganov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221217132955.108542-1-sorganov@gmail.com> References: <20221217132955.108542-1-sorganov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Support comma-separated list of options in --diff-merges=. This allows for shorter: --diff-merges=on,hide instead of: --diff-merges=on --diff-merges=hide Signed-off-by: Sergey Organov --- Documentation/diff-options.txt | 5 +++-- diff-merges.c | 22 ++++++++++++++++++---- t/t4013-diff-various.sh | 8 ++++++++ 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index fe15693492a2..977f9135b0d6 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -38,7 +38,8 @@ ifdef::git-log[] --no-diff-merges:: Specify diff format to be used for merge commits. Default is {diff-merges-default} unless `--first-parent` is in use, in which case - `first-parent` is the default. + `first-parent` is the default. Comma-separated list of + supported values is accepted as well. + --diff-merges=(off|none)::: --no-diff-merges::: @@ -53,7 +54,7 @@ ifdef::git-log[] `log.diffMerges` configuration parameter, which default value is `separate`. + - `-m` is a shortcut for '--diff-merges=on --diff-merges=hide'. + `-m` is a shortcut for '--diff-merges=on,hide'. In addition it implies `-p` when `log.diffMerges-m-imply-p` is active. + diff --git a/diff-merges.c b/diff-merges.c index 1fbf476d378e..bb2797ff8cc5 100644 --- a/diff-merges.c +++ b/diff-merges.c @@ -1,6 +1,7 @@ #include "diff-merges.h" #include "revision.h" +#include "strbuf.h" typedef void (*diff_merges_setup_func_t)(struct rev_info *); static void set_separate(struct rev_info *revs); @@ -109,12 +110,25 @@ static diff_merges_setup_func_t func_by_opt(const char *optarg) static void set_diff_merges(struct rev_info *revs, const char *optarg) { - diff_merges_setup_func_t func = func_by_opt(optarg); + char const delim = ','; + struct strbuf **opts = strbuf_split_str(optarg, delim, -1); + struct strbuf **p; - if (!func) - die(_("invalid value for '%s': '%s'"), "--diff-merges", optarg); + for (p = opts; *p; p++) { + diff_merges_setup_func_t func; + char *opt = (*p)->buf; + int len = (*p)->len; - func(revs); + if (opt[len - 1] == delim) + opt[len - 1] = '\0'; + func = func_by_opt(opt); + if (!func) { + strbuf_list_free(opts); + die(_("invalid value for '%s': '%s'"), "--diff-merges", opt); + } + func(revs); + } + strbuf_list_free(opts); } /* diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index 1789dd6063c5..a07513e67fd6 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -485,6 +485,14 @@ test_expect_success 'log --diff-merges=on matches --diff-merges=separate' ' test_cmp expected actual ' +test_expect_success 'log --diff-merges=,' ' + git log --diff-merges=1,hide master >result && + process_diffs result >expected && + git log --diff-merges=1 --diff-merges=hide master >result && + process_diffs result >actual && + test_cmp expected actual +' + test_expect_success 'deny wrong log.diffMerges config' ' test_config log.diffMerges wrong-value && test_expect_code 128 git log From patchwork Sat Dec 17 13:29:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 13075826 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 D8016C4332F for ; Sat, 17 Dec 2022 13:30:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229496AbiLQNaZ (ORCPT ); Sat, 17 Dec 2022 08:30:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230338AbiLQNaQ (ORCPT ); Sat, 17 Dec 2022 08:30:16 -0500 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D130E0DD for ; Sat, 17 Dec 2022 05:30:15 -0800 (PST) Received: by mail-lf1-x12e.google.com with SMTP id q6so7476633lfm.10 for ; Sat, 17 Dec 2022 05:30:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=5A9gLdcm9F5SLxSqVmmhUP7MFrcHV+7hifQXKb2rOUs=; b=ZUsviuP0NX9v/n95hgmMZ2QawcfMTz2e6vnMQJrTB2DvmM13r+/ecp4CAeE0pVuO+f LyJfWK4dz7VYpG9IVrq1rmky66E0Fl3OzAnU0K9k3NsRQ0Mbxmj5aaqrdpmco9fd5P7g Gnsk7gU68bf1yPYloZvNz1izzFVq8bLRrBI+Hopwci0MB/UHiVXIhXJgr7w9t+VoRZLA Ju66UHVYzNOywGwWrNbrOopRypE5HhP0r7MWypYAycYmu8CRQBNGWESTzxDwZeb9oqx/ n8PBVfhXzTAmtBg5jHQk3bFYRloPND6WiuKzYG8OfrMbBWq9u5qjPv9M115d7W8V3keV ++aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=5A9gLdcm9F5SLxSqVmmhUP7MFrcHV+7hifQXKb2rOUs=; b=OrMeHlxiAazPGtmg/sAf4rK7cGHIVcuC4auSJSBZBgenOclVo/1CZTnH9v3Cbzv5LF gbCmSGxZejnbJ2xmwAZUDuqwp7IXtv4rhpdpDDCBULnYN1lw4SFxw8ilVsDxVfeZ2yZU pwpor1kFJO+X3uaeOiG5RR/seOU1u6z9fYEkZU7G1ZlykpkEfpJIFI0srcE4R1fIZ0KK 4gbyAu8A1hfuM5r3vdOJd+e1wxTfFx05jMB7hADUIJiN2zxB9H0I4h/tz+eHmn+MB3Km S8oFBubXONUXqEn0TMRLnH0mfDKymnD0vfVuUCLU/lTUPDkyOFTB6JwaxSLq5KTb0HLl qRKQ== X-Gm-Message-State: ANoB5pkLINunH/vL5sJ9o+vaBtEI5SRrPVbYdtauxdfU9TSZPUUbi8F/ LBKmHE9HeJ6Ho/rHPQ9vYsA= X-Google-Smtp-Source: AA0mqf504w9NWmedwLo3K7IN9JPskpbcjSeuimlP0k7FxkVoEUEl2WpQqlz6UxdNk3otL9csmwbcTA== X-Received: by 2002:a19:5e5e:0:b0:4b5:6042:d136 with SMTP id z30-20020a195e5e000000b004b56042d136mr8212141lfi.22.1671283813619; Sat, 17 Dec 2022 05:30:13 -0800 (PST) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id q6-20020a056512210600b004a100c21eaesm512420lfr.97.2022.12.17.05.30.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 05:30:13 -0800 (PST) From: Sergey Organov To: Junio C Hamano Cc: Jeff King , Philip Oakley , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= , Alex Henrie , Jonathan Nieder , huang guanlong , Glen Choo , git@vger.kernel.org, Sergey Organov Subject: [PATCH v1 4/5] diff-merges: issue warning on lone '-m' option Date: Sat, 17 Dec 2022 16:29:54 +0300 Message-Id: <20221217132955.108542-5-sorganov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221217132955.108542-1-sorganov@gmail.com> References: <20221217132955.108542-1-sorganov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Lone '-m' is in use by scripts/aliases that aim at enabling diff output for merge commits, but only if '-p' is then specified as well. As '-m' may now be configured to imply '-p', using 'log.diffMerges-m-imply-p', issue warning and suggest to instead use --diff-merges=on,hide that does not depend on user configuration. Signed-off-by: Sergey Organov --- diff-merges.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/diff-merges.c b/diff-merges.c index bb2797ff8cc5..1f4e43e16940 100644 --- a/diff-merges.c +++ b/diff-merges.c @@ -10,6 +10,7 @@ static diff_merges_setup_func_t set_to_default = set_separate; static int suppress_m_parsing; static int hide = 0; static int m_imply_p = 0; +static int got_m = 0; static void suppress(struct rev_info *revs) { @@ -179,6 +180,7 @@ int diff_merges_parse_opts(struct rev_info *revs, const char **argv) set_to_default(revs); set_hide(revs); revs->merges_imply_patch = m_imply_p; + got_m = 1; } else if (!strcmp(arg, "-c")) { set_combined(revs); revs->merges_imply_patch = 1; @@ -239,5 +241,7 @@ void diff_merges_setup_revs(struct rev_info *revs) if (revs->merges_imply_patch || revs->merges_need_diff) { if (!revs->diffopt.output_format) revs->diffopt.output_format = DIFF_FORMAT_PATCH; - } + } else if (got_m) + warning(_("legacy use of lone '-m' detected: please use '--diff-merges=on,hide' instead, as '-m' may imply '-p'")); + } From patchwork Sat Dec 17 13:29:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Organov X-Patchwork-Id: 13075827 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 09684C4332F for ; Sat, 17 Dec 2022 13:30:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230365AbiLQNa1 (ORCPT ); Sat, 17 Dec 2022 08:30:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230343AbiLQNaR (ORCPT ); Sat, 17 Dec 2022 08:30:17 -0500 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67813CE27 for ; Sat, 17 Dec 2022 05:30:16 -0800 (PST) Received: by mail-lf1-x12e.google.com with SMTP id cf42so7545697lfb.1 for ; Sat, 17 Dec 2022 05:30:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=1ee/TEUjaymjFJ0bci2nCadzw0QTA9Rx1EdY5ofB0oc=; b=ow2akf4hB8QTaKSpK/kE47qERImoB9ZkO4faS/PYn3GU4caSyYx0gU93keXgGtTZfW Mnw5zv6NKY7AX+Nuk98YW33xwHiGEPEfuqlFyN7DA90Xsbbhuv+abW26DwBpazKm5StL V3m5a2mY9i5brrYnngaHAlSySFE2sD+tpC/1ERoNoVWsJhmRtIGYzLUmWW35jxMK7ZUN VZD6scFXdzbTbf5byr9/u4mqw2EmASPvn+l3gnp7yAiOBdNYFb12m2SjbGv7Dc5dMN7x 1HkjTgRgDDgD+IYVNSjRCoUYnTBUX+MjMoCXAuyHFjUSQxCVEddwgrPVm2AuouOdsk5M Mafg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=1ee/TEUjaymjFJ0bci2nCadzw0QTA9Rx1EdY5ofB0oc=; b=g9R4MJAj2qbj56gt5Ezm5Ncb4Yp2vd97pY2glKunFJNk5jMeVElgMryqTavJcu0lDz 8/VwLM3Ibu7DfrXIym1AXkigAQKD+tUg/iWm3ukT3YtL7pgrCAht7w0wiGq+WbJjuHlM rmqKXv3FTqnx2gMuN7MMNtsHnpfHo/j4jXSZ+nnUAEEIGovcpHwRjsVfLxiXa9kfEbo5 OUmMqZY374s65coQqsNnixKodaMbpg4YThTRjQiiQkbUU2hk5TRrBfPTCc/xQItJXvtm bRSI73onPa5xOwuj+0Y/dwOUaosnJAB09Gf2B2zLEi6LqPEf5fdlh3+aGdfAQtRZZ1wl UKpA== X-Gm-Message-State: ANoB5pn4f9Jmpg9J5/P9cy6nZrX5vSlofw7UXh7BoHP9vRXs/01YotUS tF+4o+QEuMsohRGpSEh098w= X-Google-Smtp-Source: AA0mqf4+M7rP5YT/tMSC4KY8+a+b3pvqjG9lTTjE+3CbMiFd1dAFcBSa4dmUL758NzqXknV2uTO7sQ== X-Received: by 2002:a05:6512:3ba7:b0:4b5:7c02:39 with SMTP id g39-20020a0565123ba700b004b57c020039mr14730073lfv.47.1671283814719; Sat, 17 Dec 2022 05:30:14 -0800 (PST) Received: from osv.localdomain ([89.175.180.246]) by smtp.gmail.com with ESMTPSA id q6-20020a056512210600b004a100c21eaesm512420lfr.97.2022.12.17.05.30.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 05:30:14 -0800 (PST) From: Sergey Organov To: Junio C Hamano Cc: Jeff King , Philip Oakley , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= , Alex Henrie , Jonathan Nieder , huang guanlong , Glen Choo , git@vger.kernel.org, Sergey Organov Subject: [PATCH v1 5/5] diff-merges: improve --diff-merges documentation Date: Sat, 17 Dec 2022 16:29:55 +0300 Message-Id: <20221217132955.108542-6-sorganov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221217132955.108542-1-sorganov@gmail.com> References: <20221217132955.108542-1-sorganov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org As we've now added a flag to --diff-merges, and so there are now flags and formats, document them as such. Another improvement is that now there is no extremely long line containg all the --diff-merges options. Signed-off-by: Sergey Organov --- Documentation/diff-options.txt | 114 ++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 52 deletions(-) diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index 977f9135b0d6..a3fbdb85a8b8 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -34,76 +34,86 @@ endif::git-diff[] endif::git-format-patch[] ifdef::git-log[] ---diff-merges=(off|none|on|first-parent|1|separate|m|combined|c|dense-combined|cc|remerge|r|[no-]hide):: +-m:: + Show diffs for merge commits in the default format. + Shortcut for '--diff-merges=on,hide' unless + `log.diffMerges-m-imply-p` configuration is active, in which + case it's a shortcut for '--diff-merges=on -p'. + +-c:: + Shortcut for '--diff-merges=combined -p'. + +--cc:: + Shortcut for '--diff-merges=dense-combined -p'. + +--remerge-diff:: + Shortcut for '--diff-merges=remerge -p'. + --no-diff-merges:: - Specify diff format to be used for merge commits. Default is + Synonym for '--diff-merges=off'. + +--diff-merges=(|)[,(|),...]:: + Specify diff format and flags to be used for merge commits. Default is {diff-merges-default} unless `--first-parent` is in use, in which case - `first-parent` is the default. Comma-separated list of - supported values is accepted as well. + `first-parent` is the default. + ---diff-merges=(off|none)::: ---no-diff-merges::: +The last format specified has precedence, whereas flags are +cumulative. Comma-separated list is handy to provide flag(s) along +with format, e.g.: `--diff-merges=first-parent,hide` is handy form of +`--diff-merges=first-parent --diff-merges=hide`. ++ +The following formats are supported: ++ +-- +off, none:: Disable output of diffs for merge commits. Useful to override implied value. + ---diff-merges=on::: ---diff-merges=m::: --m::: - These options make diff output for merge commits to be shown in - the default format. The default format could be changed using +on, m:: + Make diff output for merge commits to be shown in the default + format. The default format could be changed using `log.diffMerges` configuration parameter, which default value is `separate`. + - `-m` is a shortcut for '--diff-merges=on,hide'. - In addition it implies `-p` when `log.diffMerges-m-imply-p` is - active. +first-parent, 1:: + Show full diff with respect to first parent. This is the same + format as `--patch` produces for non-merge commits. + ---diff-merges=first-parent::: ---diff-merges=1::: - This option makes merge commits show the full diff with - respect to the first parent only. +separate:: + Show full diff with respect to each of parents. + Separate log entry and diff is generated for each parent. + ---diff-merges=separate::: - This makes merge commits show the full diff with respect to - each of the parents. Separate log entry and diff is generated - for each parent. -+ ---diff-merges=remerge::: ---diff-merges=r::: ---remerge-diff::: - With this option, two-parent merge commits are remerged to - create a temporary tree object -- potentially containing files - with conflict markers and such. A diff is then shown between - that temporary tree and the actual merge commit. +remerge, r:: + Remerge two-parent merge commits to create a temporary tree + object--potentially containing files with conflict markers + and such. A diff is then shown between that temporary tree + and the actual merge commit. + The output emitted when this option is used is subject to change, and so is its interaction with other options (unless explicitly documented). + ---diff-merges=combined::: ---diff-merges=c::: --c::: - With this option, diff output for a merge commit shows the - differences from each of the parents to the merge result - simultaneously instead of showing pairwise diff between a - parent and the result one at a time. Furthermore, it lists - only files which were modified from all parents. `-c` implies - `-p`. +combined, c:: + Show differences from each of the parents to the merge + result simultaneously instead of showing pairwise diff between + a parent and the result one at a time. Furthermore, it lists + only files which were modified from all parents. + ---diff-merges=dense-combined::: ---diff-merges=cc::: ---cc::: - With this option the output produced by - `--diff-merges=combined` is further compressed by omitting - uninteresting hunks whose contents in the parents have only - two variants and the merge result picks one of them without - modification. `--cc` implies `-p`. +dense-combined, cc:: + Further compress output produced by `--diff-merges=combined` + by omitting uninteresting hunks whose contents in the parents + have only two variants and the merge result picks one of them + without modification. +-- + ---diff-merges=hide::: ---diff-merges=no-hide::: - Hide (do not hide) the diff for merge commits unless `-p` options is given - as well. The default `no-hide` could be changed using `log.diffMerges` - configuration parameter. +The following flags are supported: ++ +-- +[no-]hide:: + Hide diff for merge commits unless `-p` options is given as + well. The default `no-hide` could be changed using + `log.diffMerges` configuration parameter. +-- --combined-all-paths:: This flag causes combined diffs (used for merge commits) to