From b10a3228fdeb495a2f576e1678cb53d0c6358528 Mon Sep 17 00:00:00 2001 From: Josef 'Jeff' Sipek Date: Wed, 21 Feb 2007 12:44:24 -0500 Subject: [PATCH] Fixed do_make_header to include From: Insert "\nFrom: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>" right after the first line of the commit message. The GIT_AUTHOR_* vars are taken from the "author" line in the commit object. Signed-off-by: Josef 'Jeff' Sipek --- guilt | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/guilt b/guilt index 7b065c5..284f9fb 100755 --- a/guilt +++ b/guilt @@ -135,8 +135,28 @@ function get_series # usage: do_make_header function do_make_header { - # FIXME: store the author string as "From: " - git-cat-file -p $rev | awk 'BEGIN{ok=0}(ok==1){print $0}/^$/{ok=1}' + # which revision do we want to work with? + local rev=$1 + + # we should try to work with commit objects only + if [ `git-cat-file -t $rev` != "commit" ]; then + echo "Hash $rev is not a commit object" >&2 + echo "Aborting..." >&2 + exit 2 + fi + + # get the author line from the commit object + local author=`git-cat-file -p $rev | grep -e '^author ' | head -1` + + # strip the timestamp & '^author ' string + author=`echo $author | sed -e 's/^author //' -e 's/ [0-9]* [+-]*[0-9][0-9]*$//'` + + git-cat-file -p $rev | awk " +BEGIN{ok=0} +(ok==1){print \$0; print \"\nFrom: $author\"; ok=2; next} +(ok==2){print \$0} +/^\$/ && (ok==0){ok=1} +" } # usage: do_get_header patchfile -- 2.11.4.GIT