Git patch sets
I needed to extract who did what on a project. The following script extracts a set of patches that have been contributed by the various authors. This result should resemble the exact same diff information of a ‘gitk –all‘.
#!/bin/sh
DEST=$1
PREV=""
( git log --reverse --pretty=format:"%ae %at %H" ; echo ) |
while read line
do
AUTHOR=`echo "$line" | awk '{print $1}'`
TIMESTAMP=`echo "$line" | awk '{print $2}'`
HASH=`echo "$line" | awk '{print $3}'`
mkdir -p $DEST/$AUTHOR
git diff $PREV $HASH > $DEST/$AUTHOR/patch-$TIMESTAMP-$HASH.diff
PREV=$HASH
done
Please let me know if there is an easier way to do this.



Well, you can save at least the three awk calls:
( git log –reverse –pretty=format:”%at %H %ae” ; echo )
I moved the author to the end, because I don’t know, if it can hold whitespaces, and then you pipe that to:
while read HASH TIMESTAMP AUTHOR ; do
mkdir -p …
git diff …
PREF=$HASH
done