4 ms·
I don't like OP's definition of divergence. I prefer to take the size of the diff along first-parent instead. Here's how I would do it: time git log -m --f
by gsylvie 10y ago
I don't like OP's definition of divergence. I prefer to take the size of the diff along first-parent instead.
Here's how I would do it:
time git log -m --first-parent --shortstat --pretty="%H" --min-parents=2 |
grep -v '^$\|3e1dd193edefd2a806a0ba6cf0879cf1a95217da' |
sed 's/.* file.* changed,//' |
sed 's/insertion.*,/+/' |
sed 's/deletion.*//' |
sed 's/insertion.*//' |
sed 's/^\ \(.*\)\ $/\$\(\(\1\)\)/' |
xargs -d '\n' -L 2 echo echo |
bash |
sort -k 2,2 -g
Note: I skip 3e1dd193edefd2a806a0ba6cf0879cf1a95217da because that commit has no diff along first-parent, and thus screws up my xargs result (which depends on every 2nd line having the --shortstat output).
Of course "--first-parent" doesn't guarantee that we're walking the mainline (see: https://developer.atlassian.com/blog/2016/04/stop-foxtrots-now/ https://developer.atlassian.com/blog/2016/04/stop-foxtrots-n... ), but it usually is.
On my laptop it takes 3 mins 30 seconds. Here are the 5 biggest merges by this definition:
099bfbfc7fbbe22356c02f0caf709ac32e1126ea 463702
3f17ea6dea8ba5668873afa54628a91aaa3fb1c0 466320
ce519e2327bff01d0eb54071e7044e6291a52aa6 500074
7ea61767e41e2baedd6a968d13f56026522e1207 504965
f063a0c0c995d010960efcc1b2ed14b99674f25c 569691
And here's "git show" for those 5:
099bfbfc7fbb 2015-06-26T13:18:51-07:00 Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux
3f17ea6dea8b 2014-06-08T11:31:16-07:00 Merge branch 'next' (accumulated 3.16 merge window patches) into master
ce519e2327bf 2009-01-06T17:04:29-08:00 Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6
7ea61767e41e 2009-09-16T08:11:54-07:00 Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6
f063a0c0c995 2010-10-28T12:13:00-07:00 Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6
- gsylvie 10y agoThis approach also helps with those orphan branches since it just calculates the diff caused by bringing the orphan branch into the mainline. Whereas OP's definition counts every line ever created on both sides (e.g., counts every line of code in the original project as well as the orphan at the moment of the merge).
- majewsky 10y agoIf you want the diff caused by bringing a topic branch into master (i.e. its unmerged parts), you can also do git diff master...topic with three dots instead of two.
- gsylvie 10y agoOr in this case (since we're processing merges one at a time to make the calculation): git diff COMMIT^1...COMMIT^2 (aka, parent1...parent2). I find the three-dot diff notation very useful, but confusing, and always have to type "git help diff" first and stare at the docs a bit to find this bit: "git diff A...B" is equivalent to "git diff $(git-merge-base A B) B" Also, I prefer first-parent since it gets the actual change to the mainline, whereas "git diff parent1...parent2" might miss some changes with dirty merges (e.g., conflict resolution). More info here: http://stackoverflow.com/a/41356308/5819286 http://stackoverflow.com/a/41356308/5819286