chiark / gitweb /
259775f510984c5c652b377905b3238e03f6ddd1
[dgit.git] / badcommit-fixup
1 #!/bin/bash
2
3 set -e
4 set -o pipefail
5
6 tmp=.git/dgit-badcommit-fixup-tmp
7 rm -rf $tmp
8 mkdir $tmp
9
10 LC_MESSAGES=C git fsck --no-dangling 2>&1 | \
11  perl -ne 'print $1 if m/^error in commit d1a977e7f9637372750ac02a58e85c35ddd4ca54:.*invalid format - expected '\''committer' | \
12  >$tmp/bad
13
14 case `wc -l <$tmp/bad` in
15     0)
16         echo >&2 'nothing bad found - is git-fsck doing as we expect?' ;
17         exit 8 ;;
18     1)
19         read <$tmp/bad bads
20         nots="^$onlybad^0 ^$onlybad^1"
21         ;;
22     *)
23         bads="cat $tmp/bad"
24         ;;
25 esac
26
27 args="$nots"
28
29 for head in `git-show-ref --heads`; do
30     exec <$tmp/bad
31     needed=false
32     for bad in $bads; do
33         if git merge-base --is-ancestor $bad $head; then
34             needed=true
35             break
36         fi
37     done 
38     if ! $needed; then continue; fi
39     args+=" $head"
40 done
41
42 echo $args