Browse Source

[PATCH] format-patch: fix skipping of blank-lines

If it is fed a commit with more than one leading blank lines,
the sed scripts git-format-patch-script used looped forever.
Using git-stripspace upfront makes the sed script somewhat
simpler to work around this problem.

Also use git-rev-parse so that we can say

    $ git-format-patch-script HEAD^^^^

to prepare the latest four patches for e-mail submission.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
maint
Junio C Hamano 20 years ago committed by Linus Torvalds
parent
commit
1855c04462
  1. 22
      git-format-patch-script

22
git-format-patch-script

@ -53,6 +53,8 @@ case "$#" in
1) linus="$1" junio=HEAD ;; 1) linus="$1" junio=HEAD ;;
*) usage ;; *) usage ;;
esac esac
junio=`git-rev-parse --verify "$junio"`
linus=`git-rev-parse --verify "$linus"`


case "$outdir" in case "$outdir" in
*/) ;; */) ;;
@ -66,9 +68,9 @@ trap 'rm -f $tmp-*' 0 1 2 3 15
series=$tmp-series series=$tmp-series


titleScript=' titleScript='
1,/^$/d /./d
: loop /^$/n
/^$/b loop s/^\[PATCH[^]]*\] *//
s/[^-a-z.A-Z_0-9]/-/g s/[^-a-z.A-Z_0-9]/-/g
s/\.\.\.*/\./g s/\.\.\.*/\./g
s/\.*$// s/\.*$//
@ -76,6 +78,7 @@ titleScript='
s/^-// s/^-//
s/-$// s/-$//
s/$/./ s/$/./
p
q q
' '


@ -88,7 +91,9 @@ total=`wc -l <$series`
i=$total i=$total
while read commit while read commit
do do
title=`git-cat-file commit "$commit" | sed -e "$titleScript"` title=`git-cat-file commit "$commit" |
git-stripspace |
sed -ne "$titleScript"`
case "$numbered" in case "$numbered" in
'') num= ;; '') num= ;;
*) *)
@ -102,16 +107,17 @@ do
echo "$file" echo "$file"
{ {
mailScript=' mailScript='
1,/^$/d /./d
: loop /^$/n
/^$/b loop
s|^|[PATCH'"$num"'] | s|^|[PATCH'"$num"'] |
: body : body
p p
n n
b body' b body'


git-cat-file commit "$commit" | sed -ne "$mailScript" git-cat-file commit "$commit" |
git-stripspace |
sed -ne "$mailScript"
echo '---' echo '---'
echo echo
git-diff-tree -p $diff_opts "$commit" | git-apply --stat --summary git-diff-tree -p $diff_opts "$commit" | git-apply --stat --summary

Loading…
Cancel
Save