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

Re: What's in git.git (stable), and Announcing GIT 1.4.4.3

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Dec 21, 2006, 11:38 UTC
Message-ID
<Pine.LNX.4.63.0612211231000.19693@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<7vmz5ib8eu.fsf@assigned-by-dhcp.cox.net>
Hi,
On Wed, 20 Dec 2006, Junio C Hamano wrote:
Show 5 quoted lines
>    Nicolas Pitre (4):
>       make patch_delta() error cases a bit more verbose
>       make git a bit less cryptic on fetch errors
>       index-pack usage of mmap() is unacceptably slower on many OSes
>          other than Linux
I assume that this line is indented manually, but ...
>       clarify some error messages wrt unknown object types
> 
>    Robert Fitzsimons (1):
>       gitweb: Show '...' links in "summary" view only if there are more items

this is not, in spite of being longer than 76 characters (Do I remember correctly that this supposed to be the maximum length for lines in emails?).

FWIW, I hacked a half-serious patch to wrap the lines automatically:

-- snipsnap -- [FWOT] shortlog: wrap long lines

If a oneline is longer than 76 characters, wrap it and indent with 9 instead of 6 spaces.

For the heck of it, assume UTF-8, and fall back to single-byte
encodings when finding that it cannot be UTF-8. (Not that it makes
a difference if you stick to ASCII.)
---
 builtin-shortlog.c  |   61 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 t/t4201-shortlog.sh |   44 ++++++++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+), 1 deletions(-)
diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index edb4042..be5691e 100644
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
@@ -276,6 +276,64 @@ static void get_from_rev(struct rev_info *rev, struct path_list *list)
 
 }
 
+/* Wrap the text, if necessary. */
+static void print_oneline(const char *oneline, int indent, int indent2, int len)
+{
+	int i, count, count_utf8, last_space = -1, assume_utf8 = 1;
+
+	count = count_utf8 = 0;
+
+	for (;;) {
+		unsigned char c = (unsigned char)oneline[count++];
+		if (!c || isspace(c)) {
+			int cur = indent
+				+ (assume_utf8 ? count_utf8 : count - 1);
+			if (cur < len || last_space < 0) {
+//printf("(%d)", cur);
+				if (last_space > 0)
+					putchar(' ');
+				else
+					for (i = 0; i < indent; i++)
+						putchar(' ');
+				for (i = last_space + 1; i < count - 1; i++)
+					putchar(oneline[i]);
+				if (!c) {
+					putchar('\n');
+					return;
+				}
+				last_space = count - 1;
+				count_utf8++;
+			} else {
+				putchar('\n');
+				for (oneline += last_space + 1;
+						isspace(*oneline); oneline++)
+					; /* do nothing */
+				indent = indent2;
+				last_space = -1;
+				count = count_utf8 = 0;
+			}
+			continue;
+		}
+		if (assume_utf8 && c > 0x7f) {
+			int multi_byte_count = 1;
+			if ((c & 0xe0) == 0xc0)
+				multi_byte_count = 2;
+			else if ((c & 0xf0) == 0xe0)
+				multi_byte_count = 3;
+			else if ((c & 0xf8) == 0xf0)
+				multi_byte_count = 4;
+			else
+				assume_utf8 = 0;
+			for (i = 0; i < multi_byte_count - 1; i++)
+				if (!oneline[count + i])
+					assume_utf8 = 0;
+			if (assume_utf8)
+				count += multi_byte_count - 1;
+		}
+		count_utf8++;
+	}
+}
+
 int cmd_shortlog(int argc, const char **argv, const char *prefix)
 {
 	struct rev_info rev;
@@ -321,7 +379,8 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
 		} else {
 			printf("%s (%d):\n", list.items[i].path, onelines->nr);
 			for (j = onelines->nr - 1; j >= 0; j--)
-				printf("      %s\n", onelines->items[j].path);
+				print_oneline(onelines->items[j].path,
+					6, 9, 76);
 			printf("\n");
 		}
 
diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh
new file mode 100644
index 0000000..86a2295
--- /dev/null
+++ b/t/t4201-shortlog.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Johannes E. Schindelin
+#
+
+test_description='git-shortlog
+'
+
+. ./test-lib.sh
+
+echo 1 > a1
+git add a1
+tree=$(git write-tree)
+commit=$((echo "Test"; echo) | git commit-tree $tree)
+git update-ref HEAD $commit 
+
+echo 2 > a1
+git commit -m "This is a very, very long first line for the commit message to see if it is wrapped correctly" a1
+
+# test if the wrapping is still valid when replacing all i's by treble clefs.
+echo 3 > a1
+git commit -m "$(echo "This is a very, very long first line for the commit message to see if it is wrapped correctly" | sed "s/i/1234/g" | tr 1234 '\360\235\204\236')" a1
+
+# now fsck up the utf8
+echo 4 > a1
+git commit -m "$(echo "This is a very, very long first line for the commit message to see if it is wrapped correctly" | sed "s/i/1234/g" | tr 1234 '\370\235\204\236')" a1
+
+git shortlog HEAD > out
+
+cat > expect << EOF
+A U Thor (4):
+      Test
+      This is a very, very long first line for the commit message to see if
+         it is wrapped correctly
+      Th𝄞s 𝄞s a very, very long f𝄞rst l𝄞ne for the comm𝄞t message to see 𝄞f
+         𝄞t 𝄞s wrapped correctly
+      Thø„žs ø„žs a very, very long fø„žrst lø„žne for the commø„žt
+         message to see ø„žf ø„žt ø„žs wrapped correctly
+
+EOF
+
+test_expect_success 'shortlog wrapping' 'diff -u expect out'
+
+test_done
-- 
1.4.4.3.g610c-dirty
Previous: Nicolas PitreNext: Randal L. Schwartz
Message 44 of 48 in “What's in git.git (stable), and Announcing GIT 1.4.4.3”
  1. Junio C HamanoDec 20, 2006
  2. Randal L. SchwartzDec 20, 2006
  3. Linus TorvaldsDec 20, 2006
  4. [BUG] daemon.c blows up on OSX (was Re: What's in git.git (stable), and Announcing GIT 1.4.4.3)Randal L. Schwartz, Dec 20, 2006
  5. Junio C HamanoDec 20, 2006
  6. Randal L. SchwartzDec 20, 2006
  7. Junio C HamanoDec 20, 2006
  8. Randal L. SchwartzDec 20, 2006
  9. Junio C HamanoDec 20, 2006
  10. Randal L. SchwartzDec 20, 2006
  11. Randal L. SchwartzDec 20, 2006
  12. Stefan PfetzingDec 21, 2006
  13. Linus TorvaldsDec 20, 2006
  14. Randal L. SchwartzDec 20, 2006
  15. Junio C HamanoDec 20, 2006
  16. Linus TorvaldsDec 20, 2006
  17. Terje Sten BjerksethDec 21, 2006
  18. Junio C HamanoDec 21, 2006
  19. Terje Sten BjerksethDec 21, 2006
  20. Junio C HamanoDec 21, 2006
  21. Randal L. SchwartzDec 21, 2006
  22. Junio C HamanoDec 21, 2006
  23. Terje Sten BjerksethDec 21, 2006
  24. Do not define _XOPEN_SOURCE on MacOSX as it is too restricting thereMarco Roeland, Dec 21, 2006
  25. Don't define _XOPEN_SOURCE on MacOSX and FreeBSD as it is too restrictingMarco Roeland, Dec 21, 2006
  26. Junio C HamanoDec 22, 2006
  27. Shawn PearceDec 22, 2006
  28. Rocco RutteDec 22, 2006
  29. Marco RoelandDec 22, 2006
  30. Junio C HamanoDec 22, 2006
  31. Marco RoelandDec 22, 2006
  32. Rocco RutteDec 22, 2006
  33. Marco RoelandDec 22, 2006
  34. Andreas EricssonJan 3, 2007
  35. Linus TorvaldsDec 21, 2006
  36. Randal L. SchwartzDec 21, 2006
  37. Junio C HamanoDec 21, 2006
  38. Randal L. SchwartzDec 21, 2006
  39. Randal L. SchwartzDec 20, 2006
  40. Junio C HamanoDec 20, 2006
  41. Johannes SchindelinDec 21, 2006
  42. Junio C HamanoDec 21, 2006
  43. Nicolas PitreDec 20, 2006
  44. Johannes SchindelinDec 21, 2006
  45. Randal L. SchwartzDec 21, 2006
  46. Junio C HamanoDec 21, 2006
  47. Randal L. SchwartzDec 21, 2006
  48. Junio C HamanoDec 21, 2006

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.