Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Gerrit show a different number of changes than git does?

Tags:

git

gerrit

This is the result of my latest commit / change in Git...

enter image description here

...and in Gerrit:

enter image description here

Is there any explanation for difference in number of lines added and deleted? Different algorithm?

like image 244
trejder Avatar asked Apr 24 '15 13:04

trejder


1 Answers

The actual changes are same. But the difference is due to how GIT and GERRIT computes the number of lines changed. Say you have 4 versions/changes/patchsets of the commit on top of HEAD.

commit_patchset#4
commit_patchset#3
commit_patchset#2
commit_patchset#1
HEAD

Git:
Number of lines changed for commit#4(A1): diff between commit_patchset#4 and commit_patch#3
Number of lines changed for commit#3(B1): diff between commit_patchset#3 and commit_patch#2
Number of lines changed for commit#2(C1): diff between commit_patchset#2 and commit_patch#1
Number of lines changed for commit#1(D1): diff between commit_patchset#1 and HEAD

Gerrit:
Number of lines changed for commit#4(A2): diff between commit_patchset#4 and BASE/HEAD
Number of lines changed for commit#3(B2): diff between commit_patchset#3 and BASE/HEAD
Number of lines changed for commit#2(C2): diff between commit_patchset#2 and BASE/HEAD
Number of lines changed for commit#1(D2): diff between commit_patchset#1 and BASE/HEAD

So always the number of lines changed will be different.

You can ask Gerrit to show the exact difference (as GIT shows) between patchset version instead of BASE/HEAD using ".." option.
For example,
http://your_gerrit_url/your_change_id/4..3 gives you the exact lines changed between commit_patchset#4 and commit_patchset#3. This should match the GIT calculations.

Hope it helps.

like image 180
CM_ Avatar answered Nov 15 '22 23:11

CM_