what does "insertions and deletions" mean and how the numbers are calculated

1.3k Views Asked by At

when use diffStat or git diff to analyze the code,it often shows the result below,

71 files changed, 10938 insertions(+), 947 deletions(-), 3103 modifications(!), 3027 unchanged lines(=) but I do not know what the insertions and deletions mean?

  • does it mean the increased or deleted line count?

  • How those insertions/deletion numbers are calculated ?

2

There are 2 best solutions below

0
VonC On BEST ANSWER

You can see that message printed in diff.c#print_stat_summary()

Those numbers are computed in diff.c#show_stats(), where the numbers of lines added or deleted are tallied.

The actual computation for a given place is in diff.c#builtin_diffstat (which calls diff.c#diff_populate_filespec() if one of the files is a binary).

1
ElpieKay On

If you add a new line, it's 1 insertion. If you delete a line, it's 1 deletion. If you modify one line, it's 1 deletion and 1 insertion.