git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: Re: What's in git.git (stable), and Announcing GIT 1.4.4.3
Date: Thu, 21 Dec 2006 12:38:17 +0100 (CET)	[thread overview]
Message-ID: <Pine.LNX.4.63.0612211231000.19693@wbgn013.biozentrum.uni-wuerzburg.de> (raw)
In-Reply-To: <7vmz5ib8eu.fsf@assigned-by-dhcp.cox.net>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 4909 bytes --]

Hi,

On Wed, 20 Dec 2006, Junio C Hamano wrote:

>    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

      parent reply	other threads:[~2006-12-21 11:38 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-20 20:48 What's in git.git (stable), and Announcing GIT 1.4.4.3 Junio C Hamano
2006-12-20 22:04 ` Randal L. Schwartz
2006-12-20 22:14   ` Linus Torvalds
2006-12-20 22:20     ` [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
2006-12-20 22:25       ` [BUG] daemon.c blows up on OSX Junio C Hamano
2006-12-20 22:35         ` Randal L. Schwartz
2006-12-20 22:44           ` Junio C Hamano
2006-12-20 22:46           ` Randal L. Schwartz
2006-12-20 23:03             ` Junio C Hamano
2006-12-20 23:25               ` Randal L. Schwartz
2006-12-20 23:34                 ` Randal L. Schwartz
2006-12-21  2:04                   ` Stefan Pfetzing
2006-12-20 23:07             ` Linus Torvalds
2006-12-20 23:17               ` Randal L. Schwartz
2006-12-20 23:30                 ` Junio C Hamano
2006-12-20 23:41                 ` Linus Torvalds
2006-12-21  0:36                   ` Terje Sten Bjerkseth
2006-12-21  0:44                     ` Junio C Hamano
2006-12-21  0:54                       ` Terje Sten Bjerkseth
2006-12-21  1:00                         ` Junio C Hamano
2006-12-21  1:20                           ` Randal L. Schwartz
2006-12-21  1:29                             ` Junio C Hamano
2006-12-21  1:35                             ` Terje Sten Bjerkseth
2006-12-21 10:39                               ` [PATCH] Do not define _XOPEN_SOURCE on MacOSX as it is too restricting there Marco Roeland
2006-12-21 11:28                                 ` [PATCH] Don't define _XOPEN_SOURCE on MacOSX and FreeBSD as it is too restricting Marco Roeland
2006-12-22  0:52                                   ` Junio C Hamano
2006-12-22  1:04                                     ` Shawn Pearce
2006-12-22  6:53                                     ` Rocco Rutte
2006-12-22  7:51                                     ` Marco Roeland
2006-12-22  8:37                                       ` Junio C Hamano
2006-12-22 11:47                                         ` Marco Roeland
2006-12-22 12:55                                           ` Rocco Rutte
2006-12-22 13:14                                             ` Marco Roeland
2007-01-03 15:25                       ` [BUG] daemon.c blows up on OSX Andreas Ericsson
2006-12-21  0:44                     ` Linus Torvalds
2006-12-21  1:07                       ` Randal L. Schwartz
2006-12-21  1:13                         ` Junio C Hamano
2006-12-21  1:08                     ` Randal L. Schwartz
     [not found]                       ` <24BF45E9-DD98-4609-9D65-B01EAA30CCA8@silverinsanity.com>
2006-12-21  1:35                         ` Randal L. Schwartz
2006-12-21  1:48                           ` Junio C Hamano
2006-12-21  1:50                             ` Randal L. Schwartz
2006-12-21  1:57                               ` Junio C Hamano
2006-12-20 23:58     ` What's in git.git (stable), and Announcing GIT 1.4.4.3 Randal L. Schwartz
2006-12-20 22:17   ` Junio C Hamano
2006-12-21  8:43     ` Johannes Schindelin
2006-12-21  8:52       ` Junio C Hamano
2006-12-20 22:19   ` Nicolas Pitre
2006-12-21 11:38 ` Johannes Schindelin [this message]

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

  List information: http://vger.kernel.org/majordomo-info.html

* 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.0612211231000.19693@wbgn013.biozentrum.uni-wuerzburg.de \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).