Re: [PATCH] xdiff/xpatience: support anchoring line(s)
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 23, 2017, 02:16 UTC
- Message-ID
- <xmqq3755sprp.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <xmqqa7zdsqb6.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 7 quoted lines
> Jonathan Tan <jonathantanmy@google.com> writes: > >> One thing that might help is to warn if --anchor is used without >> --patience, but I couldn't find a good place to put that warning. Let me >> know if you know of a good place. > > How about dropping --anchor option and do it as "--patience=<pattern>"?
Well, that may not be an optimal suggestion, as it is always a pain to have to deal with an option with optional argument.
I understand that the case you would really want to warn against is
git diff --histogram --anchor=foo
and not
git diff --anchor=foo
as it is sensible to turn --patience on implicitly. Perhaps a good starting point might be to rename the option to include "patience" somewhere in its name ("--patience-anchor=<pattern>"?) to make it more obvious that it is about helping the patience algorithm. And then make "--patience-anchor=<pattern>" without any other algorithm selection option to behave as if "--patience" was also given.
What do we do when
git diff --histogram --patience
is given? Do we warn? If we don't, perhaps it may not be too bad if
git diff --histogram --patience-anchor=foo
git diff --patience-anchor=foo --histogramdid not get any warning. Instead we just implicitly turn any occurence of --patience-anchor=foo into --patience followed by the same option, and assume that the user wanted the usual "last one wins" semantics. It would turn patience on for the former, and ignore the anchor for the latter and use historgram.