Git development
 help / color / mirror / Atom feed
* [PATCH] --pretty=format: print fewer <unknown>s
@ 2007-03-28 22:09 Jeff King
  2007-03-28 22:13 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2007-03-28 22:09 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Schindelin, git

This makes empty bodies truly empty, and fills in the
default UTF-8 encoding for an empty encoding.

Signed-off-by: Jeff King <peff@peff.net>
---

I think this covers everything that might happen in common practice.

 commit.c                   |    6 ++++--
 t/t6006-rev-list-format.sh |   16 ++++++++--------
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/commit.c b/commit.c
index 754d1b8..e4f1db5 100644
--- a/commit.c
+++ b/commit.c
@@ -895,8 +895,10 @@ static long format_commit_message(const struct commit *commit,
 				xstrndup(msg + i + 9, eol - i - 9);
 		i = eol;
 	}
-	if (msg[i])
-		table[IBODY].value = xstrdup(msg + i);
+	interp_set_entry(table, IBODY, msg[i] ? msg + i : "");
+
+	if (!table[IENCODING].value)
+		interp_set_entry(table, IENCODING, "UTF-8");
 	for (i = 0; i < ARRAY_SIZE(table); i++)
 		if (!table[i].value)
 			interp_set_entry(table, i, "<unknown>");
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index aab17fa..03ef6e0 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -79,9 +79,9 @@ EOF
 
 test_format encoding %e <<'EOF'
 commit 131a310eb913d107dd3c09a65d1651175898735d
-<unknown>
+UTF-8
 commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-<unknown>
+UTF-8
 EOF
 
 test_format subject %s <<'EOF'
@@ -93,9 +93,9 @@ EOF
 
 test_format body %b <<'EOF'
 commit 131a310eb913d107dd3c09a65d1651175898735d
-<unknown>
+
 commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-<unknown>
+
 EOF
 
 test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'
@@ -121,9 +121,9 @@ test_format complex-encoding %e <<'EOF'
 commit f58db70b055c5718631e5c61528b28b12090cdea
 iso8859-1
 commit 131a310eb913d107dd3c09a65d1651175898735d
-<unknown>
+UTF-8
 commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-<unknown>
+UTF-8
 EOF
 
 test_format complex-subject %s <<'EOF'
@@ -142,9 +142,9 @@ and it will be encoded in iso8859-1. We should therefore
 include an iso8859 character: ¡bueno!
 
 commit 131a310eb913d107dd3c09a65d1651175898735d
-<unknown>
+
 commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-<unknown>
+
 EOF
 
 test_done
-- 
1.5.1.rc2.637.ge090-dirty

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] --pretty=format: print fewer <unknown>s
  2007-03-28 22:09 [PATCH] --pretty=format: print fewer <unknown>s Jeff King
@ 2007-03-28 22:13 ` Junio C Hamano
  2007-03-28 22:17   ` Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2007-03-28 22:13 UTC (permalink / raw)
  To: Jeff King; +Cc: Johannes Schindelin, git

Jeff King <peff@peff.net> writes:

> This makes empty bodies truly empty, and fills in the
> default UTF-8 encoding for an empty encoding.

I do not think the latter is correct.  Replacing with an empty
string might make sense, although I haven't thought through the
issues.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] --pretty=format: print fewer <unknown>s
  2007-03-28 22:13 ` Junio C Hamano
@ 2007-03-28 22:17   ` Jeff King
  0 siblings, 0 replies; 3+ messages in thread
From: Jeff King @ 2007-03-28 22:17 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Schindelin, git

On Wed, Mar 28, 2007 at 03:13:30PM -0700, Junio C Hamano wrote:

> > This makes empty bodies truly empty, and fills in the
> > default UTF-8 encoding for an empty encoding.
> 
> I do not think the latter is correct.  Replacing with an empty
> string might make sense, although I haven't thought through the
> issues.

Fair enough. I originally put in an empty string, but tried to be (too)
clever with UTF-8 (I was under the impression that commits without
headers were assumed to be in UTF-8, unless there is some legacy
override set). I'm fine with whatever makes sense, but I think printing
<unknown> is silly: we _do_ know.

-Peff

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-03-28 22:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-28 22:09 [PATCH] --pretty=format: print fewer <unknown>s Jeff King
2007-03-28 22:13 ` Junio C Hamano
2007-03-28 22:17   ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox