Git: what does the number of +/- signs in diff / merge output mean? [duplicate]

别说谁变了你拦得住时间么 提交于 2019-12-17 22:57:11

问题


Possible Duplicate:
Git Merge: What does this mean?
Git diff --stat explanation

Sorry for the stupid question, but i can't find a clear answer anywhere.

When you merge two branches in git, you get an output like that :

 some_file.txt  |  564 ++++++++++++++--

I undestand that + and - mean addition and deletion, but :

  • what does the number of signs represent ? when you have few changes, each sign seem to represent a line, but when you have more signs, i can't get the logic of the representation

  • is it some sort of percentage of changes ? My guess is that the number of signs represents a relative amount of changes - but relative to what ? current file ? the whole merge ?

  • how is it calculated ? Is there any official source about this ? The most accurate answer i had on this by now is "this representation is not very precise"... i'm just curious


回答1:


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

EDIT:
the 564 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.

Hope that helps.



来源:https://stackoverflow.com/questions/13761376/git-what-does-the-number-of-signs-in-diff-merge-output-mean

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!