Last active
October 16, 2015 04:10
-
-
Save xinan/42669b49153af52919b2 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ! [[ $# -eq 1 || $# -eq 2 || $# -eq 4 ]]; then | |
echo "Usage: $0 <author> [<start_date> <end_date>] [output_dir]" | |
echo "Example: $0 [email protected] 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 |
@haaHh Thanks for the info! I didn't know that. Learnt something ๐
my author name had spaces so that was an issue, fixed with double quotes on author attribute in 'git log'
@yousefhamza Oh I did not consider that ๐ You can always use email address as author by the way.
@xinan Thanks for this. Very helpful!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this script.
tail -r
works only on BSD, for GNU/Linuxtac
can be used instead.