Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 51 lines (41 sloc) 1.05 KB
#!/bin/bash
#
# Create a patch set, save it in patches/patches-<date>-<baseref>
# Points patches/latest to the last created directory, so it's easy to
# git-send-email from there
readonly pre_patchset_hook=.git/hooks/pre-patch-set
readonly post_patchset_hook=.git/hooks/post-patch-set
git rev-list $@ > /dev/null
if [ $? -ne 0 ]; then
echo "Failed to look up refs"
exit 1
fi
# git rev-list will take care of searching for the git-repo
# so if we get here, we know we're inside a git repo.
while ! [ -e ".git" ]; do
cd ..
done
readonly revs="${@/\//:}"
readonly date=`date +%Y%m%d%H%M`
readonly basedir=patches
readonly dir="patches-$date-$revs"
readonly tmplink="$basedir/latest"
readonly odir="$basedir/$dir"
if [ -e "$odir" ]; then
echo "Directory $dir already exists. Oops."
exit 1
fi
if [ -x "$pre_patchset_hook" ]; then
set -e
./$pre_patchset_hook
set +e
fi
mkdir -p "$odir"
rm -f $tmplink
ln -sf $dir $tmplink
git format-patch -n -o $odir $@
if [ -x "$post_patchset_hook" ]; then
set -e
./$post_patchset_hook
set +e
fi