Skip to content

Instantly share code, notes, and snippets.

@milankarunarathne
Forked from xinan/git_extract_commits.sh
Last active September 9, 2015 18:14
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 milankarunarathne/fe87bc410fc5f51b46af to your computer and use it in GitHub Desktop.
Save milankarunarathne/fe87bc410fc5f51b46af to your computer and use it in GitHub Desktop.
This is a simple shell script to extract commits by a specified author in a git repository and format them as numbered patches. It is useful for GSoC code submission.
if ! [[ $# -eq 1 || $# -eq 2 || $# -eq 4 ]]; then
echo "Usage: $0 <author> [<start_date> <end_date>] [output_dir]"
echo "Example: $0 xinan@me.com 2015-05-25 2015-08-21 ./patches"
exit
fi
author=$1
if [ $# -gt 3 ]; then
output_dir=$4
elif [ $# -eq 2 ]; then
output_dir=$2
else
output_dir="./"
fi
if [ $# -gt 2 ]; then
start=$2
end=$3
else
start="2015-05-25"
end="2015-08-21"
fi
counter=0
for i in `git log --author=$author --since=$start --until=$end --pretty=oneline | sed 's/ .*//' | tail -r`
do
counter=$((counter+1))
git format-patch -M -C -1 --start-number $counter $i -o $output_dir
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment