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

Re: [PATCH] diff: add --ignore-blank-lines option

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 4, 2013, 20:46 UTC
Message-ID
<7v61xt7gej.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CALWbr2zJCxbW8Qug0i=oGvKZV5-vcAugextxMuQp9jaoaZYpyg@mail.gmail.com>
Antoine Pelisse <apelisse@gmail.com> writes:
Show 12 quoted lines
> On Tue, Jun 4, 2013 at 8:26 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Antoine Pelisse <apelisse@gmail.com> writes:
>>
>>> +xdchange_t *xdl_get_hunk(xdchange_t **xscr, xdemitconf_t const *xecfg) {
>>>       xdchange_t *xch, *xchp;
>>>       long max_common = 2 * xecfg->ctxlen + xecfg->interhunkctxlen;
>>> +     long ignorable_context = max_common / 2 - 1;
>>
>> Could you explain how this math works?
>
> I think it doesn't, mostly because I misinterpreted the "interhunkctxlen".
> I will try to think about that and provide a reroll.
OK.  Thanks.
I think the logic would be more like:
 1. Start from xscr, find the first xchp that is !xchp->ignore;
    if there is none, we are done. There is no more to show.
 2. Remember the xchp as the beginning.
 3. Tangle ->next pointer to find the next xch that is !xch->ignore;
    if there is none, we are also done.  xdchanges between the
    beginning you remembered in the step 2. and your current xchp
    are the only things we want to show.
 4. Measure the distance between the end of xchp and the beginning
    of xch.
    - If it is larger than max_common, xdchanges between the
      beginning you remembered in the step 2. and your current xchp
      are the only things we want to show.  The next iteration will
      start by skipping the blank-only changes between xchp and xch.
    - If it is short enough, assign xchp = xch and go back to 3. to
      find more interesting hunks (that is why we remembered the
      real "beginning" in step 2.).
Previous: Antoine PelisseNext: Antoine Pelisse
Message 7 of 26 in “diff: add --ignore-blank-lines option”
  1. diff: add --ignore-blank-lines optionAntoine Pelisse, May 26, 2013
  2. Johannes SixtMay 26, 2013
  3. Antoine PelisseMay 27, 2013
  4. Antoine PelisseJun 1, 2013
  5. Junio C HamanoJun 4, 2013
  6. Antoine PelisseJun 4, 2013
  7. Junio C HamanoJun 4, 2013
  8. Antoine PelisseJun 4, 2013
  9. diff: add --ignore-blank-lines optionAntoine Pelisse, Jun 8, 2013
  10. Eric SunshineJun 9, 2013
  11. Junio C HamanoJun 9, 2013
  12. Antoine PelisseJun 9, 2013
  13. Junio C HamanoJun 9, 2013
  14. Antoine PelisseJun 10, 2013
  15. Junio C HamanoJun 10, 2013
  16. Antoine PelisseJun 12, 2013
  17. Junio C HamanoJun 12, 2013
  18. diff: add --ignore-blank-lines optionAntoine Pelisse, Jun 15, 2013
  19. Junio C HamanoJun 17, 2013
  20. Antoine PelisseJun 17, 2013
  21. Antoine PelisseJun 17, 2013
  22. Junio C HamanoJun 17, 2013
  23. Antoine PelisseJun 17, 2013
  24. Junio C HamanoJun 17, 2013
  25. diff: add --ignore-blank-lines optionAntoine Pelisse, Jun 19, 2013
  26. Junio C HamanoJun 19, 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.