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

Re: Lines missing from git diff-tree -p -c output?

From
Junio C Hamano <gitster@pobox.com>
Date
May 15, 2013, 17:48 UTC
Message-ID
<7v4ne4cexm.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20130515173312.GR25742@login.drsnuggles.stderr.nl>
Matthijs Kooijman <matthijs@stdin.nl> writes:
Show 12 quoted lines
> Hi Junio,
>
>> I think the coalescing of two adjacent hunks into one is painting
>> leading lines "interesting to show context but not worth showing
>> deletion before it" incorrectly.
> Yup, that seems to be the case.
>
>> Does this patch fix the issue?
>
> Yes, it fixes the issue. However, I think that this patch actually hides
> the real problem (in a way that will always work with the current code,
> though).

Could you explain why you think it hides the real problem, and what kind of future enhancement may break it?

This is *not* my usual rhetorical question "Please explain yourself, because I think you are wrong", but is "I do not understand the reasoning behind your statement, and I (and the reasoning behind my patch) must be missing something important, so please enlighten me by pointing out where I am wrong, so that I won't stick to my flawed patch".

The painting with no_pre_delete is applied when we extend the common context back to lines we _know_ otherwise not worth showing (because there is no difference) only because we want to show them as the context lines and we do not need to show deletions that come before these common context. By forcing (k == j + context) case, that is, there are exactly "context" number of lines between the end of the current hunk and the next hunk, which the old code would have showed "context" lines at the beginning of the next hunk, to go back to the "again" label, we are coalescing the two hunks that _should_ have been shown together anyway, without painting the context lines incorrectly with "before this line, do not show deletion" mark.

Show 11 quoted lines
> I had come up with a different fix myself (similar to the one I sent to
> the list as a followup, but that one still had a bug), which I think
> might be better. In any case, it includes a testcase for this bug which
> seems good to include.
>
> I'll send my patch as a followup in a minute, feel free to use it
> entirely or only partially.
>
> Gr.
>
> Matthijs
Previous: Matthijs KooijmanNext: Matthijs Kooijman
Message 6 of 8 in “Lines missing from git diff-tree -p -c output?”
  1. Matthijs KooijmanMay 15, 2013
  2. Matthijs KooijmanMay 15, 2013
  3. Junio C HamanoMay 15, 2013
  4. Matthijs KooijmanMay 15, 2013
  5. combine-diff.c: Fix output when changes are exactly 3 lines apartMatthijs Kooijman, May 15, 2013
  6. Junio C HamanoMay 15, 2013
  7. Matthijs KooijmanMay 15, 2013
  8. Junio C HamanoMay 15, 2013

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.