53

Git's pull output has been explained here fairly well. In spite of this I'm still unsure exactly what the text graph relates to.

For example:

git diff --stat master HEAD^

Outputs (truncated):

Site/index.php | 118 ++--

While the number of lines modified is clearly displayed as 118, the text graph is a little harder to interpret.

Could this relate to the ratio of added and removed lines?

1
  • 1
    118 ++-- indicates that a total of 118 changes were made. ++-- (2+, 2- , or approximately 50%,50%) shows that roughly 50% of these 118 changes were new lines (50% of 118 is 59 new lines) and roughly 50% of these 119 changes were lines removed. If it was, for example, 118 +++--, it would suggest that circa 60% of the changes were new lines (totaling 60% of 118 changes is 70 new line). Or, as last example, 118 ++++-, it would suggest that circa 80% of the 118 changes were new lines (totaling 80% of 118 changes is 94 new lines). Commented Dec 22, 2022 at 13:22

3 Answers 3

39

Yes it's the ratio of added and removed lines.

See also:

man diffstat 
Sign up to request clarification or add additional context in comments.

4 Comments

What is the scale? Is 100% the same for all file sizes?
Site/index.php | 118 ++-- means : roughly 50% removed 50% added on index.php. The ++-- indicator is not very precise.
Ahh, thank you. I was thrown off by a diffstat which was entirely pluses. I made the assumption that a ratio would have been displayed in its simplistic form.
Unfortunately, man diffstat doesn't work in Git Bash on Windows.
34
git diff --numstat "@{1 day ago}" 

Parameters:

  • diff = Show diff
  • --numstat = show the number of lines inserted and removed
  • @{1 day ago} = Period.

Output

0 1 WebContent/WEB-INF/tags/Grid.tag 38 30 ant/build.xml 
  • Column 1 (containing 0 38) = inserted
  • Column 2 (containing 1 30) = removed

PS: Columns are separated by tab (\t).

Comments

15

As I answered here:

It supposed to reflect the amount of changes (in lines) of each file listed.
Plus signs for additions, minuses for deletions.

The 118 gives the amount of changed lines, and the - / + gives you the proportion of deletions/additions.
When the amount of changes can fit a line you'll get '+' per addition, '-' per deletion;
Otherwise, this is an approximation, e.g.

CHANGES.txt | 47 +++++++++++++++++++++++++++++++++ make-release.py | 77 +++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 102 insertions(+), 22 deletions(-) 

On CHANGES.txt since you can see that there are no '-', and since 47 '+' are a lot you have a proportionate amount of them (i.e. 100%).
On make-release.py you'll see x39 '+' standing for 55 additions and x16 '-' standing for 22 deletions.
Exactly as their proportion, and just the amount to fit output screen.

The amount of signs per line the a GCD multiple that fits the line width.

Hope that helps.

2 Comments

I know it has been a bit but do you have any idea why one might not show the total when there is room? I have a line that shows | 3 - but I also have a line that shows | 55 +++---- so there is room for three -s but it only showed 1
It looks like if all the changes in the diff can fit at 1:1 scale, they will be printed at 1:1. But if any file's amount of changes is too long for the line, all of them will be scaled proportionately.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.