Skip to content

Instantly share code, notes, and snippets.

@econchick
Forked from encukou/getpatch.sh
Created November 13, 2012 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save econchick/4064821 to your computer and use it in GitHub Desktop.
Save econchick/4064821 to your computer and use it in GitHub Desktop.
get patches from remote repo, name them according to freeipa guidelines
#! /bin/bash
export project=freeipa
export username=pviktori
export localrepo=~/dev/freeipa
export patchdir=~/patches/in
export remote=vm081
# Usage: getpatch <patchnumber> [num_patches]
#
# Fetch the HEAD from $remote, then format the last <num_patches> patches
# (default: 1), numbering them from <patchnumber>, and store them in $patchdir.
# If the $patchdir is empty, also generates a cover letter
export patchnumber=$1
shift
export numpatches=$1
shift
if [ "$patchnumber" == "" ]; then
echo Need to specify patch number
exit
fi
rm $patchdir/$project-$username-0000-cover-letter.patch
if ls $patchdir/* > /dev/null; then
COVER=''
echo 'clean the destination directory to generate cover letter'
else
COVER='--cover-letter'
fi
set -x
export patchnumber=`printf "%04d" $patchnumber`
export opts="-M3 -C -N -B --patience --minimal --full-index $COVER --inter-hunk-context=3"
cd $localrepo
git fetch $remote HEAD
patchnames=$(git format-patch $opts FETCH_HEAD~$numpatches..FETCH_HEAD --start-number $patchnumber $@)
for patchname in $patchnames; do
mv $patchname $patchdir/$project-$username-$patchname
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment