All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Lyaudet <laurent.lyaudet@gmail.com>
To: "René Scharfe" <l.s.r@web.de>
Cc: git@vger.kernel.org, "Junio C Hamano" <gitster@pobox.com>,
	"Eckhard S. Maaß" <eckhard.s.maass@googlemail.com>,
	"Elijah Newren" <newren@gmail.com>
Subject: Re: Git has two ways to count modified lines
Date: Tue, 5 Apr 2022 17:57:48 +0200	[thread overview]
Message-ID: <CAB1LBms-Urzbx=Q=9Ydvsrgx=6si+FwZa09MEz9zCHRser8iuw@mail.gmail.com> (raw)
In-Reply-To: <d650bb90-df94-eeab-0684-ee447e080ad6@web.de>

Le sam. 2 avr. 2022 à 23:55, René Scharfe <l.s.r@web.de> a écrit :
>
> Am 02.04.22 um 18:49 schrieb Laurent Lyaudet:
> > Le mer. 16 mars 2022 à 19:08, Laurent Lyaudet
> The option --break-rewrites controls rewrite detection.  Check out its
> description in the documentation of git diff to see how to use it.
Hello everyone,
Thanks René, I checked and now I understand how it works :)
> > But the two other questions remains :
> >> How comes git has two ways to count modified lines ?
> > i.e. What is (was) the purpose of this rewrite counting (when coded) ?
>
> Rewrite detection is meant to improve the diff of a file whose content
> was replaced with something very different.  Instead of lots of hunks
> containing lines that add and remove unrelated stuff, separated by empty
> lines etc. that the diff algorithm matches between the sides even though
> they are also unrelated, a rewrite diff removes all the old lines en
> bloc and then adds all the new ones, which is easier to read in that
> case.
It makes sense to produce diffs simpler to understand.
From my experience, humans are better than computers at knowing when
to "break-rewrites" (or see that a line was moved, etc.) .
I have dreamed about hinting the diff tools for many years,
but I'm more used to simply accept what the computer produces as its
diff(s) and have my own analysis that does not match.
Maybe for git 10.0, someone will add metadata in commits for human
optimized diffs :)
For applying patches, it is useless but for understanding code change, it helps.
At least, it is a good mental exercise.
Just in case, if someone cares, in my notebook I note the following counts :
- non empty and not space only created lines
- empty or space only created lines
- modified lines (non space created or deleted character)
- space modified lines (but I should split this category between space
presentation, and space bug related (Yes you can correct bug by
changing only spaces, most of the time in strings)
- moved lines :
   - as is
   - with space modification
   - with non-space modification
- non empty and not space only deleted lines
- empty or space only deleted lines

> >> How can I make git output again the same numbers than just after commit ?
>
> git show --stat --break-rewrites
Thanks :)

Best regards,
    Laurent Lyaudet

      parent reply	other threads:[~2022-04-05 21:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-16 18:08 Git has two ways to count modified lines Laurent Lyaudet
2022-04-02 16:49 ` Laurent Lyaudet
2022-04-02 21:55   ` René Scharfe
     [not found]     ` <xmqqh779u72a.fsf@gitster.g>
2022-04-04 21:08       ` René Scharfe
2022-04-05  1:58         ` Ævar Arnfjörð Bjarmason
2022-04-05 15:57           ` René Scharfe
2022-04-05 15:57     ` Laurent Lyaudet [this message]

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='CAB1LBms-Urzbx=Q=9Ydvsrgx=6si+FwZa09MEz9zCHRser8iuw@mail.gmail.com' \
    --to=laurent.lyaudet@gmail.com \
    --cc=eckhard.s.maass@googlemail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=l.s.r@web.de \
    --cc=newren@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.