summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2017-01-04 22:52:44 +0000
committerIan Jackson <ijackson@chiark.greenend.org.uk>2017-01-04 22:52:44 +0000
commit24f82efdfcec70f49f76624f25251fba47f1dc88 (patch)
tree1203abc4dfb91cb31a764d50a2096d8fc7b9d3bf
parent486009ca1b4db20fe788a8e14cc1c00477eef541 (diff)
badcommit-fixup wip
-rwxr-xr-xbadcommit-fixup42
1 files changed, 42 insertions, 0 deletions
diff --git a/badcommit-fixup b/badcommit-fixup
new file mode 100755
index 0000000..259775f
--- /dev/null
+++ b/badcommit-fixup
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+set -e
+set -o pipefail
+
+tmp=.git/dgit-badcommit-fixup-tmp
+rm -rf $tmp
+mkdir $tmp
+
+LC_MESSAGES=C git fsck --no-dangling 2>&1 | \
+ perl -ne 'print $1 if m/^error in commit d1a977e7f9637372750ac02a58e85c35ddd4ca54:.*invalid format - expected '\''committer' | \
+ >$tmp/bad
+
+case `wc -l <$tmp/bad` in
+ 0)
+ echo >&2 'nothing bad found - is git-fsck doing as we expect?' ;
+ exit 8 ;;
+ 1)
+ read <$tmp/bad bads
+ nots="^$onlybad^0 ^$onlybad^1"
+ ;;
+ *)
+ bads="cat $tmp/bad"
+ ;;
+esac
+
+args="$nots"
+
+for head in `git-show-ref --heads`; do
+ exec <$tmp/bad
+ needed=false
+ for bad in $bads; do
+ if git merge-base --is-ancestor $bad $head; then
+ needed=true
+ break
+ fi
+ done
+ if ! $needed; then continue; fi
+ args+=" $head"
+done
+
+echo $args