I\'d like a recipe for finding duplicated changes. patch-id is likely to be the same but the commit attributes may not be.
This seems to be an intended use of patch-
The nifty command suggested by bsb requires a couple of small tweaks:
(1) Instead of git show, which runs git diff-tree --cc, the command should use
git diff-tree -p
Otherwise git patch-id generates spurious null SHA1 hashes.
(2) When the pipe to xargs is used, xargs should have the -L 1 argument. Otherwise a triplicated commit will not be paired with an equivalent commit.
Here's an alias to go in ~/.gitconfig:
dup = "!f() { for c in $(git rev-list HEAD); do git diff-tree -p $c | git patch-id; done | perl -anle '($p,$c)=@F;print \"$c $s{$p}\" if $s{$p};$s{$p}=$c' | xargs -L 1 git show -s --oneline; }; f" # "git dup" lists duplicate commits