From: "René Scharfe" <l.s.r@web.de>
To: Laurent Lyaudet <laurent.lyaudet@gmail.com>, git@vger.kernel.org
Cc: "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: Sat, 2 Apr 2022 23:55:39 +0200 [thread overview]
Message-ID: <d650bb90-df94-eeab-0684-ee447e080ad6@web.de> (raw)
In-Reply-To: <CAB1LBms3F1EGswxF9mO=JrmWmj4XFncv4ZrkAy-dvOHdVrkwLQ@mail.gmail.com>
Am 02.04.22 um 18:49 schrieb Laurent Lyaudet:
> Le mer. 16 mars 2022 à 19:08, Laurent Lyaudet
> <laurent.lyaudet@gmail.com> a écrit :
>>
> I thought my email was sent to the right mailbox, at least it is what
> says this website :
> https://git-scm.com/community
Sure it was.
>> General questions or comments for the Git community can be sent to
>> the mailing list by using the email address git@vger.kernel.org.
> Moreover this website is cited in the README here :
> https://github.com/git/git/blob/master/README.md
>> Many Git online resources are accessible from https://git-scm.com/
>> including full documentation and Git related tools.
> Is there any problem with my questions explaining I got no answer,
> please ?
Not really, don't worry.
> I have found a partial explanation for the count differences :
>> 2 files changed, 88 insertions(+), 48 deletions(-)
>> rewrite src/apps/logs/components/PresenceList.js (61%)
> When committing, a file considered as "rewrite" is counted like m
> lines deleted and n lines added if it had m lines before and n lines
> after.
> Even if the diff is much smaller.
Git stores the file contents before and after your change. It doesn't
store any diff, but calculates them as needed, e.g. for the commit
confirmation message, or when you run git diff. So in that sense there
is no "the diff". The difference between two stored states can be
represented in many ways.
> Hence I answered my question :
>> How can I check how it computed these numbers in the first place ?
The option --break-rewrites controls rewrite detection. Check out its
description in the documentation of git diff to see how to use it.
> 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.
>> How can I make git output again the same numbers than just after commit ?
git show --stat --break-rewrites
But I have a question to the list as well: Why is break_opt (the
diff_options member for --break-rewrites) enabled for git commit by
default? I ask because the last commit that mentioned it, dc6b1d92ca
(wt-status: use settings from git_diff_ui_config, 2018-05-04), claimed
it would turn it off, if I read it correctly.
René
next prev parent reply other threads:[~2022-04-02 21:55 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 [this message]
[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
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=d650bb90-df94-eeab-0684-ee447e080ad6@web.de \
--to=l.s.r@web.de \
--cc=eckhard.s.maass@googlemail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=laurent.lyaudet@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).