Reputation: 10504
Through use of an import tool I have ended up with some git commits that have no author. For example here is a git log output showing an authorless commit and a normal commit
commit 40c2638378b33ac98a8d9570552ecd01e38174be
Merge: c2c068f 8f0c30c
Merge libde265 (1.0.2-2) import into refs/heads/workingbranch
commit c2c068f30652fd3e63b55c509ae50828c98daa22
Author: Debian Multimedia Maintainers <[email protected]>
Date: Mon Jan 11 18:12:19 2016 +0000
ffmpeg_2.9
Gbp-Pq: Name ffmpeg_2.9.patch
github will not accept these commits. So I need to fix them up, to do that I need to find them.
How can I find such commits so that I can fix them?
Upvotes: 2
Views: 535
Reputation: 10504
Well I found a soloution but it's a bit hacky.
git log > log1
git log --author "" > log2
diff -u log1 log2
For posterity the complete find and fix script (thanks to https://stackoverflow.com/a/28845565/5083516 for some hints on the fixup side)
#!/bin/bash -ev
rm -f loggood
rm -f logall
for TAG in $(git tag) ; do
git log --pretty=format:"%H" --author="" $TAG >> loggood
#git log doesn't seem to add a final newline, add one ourselves
echo >> loggood
git log --pretty=format:"%H" $TAG >> logall
echo >> logall
done
LC_ALL=C cat loggood | sort | uniq | sponge loggood
LC_ALL=C cat logall | sort | uniq | sponge logall
LC_ALL=C comm -13 loggood logall > logbad
for COMMIT in $(cat logbad) ; do
git checkout $COMMIT
git commit --amend --reset-author --no-edit
git replace $COMMIT $(git log --pretty=format:"%H" -n 1)
done
git filter-branch -f -- --all
for COMMIT in $(cat logbad) ; do
git replace -d $COMMIT
done
Upvotes: 1