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

Git has two ways to count modified lines

From
LLLaurent Lyaudet <laurent.lyaudet@gmail.com>
Date
Mar 16, 2022, 18:08 UTC
Message-ID
<CAB1LBmvX4kv3yqSZ+X4Ozkb9esUem3U1JY48kWVi_Eef78Sk=Q@mail.gmail.com>
Hello,

I check the number of lines modified by my commits by hand, and today I had a surprising count :

1) I commit and get the following count
laurent@laurent-GL73-8SD:~/ReposGit/flow$ git commit
[master c068911] Task CU-21ph8h7 add buttons in PresenceList: "Tout
déplier", "Tout replier", for this the useState for showDetail
(boolean) in Presence is replaced by a useState for showDetails (Set
of ids) in PresenceList; correction missing tr between thead and ths
in PresenceList.
 2 files changed, 88 insertions(+), 48 deletions(-)
 rewrite src/apps/logs/components/PresenceList.js (61%)
2) I check the diff by hand, it doesn't match.
I check on github, it agrees with my manual count.
3) I try to get the same answer again in command-line.
laurent@laurent-GL73-8SD:~/ReposGit/flow$ git log -1 --shortstat
commit c068911547bddbf7bfc4ddc7a68ee8482421ed5c (HEAD -> master,
origin/master, origin/HEAD)
Author: Laurent Lyaudet <laurent.lyaudet@gmail.com>
Date:   Wed Mar 16 18:40:25 2022 +0100    Task CU-21ph8h7 add buttons
in PresenceList: "Tout déplier", "Tout replier",
    for this the useState for showDetail (boolean) in Presence is replaced
    by a useState for showDetails (Set of ids) in PresenceList;
    correction missing tr between thead and ths in PresenceList. 2
files changed, 71 insertions(+), 31 deletions(-)

How comes git has two ways to count modified lines ? How can I make git output again the same numbers than just after commit ? How can I check how it computed these numbers in the first place ?

Thanks, best regards,
    Laurent Lyaudet
Next: Laurent Lyaudet
Message 1 of 7 in “Git has two ways to count modified lines”
  1. Laurent LyaudetMar 16, 2022
  2. Laurent LyaudetApr 2, 2022
  3. René ScharfeApr 2, 2022
  4. Laurent LyaudetApr 5, 2022
  5. René ScharfeApr 4, 2022
  6. Ævar Arnfjörð BjarmasonApr 5, 2022
  7. René ScharfeApr 5, 2022

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.