git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] xdiff/xpatience: support anchoring line(s)

From
Stefan Beller <sbeller@google.com>
Date
Nov 23, 2017, 00:15 UTC
Message-ID
<CAGZ79kYOovfAGNseAevsZOP2emxFCZfJpH=EJD5L0_vVnMZ-2Q@mail.gmail.com>
In-Reply-To
<20171122234152.72901-1-jonathantanmy@google.com>
On Wed, Nov 22, 2017 at 3:41 PM, Jonathan Tan <jonathantanmy@google.com> wrote:
Show 12 quoted lines
> 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")

Show 12 quoted lines
> 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.

Show 7 quoted lines
>> 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
Previous: Jonathan TanNext: Junio C Hamano
Message 5 of 15 in “xdiff/xpatience: support anchoring a line”
  1. xdiff/xpatience: support anchoring a lineJonathan Tan, Nov 21, 2017
  2. Stefan BellerNov 21, 2017
  3. Junio C HamanoNov 22, 2017
  4. xdiff/xpatience: support anchoring line(s)Jonathan Tan, Nov 22, 2017
  5. Stefan BellerNov 23, 2017
  6. Junio C HamanoNov 23, 2017
  7. Junio C HamanoNov 23, 2017
  8. Junio C HamanoNov 23, 2017
  9. Jonathan TanNov 27, 2017
  10. diff: support anchoring line(s)Jonathan Tan, Nov 27, 2017
  11. Junio C HamanoNov 28, 2017
  12. diff: support anchoring line(s)Jonathan Tan, Nov 28, 2017
  13. Johannes SchindelinNov 30, 2017
  14. Jonathan TanNov 30, 2017
  15. Stefan BellerDec 4, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.