#!/bin/sh
blurb="${1-cherry}"
git status --short \
    | sed '/^ M /!d;s///' \
    | while read filename
do
    printf '\nprocessing: %s\n' $filename
    n=0
    while [ "$(git status --short -- $filename)" ]
    do
        n=$(expr 1 + $n)
        printf 'y\nq\n' | git add --patch $filename >/dev/null
        printf '%5d -- ' $n
        git commit -m"$n $filename ($blurb)" \
            | sed '1d;s/.* changed, //;s/[^0-9,]//g;s/,/& /'
    done
done
