aboutsummaryrefslogtreecommitdiff
path: root/git-format-patch.sh
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-12-10 22:22:35 -0800
committerJunio C Hamano <junkio@cox.net>2005-12-10 22:22:35 -0800
commit7564577a6c05a1153ddb94cbe68e75c391b52f20 (patch)
tree0d872a53a50f750090ec9932696c2fe40ce2627c /git-format-patch.sh
parenteea420693befc2f876079a8a4585ea8ebf07c047 (diff)
downloadgit-7564577a6c05a1153ddb94cbe68e75c391b52f20.tar.gz
git-7564577a6c05a1153ddb94cbe68e75c391b52f20.tar.xz
format-patch: use same number of digits in numbers
This would help sorting by subject in MUA work saner even though MUA is too dumb to attempt sorting numbered subjects sanely. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-format-patch.sh')
-rwxr-xr-xgit-format-patch.sh14
1 files changed, 10 insertions, 4 deletions
diff --git a/git-format-patch.sh b/git-format-patch.sh
index 1eebe857c..921feee59 100755
--- a/git-format-patch.sh
+++ b/git-format-patch.sh
@@ -254,6 +254,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
@@ -262,10 +271,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"`