git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Feb 9, 2007, 00:43 UTC
Message-ID
<Pine.LNX.4.63.0702090142100.22628@wbgn013.biozentrum.uni-wuerzburg.de>
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)
Previous: Linus TorvaldsNext: Johannes Schindelin
Message 14 of 21 in “qgit: Default the log window to wider than the file list and set monospaced font”
  1. qgit: Default the log window to wider than the file list and set monospaced fontAndy Parkins, Feb 7, 2007
  2. Marco CostalbaFeb 8, 2007
  3. Jakub NarebskiFeb 8, 2007
  4. Andy ParkinsFeb 8, 2007
  5. Marco CostalbaFeb 8, 2007
  6. Andy ParkinsFeb 8, 2007
  7. Marco CostalbaFeb 8, 2007
  8. Marco CostalbaFeb 8, 2007
  9. Andy ParkinsFeb 8, 2007
  10. qgit4: Add a header and set the font family appropriately to the log messageAndy Parkins, Feb 8, 2007
  11. Shawn O. PearceFeb 8, 2007
  12. Junio C HamanoFeb 8, 2007
  13. Linus TorvaldsFeb 9, 2007
  14. format-patch -n: make sorting easier by padding numberJohannes Schindelin, Feb 9, 2007
  15. Johannes SchindelinFeb 9, 2007
  16. Michael S. TsirkinFeb 9, 2007
  17. Marco CostalbaFeb 9, 2007
  18. qgit4: Removed the monospace font override from the log viewer boxAndy Parkins, Feb 8, 2007
  19. qgit4: Set a 5:1 stretch ratio on the left and right halves of the patch viewerAndy Parkins, Feb 8, 2007
  20. Andy ParkinsFeb 8, 2007
  21. Andy ParkinsFeb 8, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.