Skip to content

Commit

Permalink
[PATCH] guilt: fix "from: xxx" filtering in the patch description
Browse files Browse the repository at this point in the history
Commit 2cc8d35 ([PATCH] guilt: improve patch header handling) caused
a regression with patch header handling.  When using a hand written
patch description in the format:

> Frobnozzle: this is a patch subject
>
> From: Fred McNurk <[email protected]>

the old code filtered the From: line out of the git commit
description, while the new code leaves it in there. The result is
that when using guilt patchbomb, the From line is emitted twice in
the email that is sent - once from the author of the patch, and
again in the body of the commit message.

Fix this by unconditionally filtering the From: field out of the
constructed commit message that is used for git.

This patch was sent out via my local version of guilt that has this
patch applied, so the sending of this patch is demonstration that
this fix has been tested and works...

Signed-off-by: Dave Chinner <[email protected]>
Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
  • Loading branch information
Dave Chinner authored and jeffpc committed Mar 13, 2012
1 parent 2c7276b commit 8f88f95
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions guilt
Original file line number Diff line number Diff line change
Expand Up @@ -348,21 +348,29 @@ BEGIN{}
# usage: do_get_header patchfile
do_get_header()
{
# The complexity arises from the fact that we want to ignore all
# but the Subject line of the header, and any empty lines after it,
# if these exist, and inject only the Subject line as the first
# line of the commit message.
# The complexity arises from the fact that we want to ignore all but the
# Subject line of the header, and any empty lines after it, if these
# exist, and inject only the Subject line as the first line of the
# commit message.
#
# We also need to strip "from:" lines from the body of the patch
# description as these are used by people to manually set the author of
# the patch to be different to their local email address and failing to
# strip them results in duplicate from: lines in output from guilt
# patchbomb.

# 1st line prints first encountered Subject line plus empty line.
# 2nd line skips standard email/git patch header lines.
# 3rd line skips tip's additional header lines.
# 4th line skips any empty lines thereafter.
# 5th line turns off empty line skip upon seeing a non-empty line.
# 6th line terminates execution when we encounter the diff
# 3th line skips "from:" lines throughout the patch description
# 4rd line skips tip's additional header lines.
# 5th line skips any empty lines thereafter.
# 6th line turns off empty line skip upon seeing a non-empty line.
# 7th line terminates execution when we encounter the diff
cat "$1" | awk '
BEGIN{body=0; subj=0}
/^Subject:/ && (body == 0 && subj == 0){subj=1; print substr($0, 10) "\n"; next}
/^(Subject:|From:|Author:|Date:|commit)/ && (body == 0){next}
/^(Subject:|Author:|Date:|commit)/ && (body == 0){next}
/^From:/ {next}
/^(Commit-ID:|Gitweb:|AuthorDate:|Committer:CommitDate:)/ && (body == 0){next}
/^[ \t\f\n\r\v]*$/ && (body==0){next}
/^.*$/ && (body==0){body=1}
Expand Down

0 comments on commit 8f88f95

Please sign in to comment.