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>
Junio C Hamano committed
Dec 10, 2005 at 22:22 UTC
7564577a6c05a1153ddb94cbe68e75c391b52f20
1 file changed
+10
-4
git-format-patch.sh
+10
-4
@@ -254,6 +254,15 @@ Date: '"$ad"
254
}
255
256
total=`wc -l <$series | tr -dc "[0-9]"`
257
+case "$total,$numbered" in
258
+1,*)
259
+ numfmt='' ;;
260
+*,t)
261
+ numfmt=`echo "$total" | wc -c`
262
+ numfmt=$(($numfmt-1))
263
+ numfmt=" %0${numfmt}d/$total"
264
+esac
265
+
266
i=1
267
while read commit
268
do
@@ -262,10 +271,7 @@ do
271
case "$numbered" in
272
'') num= ;;
273
*)
265
- case $total in
266
- 1) num= ;;
267
- *) num=' '`printf "%d/%d" $i $total` ;;
268
- esac
274
+ num=`printf "$numfmt" $i` ;;
275
esac
276
277
file=`printf '%04d-%stxt' $i "$title"`