[PATCH] format-patch -n: make sorting easier by padding number

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Now, when format-patch outputs more than 9 patches, the numbers
are padded accordingly. Example:

	[PATCH 009/167] The 9th patch of a series of 167

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@xxxxxx>

---

	On Thu, 8 Feb 2007, Linus Torvalds wrote:
	
	> On Thu, 8 Feb 2007, Junio C Hamano wrote:
	> > 
	> > This came up before, but when you have more than 9 in your
	> > series, we _could_ do [PATCH 01/12] ... [PATCH 12/12] to line
	> > them up in e-mail client of the recipients better.
	> 
	> Not just "line them up". It's more than just a visual thing.

	How about this?

	Yes, it calculates the width over and over again, but it's not
	like it's a really performance critical part.

 log-tree.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/log-tree.c b/log-tree.c
index 85acd66..89c29e2 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -102,6 +102,16 @@ static int append_signoff(char *buf, int buf_sz, int at, const char *signoff)
 	return at;
 }
 
+static unsigned int log10(unsigned int number)
+{
+	unsigned int i = 10, result = 1;
+	while (i < number) {
+		i *= 10;
+		result++;
+	}
+	return result;
+}
+
 void show_log(struct rev_info *opt, const char *sep)
 {
 	static char this_header[16384];
@@ -155,7 +165,8 @@ void show_log(struct rev_info *opt, const char *sep)
 		if (opt->total > 0) {
 			static char buffer[64];
 			snprintf(buffer, sizeof(buffer),
-					"Subject: [PATCH %d/%d] ",
+					"Subject: [PATCH %0*d/%d] ",
+					log10(opt->total),
 					opt->nr, opt->total);
 			subject = buffer;
 		} else if (opt->total == 0)
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]