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

Re: Bug: git log --numstat counts wrong

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 23, 2011, 19:23 UTC
Message-ID
<7vwrczt64j.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CALUzUxoujys1eWL6i6YJmFZZakcQx8oa8ZbRjixUzANB1Hpb3Q@mail.gmail.com>
Tay Ray Chuan <rctay89@gmail.com> writes:
> On further thought, I think the patch merely side-steps the problem -
> ie. that -U0 generates "incorrect" diffs.
I do not know if there anything "incorrect" about it.

When the file have common blocks lines in different places that are not modified, the comparison between preimage and postimage is free to choose how these common blocks are matched, and for that reason it is incorrect to expect that "diff -U0", "diff -U3" and "diff -U20" would produce the identical results.

> I think this function is incorrect. xdl_cleanup_records() and
> xdl_clean_mmatch() may potentially look into common tail lines, so it
> may not be "safe" to drop all common tail lines.

I would prefer to keep that common trimming optimization, and also to see the same common trimming logic extended to trim (and adjust offsets) at the beginning as well in the longer term. If xdl_cleanup_records() and xdl_clean_mmatch() need to become aware of the change in the total number of lines made by trim_common_tail(), please make it so.

Show 16 quoted lines
>
> -- >8 --
> diff --git a/xdiff-interface.c b/xdiff-interface.c
> index 0e2c169..da4fab6 100644
> --- a/xdiff-interface.c
> +++ b/xdiff-interface.c
> @@ -131,7 +131,7 @@
>         mmfile_t a = *mf1;
>         mmfile_t b = *mf2;
>
> -       trim_common_tail(&a, &b, xecfg->ctxlen);
> +/*     trim_common_tail(&a, &b, xecfg->ctxlen);  */
>
>         return xdl_diff(&a, &b, xpp, xecfg, xecb);
>  }
> -- >8 --
Previous: Tay Ray ChuanNext: Alexander Pepper
Message 15 of 16 in “Bug: git log --numstat counts wrong”
  1. Alexander PepperSep 21, 2011
  2. Junio C HamanoSep 21, 2011
  3. Alexander PepperSep 21, 2011
  4. Alexander PepperSep 21, 2011
  5. Junio C HamanoSep 21, 2011
  6. Alexander PepperSep 22, 2011
  7. Junio C HamanoSep 22, 2011
  8. René ScharfeSep 22, 2011
  9. Tay Ray ChuanSep 23, 2011
  10. Revert removal of multi-match discard heuristic in 27af01Tay Ray Chuan, Sep 25, 2011
  11. René ScharfeSep 25, 2011
  12. Junio C HamanoSep 22, 2011
  13. Tay Ray ChuanSep 23, 2011
  14. Tay Ray ChuanSep 23, 2011
  15. Junio C HamanoSep 23, 2011
  16. Alexander PepperSep 23, 2011

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.