X-Git-Url: https://git.octo.it/?a=blobdiff_plain;ds=sidebyside;f=git-format-patch.sh;h=daa3caea778e13e946c4ffe53c876f5222ce7dfe;hb=a14c225661fa2fc271d9e0fbf262e369dc7254fc;hp=9b4088045a5d53ceb1b893e5f6bda575518d36c1;hpb=069b20a198f171512a1d2d2163b40f70c94f5257;p=git.git diff --git a/git-format-patch.sh b/git-format-patch.sh index 9b408804..daa3caea 100755 --- a/git-format-patch.sh +++ b/git-format-patch.sh @@ -3,15 +3,8 @@ # Copyright (c) 2005 Junio C Hamano # -. git-sh-setup - -usage () { - echo >&2 "usage: $0"' [-n] [-o dir | --stdout] [--keep-subject] [--mbox] - [--check] [--signoff] [-...] - [--help] - ( from..to ... | upstream [ our-head ] ) - -Prepare each commit with its patch since our-head forked from upstream, +USAGE='[-n | -k] [-o | --stdout] [--signoff] [--check] [--mbox] [--diff-options] []' +LONG_USAGE='Prepare each commit with its patch since our-head forked from upstream, one file per patch, for e-mail submission. Each output file is numbered sequentially from 1, and uses the first line of the commit message (massaged for pathname safety) as the filename. @@ -24,10 +17,12 @@ as "[PATCH N/M] Subject", unless you have only one patch. When --mbox is specified, the output is formatted to resemble UNIX mailbox format, and can be concatenated together for processing -with applymbox. -' - exit 1 -} +with applymbox.' +. git-sh-setup + +# Force diff to run in C locale. +LANG=C LC_ALL=C +export LANG LC_ALL diff_opts= LF=' @@ -202,7 +197,7 @@ process_one () { ;; esac - eval "$(LANG=C LC_ALL=C sed -ne "$whosepatchScript" $commsg)" + eval "$(sed -ne "$whosepatchScript" $commsg)" test "$author,$au" = ",$me" || { mailScript="$mailScript"' a\ @@ -215,6 +210,8 @@ Date: '"$ad" } mailScript="$mailScript"' + a\ + : body p n @@ -238,9 +235,8 @@ Date: '"$ad" echo git-diff-tree -p $diff_opts "$commit" | git-apply --stat --summary echo - git-cat-file commit "$commit^" | sed -e 's/^tree /applies-to: /' -e q git-diff-tree -p $diff_opts "$commit" - echo "---" + echo "-- " echo "@@GIT_VERSION@@" case "$mbox" in @@ -251,6 +247,15 @@ Date: '"$ad" } total=`wc -l <$series | tr -dc "[0-9]"` +case "$total,$numbered" in +1,*) + numfmt='' ;; +*,t) + numfmt=`echo "$total" | wc -c` + numfmt=$(($numfmt-1)) + numfmt=" %0${numfmt}d/$total" +esac + i=1 while read commit do @@ -259,10 +264,7 @@ do case "$numbered" in '') num= ;; *) - case $total in - 1) num= ;; - *) num=' '`printf "%d/%d" $i $total` ;; - esac + num=`printf "$numfmt" $i` ;; esac file=`printf '%04d-%stxt' $i "$title"`