From: Sergey Organov <sorganov@gmail.com>
To: Elijah Newren <newren@gmail.com>
Cc: "Junio C Hamano" <gitster@pobox.com>, "Jeff King" <peff@peff.net>,
"Philip Oakley" <philipoakley@iee.email>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Alex Henrie" <alexhenrie24@gmail.com>,
"Jonathan Nieder" <jrnieder@gmail.com>,
"huang guanlong" <gl041188@gmail.com>,
git@vger.kernel.org
Subject: Re: [PATCH 3/5] diff-merges: implement log.diffMergesForce config
Date: Wed, 30 Nov 2022 15:58:30 +0300 [thread overview]
Message-ID: <87zgc8tx8p.fsf@osv.gnss.ru> (raw)
In-Reply-To: CABPp-BFHQ8KwNK=FKGc96iQYqr9xT--WH7kg5R-CzCaAiWiRZg@mail.gmail.com
Elijah Newren <newren@gmail.com> writes:
> On Sun, Nov 27, 2022 at 1:37 AM Sergey Organov <sorganov@gmail.com> wrote:
>>
>> Force specified log format for -c, --cc, and --remerge-diff options
>> instead of their respective formats. The override is useful when some
>> external tool hard-codes diff for merges format option.
>>
>> Using any of the above options twice or more will get back the
>> original meaning of the option no matter what configuration says.
>>
>> Signed-off-by: Sergey Organov <sorganov@gmail.com>
>> ---
>> Documentation/config/log.txt | 11 +++++++++++
>> builtin/log.c | 2 ++
>> diff-merges.c | 32 ++++++++++++++++++++++++++------
>> diff-merges.h | 2 ++
>> t/t4013-diff-various.sh | 18 ++++++++++++++++++
>> t/t9902-completion.sh | 3 +++
>> 6 files changed, 62 insertions(+), 6 deletions(-)
>>
>> diff --git a/Documentation/config/log.txt b/Documentation/config/log.txt
>> index 265a57312e58..7452c7fad638 100644
>> --- a/Documentation/config/log.txt
>> +++ b/Documentation/config/log.txt
>> @@ -43,6 +43,17 @@ log.diffMergesHide::
>> log.diffMerges-m-imply-p::
>> `true` enables implication of `-p` by `-m`.
>>
>> +log.diffMergesForce::
>> + Use specified log format for -c, --cc, and --remerge-diff
>> + options instead of their respective formats when the option
>> + appears on the command line one time. See `--diff-merges` in
>> + linkgit:git-log[1] for allowed values. Using 'off' or 'none'
>> + disables the override (default).
>> ++
>> +The override is useful when external tool hard-codes one of the above
>> +options. Using any of these options two (or more) times will get back
>> +the original meaning of the options.
>
> I didn't quite understand your intent here from this explanation.
> When you pointed out to Junio that you wanted to override magit's
> hard-coded `git log --cc` and turn it into `git log -m -p`, then it
> suddenly made more sense. And the two or more times I guess is your
> escape hatch to allow users to say "I *really* do want this other
> format, so `git log --cc --cc` will get it for me.".
>
> Maybe something like:
>
> Override -c, --cc, --remerge-diff options and use the specified
> diff-generation scheme for merges instead. However, this config
> setting can in turn be overridden by specifying an alternate option
> multiple times (e.g. `git log --cc --cc`). Overriding the
> diff-generation scheme for merges can be useful when an external tool
> has a hard-coded command line it calls such as `git log --cc`. See
> `--diff-merges` in linkgit:git-log[1] for allowed values. Using 'off'
> or 'none' disables the override (default).
Thanks for suggestion, I'll take this into consideration should we agree
to actually let this feature in.
>
> However:
> * This feels like we're trying to workaround bugs or inflexibility
> in other tools with code in Git. This feels like a slippery slope
> issue and/or fixing the wrong tool.
Yep, that's why I said in my another answer to Junio that I won't insist
on it if you guys object, even though it does look useful for me.
> * Why is this just for -c, --cc, and --remerge-diff, and not for
> also overriding -m? It seems odd that one would be left out,
> especially since tools are more likely to have hard-coded it than
> --remerge-diff, given that -m has been around for a long time and
> --remerge-diff is new.
'-m' is rather the first one that got an override support, see
'log.diffMerges'.
[As for --remerge-diff, as a side note, I'd call it something like --rd
for short, as we have --diff-merges=remerge anyway. And then I'll think
about adding --pd (pure-diff) or --fpd (first-parent-diff) ;-)]
>
>> +
>> log.follow::
>> If `true`, `git log` will act as if the `--follow` option was used when
>> a single <path> is given. This has the same limitations as `--follow`,
> [...]
>> diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
>> index 1789dd6063c5..8a90d2dac360 100755
>> --- a/t/t4013-diff-various.sh
>> +++ b/t/t4013-diff-various.sh
>> @@ -557,6 +557,24 @@ test_expect_success 'git config log.diffMerges-m-imply-p has proper effect' '
>> test_cmp expected actual
>> '
>>
>> +test_expect_success 'git config log.diffMergesForce has proper effect' '
>> + git log -m -p master >result &&
>> + process_diffs result >expected &&
>> + test_config log.diffMergesForce on &&
>
> I think the default for `on` is bad; it made sense at the time, but I
> think we have a better option now.
We probably disagree about what a better option actually is, but the
point is valid anyway.
> Perhaps we switch to it, perhaps we don't, but if there's _any_ chance
> at all we change the default for "on" (which I think there definitely
> is), then you should really use the option that matches the actual
> mode you are using rather than a synonym for it; doing so
> future-proofs this testcase.
Yep, agreed. Thanks for the catch!
>
>> + git log --cc master >result &&
>> + process_diffs result >actual &&
>> + test_cmp expected actual
>> +'
>> +
>> +test_expect_success 'git config log.diffMergesForce override by duplicate' '
>> + git log --cc master >result &&
>> + process_diffs result >expected &&
>> + test_config log.diffMergesForce on &&
>
> Matters less here, but just in case "--cc" were to become the default,
> it'd be nice to explicitly use something else like separate here.
Yes, thanks!
>
>> + git log --cc --cc master >result &&
>> + process_diffs result >actual &&
>> + test_cmp expected actual
>> +'
-- Sergey Organov
next prev parent reply other threads:[~2022-11-30 12:58 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-27 9:37 [PATCH 0/5] diff-merges: more features Sergey Organov
2022-11-27 9:37 ` [PATCH 1/5] diff-merges: implement [no-]hide option and log.diffMergesHide config Sergey Organov
2022-12-08 0:06 ` Glen Choo
2022-12-08 18:13 ` Sergey Organov
2022-11-27 9:37 ` [PATCH 2/5] diff-merges: implement log.diffMerges-m-imply-p config Sergey Organov
2022-11-27 9:37 ` [PATCH 3/5] diff-merges: implement log.diffMergesForce config Sergey Organov
2022-11-28 2:35 ` Junio C Hamano
2022-11-28 14:44 ` Sergey Organov
2022-11-29 15:30 ` Junio C Hamano
2022-11-29 17:59 ` Ævar Arnfjörð Bjarmason
2022-11-30 13:01 ` Sergey Organov
2022-11-30 13:28 ` Junio C Hamano
2022-11-29 18:48 ` Jeff King
2022-11-30 13:02 ` Sergey Organov
2022-11-29 5:10 ` Elijah Newren
2022-11-30 12:58 ` Sergey Organov [this message]
2022-11-27 9:37 ` [PATCH 4/5] diff-merges: support list of values for --diff-merges Sergey Organov
2022-11-27 9:37 ` [PATCH 5/5] diff-merges: issue warning on lone '-m' option Sergey Organov
2022-11-28 7:51 ` [PATCH 0/5] diff-merges: more features Junio C Hamano
2022-11-28 14:42 ` Sergey Organov
2022-11-29 4:50 ` Elijah Newren
2022-11-30 13:16 ` Sergey Organov
2022-12-01 2:21 ` Elijah Newren
2022-12-01 9:36 ` Sergey Organov
2022-12-07 23:55 ` Glen Choo
2022-12-08 14:29 ` Sergey Organov
2022-12-08 23:05 ` Glen Choo
2022-12-10 20:45 ` Sergey Organov
2022-12-08 23:06 ` Glen Choo
2022-12-08 16:18 ` Sergey Organov
2022-12-17 13:29 ` [PATCH v1 0/5] diff-merges: more features to fix '-m' Sergey Organov
2022-12-17 13:29 ` [PATCH v1 1/5] diff-merges: implement [no-]hide option and log.diffMergesHide config Sergey Organov
2022-12-17 13:29 ` [PATCH v1 2/5] diff-merges: implement log.diffMerges-m-imply-p config Sergey Organov
2022-12-17 13:29 ` [PATCH v1 3/5] diff-merges: support list of values for --diff-merges Sergey Organov
2022-12-17 13:29 ` [PATCH v1 4/5] diff-merges: issue warning on lone '-m' option Sergey Organov
2022-12-17 13:29 ` [PATCH v1 5/5] diff-merges: improve --diff-merges documentation Sergey Organov
2022-12-18 3:10 ` [PATCH v1 0/5] diff-merges: more features to fix '-m' Junio C Hamano
2022-12-19 14:22 ` Sergey Organov
2022-12-19 14:29 ` Sergey Organov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zgc8tx8p.fsf@osv.gnss.ru \
--to=sorganov@gmail.com \
--cc=alexhenrie24@gmail.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=gl041188@gmail.com \
--cc=jrnieder@gmail.com \
--cc=newren@gmail.com \
--cc=peff@peff.net \
--cc=philipoakley@iee.email \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.