From: Stefan Beller <sbeller@google.com>
To: Jonathan Tan <jonathantanmy@google.com>
Cc: git <git@vger.kernel.org>, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] xdiff/xpatience: support anchoring line(s)
Date: Wed, 22 Nov 2017 16:15:50 -0800 [thread overview]
Message-ID: <CAGZ79kYOovfAGNseAevsZOP2emxFCZfJpH=EJD5L0_vVnMZ-2Q@mail.gmail.com> (raw)
In-Reply-To: <20171122234152.72901-1-jonathantanmy@google.com>
On Wed, Nov 22, 2017 at 3:41 PM, Jonathan Tan <jonathantanmy@google.com> wrote:
> Teach the patience diff to attempt preventing user-specified lines from
> appearing as a deletion or addition in the end result. The end user can
> use this by specifying "--anchor=<text>" one or more times when using
> Git commands like "diff" and "show".
>
> Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
> ---
> Actual patch instead of RFC.
>
> 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.
Would it make sense to have `--anchor` imply patience?
(not necessarily in this patch, might be a "yes, let's do
it in a year when users complain")
> Replying to Stefan's and Junio's comments:
>
>> The solution you provide is a good thing to experiment with, but
>> longer term, I would want to have huge record of configs in which
>> humans selected the best diff, such that we can use that data
>> to reason about better automatic diff generation.
>> The diff heuristic was based on a lot of human generated data,
>> that was generated by Michael at the time. I wonder if we want to
>> permanently store the anchor so the data collection will happen
>> automatically over time.
>
> I think machine learning is beyond the scope of this patch :-)
agreed; I just wanted to share what I think we could do in the future
to select sane default. For that we'd want to collect some "most useful"
configurations.
When I proposed separate flags for the move detection regarding
ignoring whitespaces, the question "how is the user sanely select
from so many flags?" came up. And in that spirit I would want think
adding this rather fundamental flag, and then machine learn (e.g. the
weights in traversing the diff matrix) off of this collected data later
might be a viable approach.
>> or rather: "c is not moved, we don't care how the diff actually looks
>> like",
>> so maybe
>> ! grep "+c" diff
>
> I think it's less error-prone to show "a" moving. With this, if the
> command somehow prints nothing, the test would still pass.
Makes sense.
> diff --git a/t/t4033-diff-patience.sh b/t/t4033-diff-patience.sh
> index 113304dc5..2d00d1056 100755
> --- a/t/t4033-diff-patience.sh
> +++ b/t/t4033-diff-patience.sh
I was waiting for
test_expect_success 'one --anchor anchors many lines' '
printf "a\nb\na\nc\na\n" >file && # many 'a's
....
--anchor=a
...
Thanks for writing this patch,
I hope we can make use of this addition eventually a lot. :)
Stefan
next prev parent reply other threads:[~2017-11-23 0:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-21 22:17 [RFC PATCH] xdiff/xpatience: support anchoring a line Jonathan Tan
2017-11-21 23:28 ` Stefan Beller
2017-11-22 2:27 ` Junio C Hamano
2017-11-22 23:41 ` [PATCH] xdiff/xpatience: support anchoring line(s) Jonathan Tan
2017-11-23 0:15 ` Stefan Beller [this message]
2017-11-23 2:05 ` Junio C Hamano
2017-11-23 2:16 ` Junio C Hamano
2017-11-23 2:47 ` Junio C Hamano
2017-11-27 18:30 ` Jonathan Tan
2017-11-27 19:47 ` [PATCH v2] diff: " Jonathan Tan
2017-11-28 1:38 ` Junio C Hamano
2017-11-28 18:47 ` [PATCH v3] " Jonathan Tan
2017-11-30 0:36 ` Johannes Schindelin
2017-11-30 23:26 ` Jonathan Tan
2017-12-04 19:45 ` Stefan Beller
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='CAGZ79kYOovfAGNseAevsZOP2emxFCZfJpH=EJD5L0_vVnMZ-2Q@mail.gmail.com' \
--to=sbeller@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jonathantanmy@google.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).