set -x
i=0
while true ; do
	if git rev-parse fix-$i >/dev/null 2>&1 ; then
		if git merge-base --is-ancestor fix-$i @ ; then
			reset=@
			break
		else
			if git cherry-pick fix-$i ; then
				reset=@^
				break
			else
				git cherry-pick --abort
				i=$((i+1))
			fi
		fi
	else
		bash -i
	fi
done
rm -f ~/status
xterm -hold -e sh -i -c 'cd ; ~/devel/vcs/myrepos/mr -j2 status ; printf %s $? > ~/status'
ret=$(cat ~/status)
rm -f ~/status
git reset --hard "$reset"
# mr exits 2 on user interrupts, so it was good
if [ "$ret" -eq 2 ] ; then exit 0 ; fi

# mr exits 1 when it gets a SIGWINCH, so it was bad
if [ "$ret" -eq 1 ] ; then exit 1 ; fi

# No idea, skip commit
exit 125
