This is the result of my latest commit / change in Git...
...and in Gerrit:
Is there any explanation for difference in number of lines added and deleted? Different algorithm?
This is the result of my latest commit / change in Git...
...and in Gerrit:
Is there any explanation for difference in number of lines added and deleted? Different algorithm?
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.
If you have pushed multiple times then it's because your reference version is against something other than the base commit in the change.
Each git commits points to an entire git tree snapshot (which makes checkouting or diffing any revision very fast and quite constant time). Git does not store patches internally, they are computed on-demand when required like when commit stats are computed.
git diff
is the main command to compute them, and it handles several diff algorithms (see --diff-algorithm
at least). Also git configuration can set specific default diff behaviors (see diff.dirstat
and diff.algorithm
configs).
If both tools/machines computes diff stats with different diff settings then you might get different stats at the end. (I don't know if this is the case)
© 2022 - 2024 — McMap. All rights reserved.
Gerrit
usesjgit
. There is ajgit
binary available. Try runningjgit show
on your commit and check if diffs produced byjgit
andgit
are different. I remember I encountered a similar situation. – Educateegit status
+git add -A
+git commit -m ""
+git push
. I don't know, if this is the only situation, that I found by pure accident or if differences are after every commit / push. I don't have access to company intranet for next three days, so I can't verify this further. – Reclusion