All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Junio C Hamano <junkio@cox.net>, git@vger.kernel.org
Subject: [PATCH] format-patch -n: make sorting easier by padding number
Date: Fri, 9 Feb 2007 01:43:54 +0100 (CET)	[thread overview]
Message-ID: <Pine.LNX.4.63.0702090142100.22628@wbgn013.biozentrum.uni-wuerzburg.de> (raw)
In-Reply-To: <Pine.LNX.4.64.0702081623460.8424@woody.linux-foundation.org>


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@gmx.de>

---

	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)

  reply	other threads:[~2007-02-09  0:44 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-07 21:38 [PATCH] qgit: Default the log window to wider than the file list and set monospaced font Andy Parkins
2007-02-08  8:39 ` Marco Costalba
2007-02-08  9:46   ` Jakub Narebski
2007-02-08 10:20   ` Andy Parkins
2007-02-08 19:06     ` Marco Costalba
2007-02-08 19:12       ` Andy Parkins
2007-02-08 19:29         ` Marco Costalba
2007-02-08 19:51           ` Marco Costalba
2007-02-08 21:58             ` Andy Parkins
2007-02-08 23:31               ` [PATCH] qgit4: Add a header and set the font family appropriately to the log message Andy Parkins
2007-02-08 23:41                 ` Shawn O. Pearce
2007-02-08 23:58                   ` Junio C Hamano
2007-02-09  0:29                     ` Linus Torvalds
2007-02-09  0:43                       ` Johannes Schindelin [this message]
2007-02-09  0:47                         ` [PATCH] format-patch -n: make sorting easier by padding number Johannes Schindelin
2007-02-09  9:19                     ` [PATCH] qgit4: Add a header and set the font family appropriately to the log message Michael S. Tsirkin
2007-02-09  5:44                 ` Marco Costalba
2007-02-08 23:31               ` [PATCH] qgit4: Removed the monospace font override from the log viewer box Andy Parkins
2007-02-08 23:31               ` [PATCH] qgit4: Set a 5:1 stretch ratio on the left and right halves of the patch viewer Andy Parkins
2007-02-08 23:04           ` [PATCH] qgit: Default the log window to wider than the file list and set monospaced font Andy Parkins
2007-02-08 10:22   ` Andy Parkins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.63.0702090142100.22628@wbgn013.biozentrum.uni-wuerzburg.de \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.