git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* git log --oneline and git log --pretty=format... give differrent outputs
@ 2011-07-22  7:06 Shumkin Alexey
  2011-07-22  7:53 ` Alexey Shumkin
  0 siblings, 1 reply; 104+ messages in thread
From: Shumkin Alexey @ 2011-07-22  7:06 UTC (permalink / raw)
  To: git

Hello everybody!

I have a repository. Basic development is on Windows platform (under
Cygwin). I have commit messages on Russian, so 
i18n.commitEncoding = i18n.logOutputtEncoding = cp1251. It's ok.
I works fine on Windows.
When I run on Windows 
git log --graph --oneline
and 
git log --graph --pretty=format:'%C(yellow)%h %Creset%s'

I get two identical outputs which look like
*   ae0a70f merge v2.6.54 into v3.0
|\  
| * 581e071 + explicit changelog mail content-type (for claws-mail)...
| * 9bafb65 fixed: changelog does not recognize Mantis...
| * f417e91 fixed: #82 (Добавить в программу возможность...
| * 8553efa fixed: #87 (2.6.53 Добавить для рассылки e-mail...
....

But when I run the same commands (for the same repository and current
commit, of course) on Linux machine (ru_RU.UTF-8 locale; Guake,
xterm, gnome-terminal, etc ) I get different outputs

git log --graph --oneline
gives output identical to Windows (see above)
but
git log --graph --pretty=format:'%C(yellow)%h %Creset%s'
gives
*   ae0a70f merge v2.6.54 into v3.0
|\  
| * 581e071 + explicit changelog mail content-type (for claws-mail)...
| * 9bafb65 fixed: changelog does not recognize Mantis...
| * f417e91 fixed: #82 (<C4><EE><E1><E0><E2><E8><F2><FC>...
| * 8553efa fixed: #87 (2.6.53<C4><EE><E1><E0><E2><E8><F2><FC>...

i.e. non-UTF-8 characters are represented with their codes and not
converted to UTF-8 as they are for "git log --graph --oneline"

So, the question - why? I thought both commands use the same log output
mechanism.
As I can edit Git sources but I'm not familiar to C well, so one
more question "Where exactly in sources to fix it fast?"

Thanks

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

* Re: git log --oneline and git log --pretty=format... give differrent outputs
  2011-07-22  7:06 git log --oneline and git log --pretty=format... give differrent outputs Shumkin Alexey
@ 2011-07-22  7:53 ` Alexey Shumkin
  2011-07-25 10:31   ` [PATCH] pretty: user format ignores i18n.logOutputEncoding setting Alexey Shumkin
  0 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2011-07-22  7:53 UTC (permalink / raw)
  To: git

Oh! I've fixed it!
A patch I'll provide soon

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

* [PATCH] pretty: user format ignores i18n.logOutputEncoding setting
  2011-07-22  7:53 ` Alexey Shumkin
@ 2011-07-25 10:31   ` Alexey Shumkin
  2011-07-25 10:31     ` Alexey Shumkin
  0 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2011-07-25 10:31 UTC (permalink / raw)
  To: git


Started here http://thread.gmane.org/gmane.comp.version-control.git/177634

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

* [PATCH] pretty: user format ignores i18n.logOutputEncoding setting
  2011-07-25 10:31   ` [PATCH] pretty: user format ignores i18n.logOutputEncoding setting Alexey Shumkin
@ 2011-07-25 10:31     ` Alexey Shumkin
  2011-07-25 19:45       ` Junio C Hamano
  0 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2011-07-25 10:31 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin

git log --graph --oneline
and
git log --graph --pretty=format:'%C(yellow)%h %Creset%s'
give different outputs on Linux UTF-8 console
when commit messages contain non-UTF-8 characters
(e.g. commits made on Windows)

Fix it.

Signed-off-by: Alexey Shumkin <zapped@mail.ru>
---
 log-tree.c                    |    1 +
 t/t4205-log-pretty-formats.sh |   20 ++++++++++++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/log-tree.c b/log-tree.c
index e945701..39913d7 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -488,6 +488,7 @@ void show_log(struct rev_info *opt)
 	ctx.preserve_subject = opt->preserve_subject;
 	ctx.reflog_info = opt->reflog_info;
 	ctx.fmt = opt->commit_format;
+	ctx.output_encoding = get_log_output_encoding();
 	pretty_print_commit(&ctx, commit, &msgbuf);
 
 	if (opt->add_signoff)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 2ae9faa..24e787a 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -11,10 +11,12 @@ test_expect_success 'set up basic repos' '
 	>bar &&
 	git add foo &&
 	test_tick &&
-	git commit -m initial &&
+	git config i18n.commitEncoding cp1251 &&
+	printf "initial \320\272\320\276\320\274\320\274\320\270\321\202" | iconv -t cp1251 -f utf-8 | xargs -I{} git commit -m "{}" &&
 	git add bar &&
 	test_tick &&
-	git commit -m "add bar"
+	git commit -m "add bar" &&
+	git config --unset i18n.commitEncoding
 '
 
 test_expect_success 'alias builtin format' '
@@ -38,6 +40,20 @@ test_expect_success 'alias user-defined format' '
 	test_cmp expected actual
 '
 
+test_expect_success 'alias user-defined tformat with %s (native encoding)' '
+	git config i18n.logOutputEncoding cp1251 &&
+	git log --oneline >expected-s &&
+	git log --pretty="tformat:%h %s" >actual-s &&
+	git config --unset i18n.logOutputEncoding &&
+	test_cmp expected-s actual-s
+'
+
+test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' '
+	git log --oneline >expected-s &&
+	git log --pretty="tformat:%h %s" >actual-s &&
+	test_cmp expected-s actual-s
+'
+
 test_expect_success 'alias user-defined tformat' '
 	git log --pretty="tformat:%h" >expected &&
 	git config pretty.test-alias "tformat:%h" &&
-- 
1.7.6.dirty

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

* Re: [PATCH] pretty: user format ignores i18n.logOutputEncoding setting
  2011-07-25 10:31     ` Alexey Shumkin
@ 2011-07-25 19:45       ` Junio C Hamano
  2011-07-26 13:18         ` Alexey Shumkin
                           ` (2 more replies)
  0 siblings, 3 replies; 104+ messages in thread
From: Junio C Hamano @ 2011-07-25 19:45 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git, Alexey Shumkin

Alexey Shumkin <alex.crezoff@gmail.com> writes:

> git log --graph --oneline
> and
> git log --graph --pretty=format:'%C(yellow)%h %Creset%s'
> give different outputs on Linux UTF-8 console
> when commit messages contain non-UTF-8 characters

(content) "different" is not specific enough to describe a problem (in
some cases, difference in command line arguments is the way to obtain
different results), especially if you do not state that they "should" be
the same to begin with, and preferrably under what condition they should
be the same.

(content) Do you really need all of the above options to observe the
breakage, or can you drop --graph?  If so, drop it from the proposed
commit log message, as it is distracting without merit.

(content) Do you really mean SP before %Creset, not after?

(style) Somehow I find this hard to read. Perhaps make the two "sample
commands" stand out more from the surrounding text?  E.g.

-- >8 --
The following two ought to give the same output to a terminal:

	$ git log --oneline
        $ git log --pretty=format:'%C(yellow)%h %creset%s'

However, the former pays attention to i18n.logOutputEncoding
configuration, while the latter does not when it format "%s". A log
messages written in an encoding i18n.commitEncoding that is not UTF-8
is shown corrupted with the latter even when i18n.logOutputEncoding is set
to convert to UTF-8.

Signed-off-by: ...
-- 8< --

(question) Does this change affect other commands, most notably
format-patch, and if so how?

> diff --git a/log-tree.c b/log-tree.c
> index e945701..39913d7 100644
> --- a/log-tree.c
> +++ b/log-tree.c
> @@ -488,6 +488,7 @@ void show_log(struct rev_info *opt)
>  	ctx.preserve_subject = opt->preserve_subject;
>  	ctx.reflog_info = opt->reflog_info;
>  	ctx.fmt = opt->commit_format;
> +	ctx.output_encoding = get_log_output_encoding();
>  	pretty_print_commit(&ctx, commit, &msgbuf);
>  
>  	if (opt->add_signoff)
> diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
> index 2ae9faa..24e787a 100755
> --- a/t/t4205-log-pretty-formats.sh
> +++ b/t/t4205-log-pretty-formats.sh
> @@ -11,10 +11,12 @@ test_expect_success 'set up basic repos' '
>  	>bar &&
>  	git add foo &&
>  	test_tick &&
> -	git commit -m initial &&
> +	git config i18n.commitEncoding cp1251 &&
> +	printf "initial \320\272\320\276\320\274\320\274\320\270\321\202" | iconv -t cp1251 -f utf-8 | xargs -I{} git commit -m "{}" &&
>  	git add bar &&
>  	test_tick &&
> -	git commit -m "add bar"
> +	git commit -m "add bar" &&
> +	git config --unset i18n.commitEncoding
>  '
>  
>  test_expect_success 'alias builtin format' '
> @@ -38,6 +40,20 @@ test_expect_success 'alias user-defined format' '
>  	test_cmp expected actual
>  '
>  
> +test_expect_success 'alias user-defined tformat with %s (native encoding)' '
> +	git config i18n.logOutputEncoding cp1251 &&
> +	git log --oneline >expected-s &&
> +	git log --pretty="tformat:%h %s" >actual-s &&
> +	git config --unset i18n.logOutputEncoding &&
> +	test_cmp expected-s actual-s
> +'
> +
> +test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' '
> +	git log --oneline >expected-s &&
> +	git log --pretty="tformat:%h %s" >actual-s &&
> +	test_cmp expected-s actual-s
> +'
> +
>  test_expect_success 'alias user-defined tformat' '
>  	git log --pretty="tformat:%h" >expected &&
>  	git config pretty.test-alias "tformat:%h" &&

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

* Re: [PATCH] pretty: user format ignores i18n.logOutputEncoding setting
  2011-07-25 19:45       ` Junio C Hamano
@ 2011-07-26 13:18         ` Alexey Shumkin
  2011-09-09  8:43         ` [PATCH v2] " Alexey Shumkin
  2011-09-09  8:53         ` [PATCH v2] " Alexey Shumkin
  2 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2011-07-26 13:18 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Alexey Shumkin

В Mon, 25 Jul 2011 12:45:26 -0700
Junio C Hamano <gitster@pobox.com> пишет:

> Alexey Shumkin <alex.crezoff@gmail.com> writes:
> 
> > git log --graph --oneline
> > and
> > git log --graph --pretty=format:'%C(yellow)%h %Creset%s'
> > give different outputs on Linux UTF-8 console
> > when commit messages contain non-UTF-8 characters
> 
> (content) "different" is not specific enough to describe a problem (in
> some cases, difference in command line arguments is the way to obtain
> different results), especially if you do not state that they "should"
> be the same to begin with, and preferrably under what condition they
> should be the same.
Ok, I'll fix the description

> (content) Do you really need all of the above options to observe the
> breakage, or can you drop --graph?  If so, drop it from the proposed
> commit log message, as it is distracting without merit.
You're right. I do not. I just observed the error with such parameters,
so I wrote them, but they are not neccessary for the error appearance.

> (content) Do you really mean SP before %Creset, not after?
Realy do, but it does not matter here

> (style) Somehow I find this hard to read. Perhaps make the two "sample
> commands" stand out more from the surrounding text?  E.g.
> 
> -- >8 --
> The following two ought to give the same output to a terminal:
> 
> 	$ git log --oneline
>         $ git log --pretty=format:'%C(yellow)%h %creset%s'
> 
> However, the former pays attention to i18n.logOutputEncoding
> configuration, while the latter does not when it format "%s". A log
> messages written in an encoding i18n.commitEncoding that is not UTF-8
> is shown corrupted with the latter even when i18n.logOutputEncoding
> is set to convert to UTF-8.
> 
> Signed-off-by: ...
> -- 8< --
I'm sorry. I'm newbie in a patch distribution and collaborative work on
Enlgish (it is not my native language). So thanks for the correction.

> (question) Does this change affect other commands, most notably
> format-patch, and if so how?
I'll discover this, thanks for pointing me a direction.

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

* [PATCH v2] pretty: user format ignores i18n.logOutputEncoding setting
  2011-07-25 19:45       ` Junio C Hamano
  2011-07-26 13:18         ` Alexey Shumkin
@ 2011-09-09  8:43         ` Alexey Shumkin
  2011-09-09  8:43           ` [PATCH 1/2] pretty: Add failing tests: " Alexey Shumkin
  2011-09-09  8:43           ` [PATCH 2/2] pretty: " Alexey Shumkin
  2011-09-09  8:53         ` [PATCH v2] " Alexey Shumkin
  2 siblings, 2 replies; 104+ messages in thread
From: Alexey Shumkin @ 2011-09-09  8:43 UTC (permalink / raw)
  To: git

I discovered two more commands affected with this bug.
So I reroll this patch and tests for it.

>>(question) Does this change affect other commands, most notably
format-patch, and if so how?
No, it does not affect format-patc

---

 builtin/rev-list.c               |    1 +
 builtin/shortlog.c               |    1 +
 log-tree.c                       |    1 +
 submodule.c                      |    3 +
 t/t4041-diff-submodule-option.sh |   44 +++++----
 t/t4205-log-pretty-formats.sh    |   22 ++++-
 t/t6006-rev-list-format.sh       |  192 +++++++++++++++++++++++---------------
 7 files changed, 167 insertions(+), 97 deletions(-)

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

* [PATCH 1/2] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting
  2011-09-09  8:43         ` [PATCH v2] " Alexey Shumkin
@ 2011-09-09  8:43           ` Alexey Shumkin
  2011-09-09  8:43           ` [PATCH 2/2] pretty: " Alexey Shumkin
  1 sibling, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2011-09-09  8:43 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin

The following two ought to give the same output to a terminal:

	$ git log --oneline --no-color
	$ git log --pretty=format:'%h %s'

However, the former pays attention to i18n.logOutputEncoding
configuration, while the latter does not when it format "%s". A log
messages written in an encoding i18n.commitEncoding that differs
from terminal encoding are shown corrupted with the latter even
when i18n.logOutputEncoding and terminal encoding are the same.

The same corruption is true for
	$ git diff --submodule=log
and
	$ git rev-list --pretty=format:%s HEAD

Signed-off-by: Alexey Shumkin <zapped@mail.ru>
---
 t/t4041-diff-submodule-option.sh |   44 +++++----
 t/t4205-log-pretty-formats.sh    |   22 ++++-
 t/t6006-rev-list-format.sh       |  192 +++++++++++++++++++++++---------------
 3 files changed, 161 insertions(+), 97 deletions(-)

diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index bf9a752..4460cff 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 #
 # Copyright (c) 2009 Jens Lehmann, based on t7401 by Ping Yin
+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
 #
 
 test_description='Support for verbose submodule differences in git diff
@@ -10,6 +11,7 @@ This test tries to verify the sanity of the --submodule option of git diff.
 
 . ./test-lib.sh
 
+added=$(printf "\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275")
 add_file () {
 	sm=$1
 	shift
@@ -19,8 +21,12 @@ add_file () {
 		echo "$name" > "$name" &&
 		git add "$name" &&
 		test_tick &&
-		git commit -m "Add $name"
+		git config i18n.commitEncoding cp1251 &&
+		echo "Add $name ($added $name)" \
+			| iconv -f utf-8 -t cp1251 \
+			| xargs -I{} git commit -m "{}"
 	done >/dev/null
+	git config --unset i18n.commitEncoding
 	git rev-parse --verify HEAD | cut -c1-7
 	cd "$owd"
 }
@@ -37,7 +43,7 @@ head1=$(add_file sm1 foo1 foo2)
 test_expect_success 'added submodule' "
 	git add sm1 &&
 	git diff-index -p --submodule=log HEAD >actual &&
-	cat >expected <<-EOF &&
+	cat >expected <<EOF
 Submodule sm1 0000000...$head1 (new submodule)
 EOF
 	test_cmp expected actual
@@ -48,27 +54,27 @@ head2=$(add_file sm1 foo3)
 
 test_expect_success 'modified submodule(forward)' "
 	git diff-index -p --submodule=log HEAD >actual &&
-	cat >expected <<-EOF &&
+	cat >expected <<EOF
 Submodule sm1 $head1..$head2:
-  > Add foo3
+  > Add foo3 ($added foo3)
 EOF
 	test_cmp expected actual
 "
 
 test_expect_success 'modified submodule(forward)' "
 	git diff --submodule=log >actual &&
-	cat >expected <<-EOF &&
+	cat >expected <<EOF
 Submodule sm1 $head1..$head2:
-  > Add foo3
+  > Add foo3 ($added foo3)
 EOF
 	test_cmp expected actual
 "
 
 test_expect_success 'modified submodule(forward) --submodule' "
 	git diff --submodule >actual &&
-	cat >expected <<-EOF &&
+	cat >expected <<EOF
 Submodule sm1 $head1..$head2:
-  > Add foo3
+  > Add foo3 ($added foo3)
 EOF
 	test_cmp expected actual
 "
@@ -98,10 +104,10 @@ head3=$(
 
 test_expect_success 'modified submodule(backward)' "
 	git diff-index -p --submodule=log HEAD >actual &&
-	cat >expected <<-EOF &&
+	cat >expected <<EOF
 Submodule sm1 $head2..$head3 (rewind):
-  < Add foo3
-  < Add foo2
+  < Add foo3 ($added foo3)
+  < Add foo2 ($added foo2)
 EOF
 	test_cmp expected actual
 "
@@ -110,12 +116,12 @@ head4=$(add_file sm1 foo4 foo5) &&
 head4_full=$(GIT_DIR=sm1/.git git rev-parse --verify HEAD)
 test_expect_success 'modified submodule(backward and forward)' "
 	git diff-index -p --submodule=log HEAD >actual &&
-	cat >expected <<-EOF &&
+	cat >expected <<EOF
 Submodule sm1 $head2...$head4:
-  > Add foo5
-  > Add foo4
-  < Add foo3
-  < Add foo2
+  > Add foo5 ($added foo5)
+  > Add foo4 ($added foo4)
+  < Add foo3 ($added foo3)
+  < Add foo2 ($added foo2)
 EOF
 	test_cmp expected actual
 "
@@ -131,10 +137,10 @@ mv sm1-bak sm1
 test_expect_success 'typechanged submodule(submodule->blob), --cached' "
 	git diff --submodule=log --cached >actual &&
 	cat >expected <<-EOF &&
-Submodule sm1 41fbea9...0000000 (submodule deleted)
+Submodule sm1 $head4...0000000 (submodule deleted)
 diff --git a/sm1 b/sm1
 new file mode 100644
-index 0000000..9da5fb8
+index 0000000..$head5
 --- /dev/null
 +++ b/sm1
 @@ -0,0 +1 @@
@@ -148,7 +154,7 @@ test_expect_success 'typechanged submodule(submodule->blob)' "
 	cat >expected <<-EOF &&
 diff --git a/sm1 b/sm1
 deleted file mode 100644
-index 9da5fb8..0000000
+index $head5..0000000
 --- a/sm1
 +++ /dev/null
 @@ -1 +0,0 @@
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 2ae9faa..96e0229 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 #
 # Copyright (c) 2010, Will Palmer
+# Copyright (c) 2011, Alexey Shumkin (+ non-UTF-8 commit encoding tests)
 #
 
 test_description='Test pretty formats'
@@ -11,10 +12,13 @@ test_expect_success 'set up basic repos' '
 	>bar &&
 	git add foo &&
 	test_tick &&
-	git commit -m initial &&
+	git config i18n.commitEncoding cp1251 &&
+	printf "initial \320\272\320\276\320\274\320\274\320\270\321\202" \
+		| iconv -f utf-8 -t cp1251 | xargs -I{} git commit -m "{}" &&
 	git add bar &&
 	test_tick &&
-	git commit -m "add bar"
+	git commit -m "add bar" &&
+	git config --unset i18n.commitEncoding
 '
 
 test_expect_success 'alias builtin format' '
@@ -38,6 +42,20 @@ test_expect_success 'alias user-defined format' '
 	test_cmp expected actual
 '
 
+test_expect_success 'alias user-defined tformat with %s (cp1251 encoding)' '
+	git config i18n.logOutputEncoding cp1251 &&
+	git log --oneline >expected-s &&
+	git log --pretty="tformat:%h %s" >actual-s &&
+	git config --unset i18n.logOutputEncoding &&
+	test_cmp expected-s actual-s
+'
+
+test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' '
+	git log --oneline >expected-s &&
+	git log --pretty="tformat:%h %s" >actual-s &&
+	test_cmp expected-s actual-s
+'
+
 test_expect_success 'alias user-defined tformat' '
 	git log --pretty="tformat:%h" >expected &&
 	git config pretty.test-alias "tformat:%h" &&
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index d918cc0..8d99635 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -1,13 +1,34 @@
 #!/bin/sh
 
+# Copyright (c) 2009 Jens Lehmann
+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
+
 test_description='git rev-list --pretty=format test'
 
 . ./test-lib.sh
 
 test_tick
+added=$(printf "added (\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275) foo")
+added_cp1251=$(echo "$added" | iconv -f utf-8 -t cp1251)
+changed=$(printf "changed (\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275) foo")
+changed_cp1251=$(echo "$changed" | iconv -f utf-8 -t cp1251)
+
 test_expect_success 'setup' '
-touch foo && git add foo && git commit -m "added foo" &&
-  echo changed >foo && git commit -a -m "changed foo"
+	touch foo &&
+	git add foo &&
+	git config i18n.commitEncoding cp1251 &&
+	git commit -m "$added_cp1251" &&
+	head1=$(git rev-parse --verify HEAD) &&
+	head1_7=$(echo $head1 | cut -c1-7) &&
+	echo "$changed" > foo &&
+	git commit -a -m "$changed_cp1251" &&
+	head2=$(git rev-parse --verify HEAD) &&
+	head2_7=$(echo $head2 | cut -c1-7) &&
+	tree2=$(git cat-file -p HEAD | grep tree | cut -f 2 -d" ") &&
+	tree2_7=$(echo $tree2 | cut -c1-7) &&
+	head2_parent=$(git cat-file -p HEAD | grep parent | cut -f 2 -d" ") &&
+	head2_parent_7=$(echo $head2_parent | cut -c1-7) &&
+	git config --unset i18n.commitEncoding
 '
 
 # usage: test_format name format_string <expected_output
@@ -19,49 +40,49 @@ test_cmp expect.$1 output.$1
 "
 }
 
-test_format percent %%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format percent %%h <<EOF
+commit $head2
 %h
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 %h
 EOF
 
-test_format hash %H%n%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-131a310eb913d107dd3c09a65d1651175898735d
-131a310
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
+test_format hash %H%n%h <<EOF
+commit $head2
+$head2
+$head2_7
+commit $head1
+$head1
+$head1_7
 EOF
 
-test_format tree %T%n%t <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-fe722612f26da5064c32ca3843aa154bdb0b08a0
-fe72261
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format tree %T%n%t <<EOF
+commit $head2
+$tree2
+$tree2_7
+commit $head1
 4d5fcadc293a348e88f777dc0920f11e7d71441c
 4d5fcad
 EOF
 
-test_format parents %P%n%p <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format parents %P%n%p <<EOF
+commit $head2
+$head1
+$head2_parent_7
+commit $head1
 
 
 EOF
 
 # we don't test relative here
-test_format author %an%n%ae%n%ad%n%aD%n%at <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format author %an%n%ae%n%ad%n%aD%n%at <<EOF
+commit $head2
 A U Thor
 author@example.com
 Thu Apr 7 15:13:13 2005 -0700
 Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 A U Thor
 author@example.com
 Thu Apr 7 15:13:13 2005 -0700
@@ -69,14 +90,14 @@ Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
 EOF
 
-test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<EOF
+commit $head2
 C O Mitter
 committer@example.com
 Thu Apr 7 15:13:13 2005 -0700
 Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 C O Mitter
 committer@example.com
 Thu Apr 7 15:13:13 2005 -0700
@@ -84,86 +105,105 @@ Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
 EOF
 
-test_format encoding %e <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format encoding %e <<EOF
+commit $head2
+commit $head1
 EOF
 
-test_format subject %s <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-added foo
+expected=$(printf "commit $head2\n\
+$changed\n\
+commit $head1\n\
+$added
+")
+
+test_format subject %s <<EOF
+$expected
 EOF
 
-test_format body %b <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format body %b <<EOF
+commit $head2
+commit $head1
 EOF
 
-test_format raw-body %B <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-changed foo
+expected=$(printf "commit $head2\n\
+$changed\n\
+\n\
+commit $head1\n\
+$added
+")
 
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-added foo
+test_format raw-body %B <<EOF
+$expected
 
 EOF
 
-test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<EOF
+commit $head2
 ^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 ^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
 EOF
 
-test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<EOF
+commit $head2
 ^[[1;31;43mfoo^[[m
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 ^[[1;31;43mfoo^[[m
 EOF
 
-cat >commit-msg <<'EOF'
+iconv -f utf-8 -t cp1251 > commit-msg <<EOF
 Test printing of complex bodies
 
 This commit message is much longer than the others,
-and it will be encoded in iso8859-1. We should therefore
-include an iso8859 character: ¡bueno!
+and it will be encoded in cp1251. We should therefore
+include an cp1251 character: так вот!
 EOF
+
 test_expect_success 'setup complex body' '
-git config i18n.commitencoding iso8859-1 &&
-  echo change2 >foo && git commit -a -F commit-msg
+	git config i18n.commitencoding cp1251 &&
+	echo change2 >foo && git commit -a -F commit-msg &&
+	head3=$(git rev-parse --verify HEAD) &&
+	head3_7=$(echo $head3 | cut -c1-7)
 '
 
-test_format complex-encoding %e <<'EOF'
-commit f58db70b055c5718631e5c61528b28b12090cdea
-iso8859-1
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format complex-encoding %e <<EOF
+commit $head3
+cp1251
+commit $head2
+cp1251
+commit $head1
+cp1251
 EOF
 
-test_format complex-subject %s <<'EOF'
-commit f58db70b055c5718631e5c61528b28b12090cdea
-Test printing of complex bodies
-commit 131a310eb913d107dd3c09a65d1651175898735d
-changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-added foo
+# unset commit encoding config
+# otherwise %e does not print encoding value
+# and following test fails
+git config --unset i18n.commitencoding
+
+expected=$(printf "commit $head3\n\
+Test printing of complex bodies\n\
+commit $head2\n\
+$changed\n\
+commit $head1\n\
+$added
+")
+
+test_format complex-subject %s <<EOF
+$expected
 EOF
 
-test_format complex-body %b <<'EOF'
-commit f58db70b055c5718631e5c61528b28b12090cdea
+test_format complex-body %b <<EOF
+commit $head3
 This commit message is much longer than the others,
-and it will be encoded in iso8859-1. We should therefore
-include an iso8859 character: ¡bueno!
+and it will be encoded in cp1251. We should therefore
+include an cp1251 character: так вот!
 
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head2
+commit $head1
 EOF
 
 test_expect_success '%x00 shows NUL' '
-	echo  >expect commit f58db70b055c5718631e5c61528b28b12090cdea &&
+	echo  >expect commit $head3 &&
 	echo >>expect fooQbar &&
 	git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
 	nul_to_q <actual.nul >actual &&
@@ -210,12 +250,12 @@ test_expect_success 'add LF before non-empty (2)' '
 
 test_expect_success 'add SP before non-empty (1)' '
 	git show -s --pretty=format:"%s% bThanks" HEAD^^ >actual &&
-	test $(wc -w <actual) = 2
+	test $(wc -w <actual) = 3
 '
 
 test_expect_success 'add SP before non-empty (2)' '
 	git show -s --pretty=format:"%s% sThanks" HEAD^^ >actual &&
-	test $(wc -w <actual) = 4
+	test $(wc -w <actual) = 6
 '
 
 test_expect_success '--abbrev' '
-- 
1.7.6.1.g8f21c

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

* [PATCH 2/2] pretty: user format ignores i18n.logOutputEncoding setting
  2011-09-09  8:43         ` [PATCH v2] " Alexey Shumkin
  2011-09-09  8:43           ` [PATCH 1/2] pretty: Add failing tests: " Alexey Shumkin
@ 2011-09-09  8:43           ` Alexey Shumkin
  1 sibling, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2011-09-09  8:43 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin

The following two ought to give the same output to a terminal:

	$ git log --oneline --no-color
	$ git log --pretty=format:'%h %s'

However, the former pays attention to i18n.logOutputEncoding
configuration, while the latter does not when it format "%s". A log
messages written in an encoding i18n.commitEncoding that differs
from terminal encoding are shown corrupted with the latter even
when i18n.logOutputEncoding and terminal encoding are the same.

The same corruption is true for
	$ git diff --submodule=log
and
	$ git rev-list --pretty=format:%s HEAD

Signed-off-by: Alexey Shumkin <zapped@mail.ru>
---
 builtin/rev-list.c |    1 +
 builtin/shortlog.c |    1 +
 log-tree.c         |    1 +
 submodule.c        |    3 +++
 4 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 56727e8..831077d 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -105,6 +105,7 @@ static void show_commit(struct commit *commit, void *data)
 		ctx.abbrev = revs->abbrev;
 		ctx.date_mode = revs->date_mode;
 		ctx.fmt = revs->commit_format;
+		ctx.output_encoding = get_log_output_encoding();
 		pretty_print_commit(&ctx, commit, &buf);
 		if (revs->graph) {
 			if (buf.len) {
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 37f3193..eba4086 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -163,6 +163,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
 		ctx.subject = "";
 		ctx.after_subject = "";
 		ctx.date_mode = DATE_NORMAL;
+		ctx.output_encoding = get_log_output_encoding();
 		pretty_print_commit(&ctx, commit, &ufbuf);
 		buffer = ufbuf.buf;
 	} else if (*buffer) {
diff --git a/log-tree.c b/log-tree.c
index e945701..39913d7 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -488,6 +488,7 @@ void show_log(struct rev_info *opt)
 	ctx.preserve_subject = opt->preserve_subject;
 	ctx.reflog_info = opt->reflog_info;
 	ctx.fmt = opt->commit_format;
+	ctx.output_encoding = get_log_output_encoding();
 	pretty_print_commit(&ctx, commit, &msgbuf);
 
 	if (opt->add_signoff)
diff --git a/submodule.c b/submodule.c
index b6dec70..26efef4 100644
--- a/submodule.c
+++ b/submodule.c
@@ -213,10 +213,13 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
 	static const char format[] = "  %m %s";
 	struct strbuf sb = STRBUF_INIT;
 	struct commit *commit;
+	const char *log_output_encoding;
 
+	log_output_encoding = get_log_output_encoding();
 	while ((commit = get_revision(rev))) {
 		struct pretty_print_context ctx = {0};
 		ctx.date_mode = rev->date_mode;
+		ctx.output_encoding = log_output_encoding;
 		strbuf_setlen(&sb, 0);
 		if (commit->object.flags & SYMMETRIC_LEFT) {
 			if (del)
-- 
1.7.6.1.g8f21c

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

* [PATCH v2] pretty: user format ignores i18n.logOutputEncoding setting
  2011-07-25 19:45       ` Junio C Hamano
  2011-07-26 13:18         ` Alexey Shumkin
  2011-09-09  8:43         ` [PATCH v2] " Alexey Shumkin
@ 2011-09-09  8:53         ` Alexey Shumkin
  2011-09-09  8:53           ` [PATCH 1/2] pretty: Add failing tests: " Alexey Shumkin
  2011-09-09  8:53           ` [PATCH " Alexey Shumkin
  2 siblings, 2 replies; 104+ messages in thread
From: Alexey Shumkin @ 2011-09-09  8:53 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

Ooops! previuos message haven't Cc-ed to Junio.
This one is CC-ed.
I discovered two more commands affected with this bug.
So I reroll this patch and tests for it.

>>(question) Does this change affect other commands, most notably  
>>format-patch, and if so how?
No, it does not affect format-patch

---

 builtin/rev-list.c               |    1 +
 builtin/shortlog.c               |    1 +
 log-tree.c                       |    1 +
 submodule.c                      |    3 +
 t/t4041-diff-submodule-option.sh |   44 +++++----
 t/t4205-log-pretty-formats.sh    |   22 ++++-
 t/t6006-rev-list-format.sh       |  192 +++++++++++++++++++++++---------------
 7 files changed, 167 insertions(+), 97 deletions(-)

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

* [PATCH 1/2] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting
  2011-09-09  8:53         ` [PATCH v2] " Alexey Shumkin
@ 2011-09-09  8:53           ` Alexey Shumkin
  2011-09-09 22:54             ` Junio C Hamano
  2011-09-09  8:53           ` [PATCH " Alexey Shumkin
  1 sibling, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2011-09-09  8:53 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Alexey Shumkin

The following two ought to give the same output to a terminal:

	$ git log --oneline --no-color
	$ git log --pretty=format:'%h %s'

However, the former pays attention to i18n.logOutputEncoding
configuration, while the latter does not when it format "%s". A log
messages written in an encoding i18n.commitEncoding that differs
from terminal encoding are shown corrupted with the latter even
when i18n.logOutputEncoding and terminal encoding are the same.

The same corruption is true for
	$ git diff --submodule=log
and
	$ git rev-list --pretty=format:%s HEAD

Signed-off-by: Alexey Shumkin <zapped@mail.ru>
---
 t/t4041-diff-submodule-option.sh |   44 +++++----
 t/t4205-log-pretty-formats.sh    |   22 ++++-
 t/t6006-rev-list-format.sh       |  192 +++++++++++++++++++++++---------------
 3 files changed, 161 insertions(+), 97 deletions(-)

diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index bf9a752..4460cff 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 #
 # Copyright (c) 2009 Jens Lehmann, based on t7401 by Ping Yin
+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
 #
 
 test_description='Support for verbose submodule differences in git diff
@@ -10,6 +11,7 @@ This test tries to verify the sanity of the --submodule option of git diff.
 
 . ./test-lib.sh
 
+added=$(printf "\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275")
 add_file () {
 	sm=$1
 	shift
@@ -19,8 +21,12 @@ add_file () {
 		echo "$name" > "$name" &&
 		git add "$name" &&
 		test_tick &&
-		git commit -m "Add $name"
+		git config i18n.commitEncoding cp1251 &&
+		echo "Add $name ($added $name)" \
+			| iconv -f utf-8 -t cp1251 \
+			| xargs -I{} git commit -m "{}"
 	done >/dev/null
+	git config --unset i18n.commitEncoding
 	git rev-parse --verify HEAD | cut -c1-7
 	cd "$owd"
 }
@@ -37,7 +43,7 @@ head1=$(add_file sm1 foo1 foo2)
 test_expect_success 'added submodule' "
 	git add sm1 &&
 	git diff-index -p --submodule=log HEAD >actual &&
-	cat >expected <<-EOF &&
+	cat >expected <<EOF
 Submodule sm1 0000000...$head1 (new submodule)
 EOF
 	test_cmp expected actual
@@ -48,27 +54,27 @@ head2=$(add_file sm1 foo3)
 
 test_expect_success 'modified submodule(forward)' "
 	git diff-index -p --submodule=log HEAD >actual &&
-	cat >expected <<-EOF &&
+	cat >expected <<EOF
 Submodule sm1 $head1..$head2:
-  > Add foo3
+  > Add foo3 ($added foo3)
 EOF
 	test_cmp expected actual
 "
 
 test_expect_success 'modified submodule(forward)' "
 	git diff --submodule=log >actual &&
-	cat >expected <<-EOF &&
+	cat >expected <<EOF
 Submodule sm1 $head1..$head2:
-  > Add foo3
+  > Add foo3 ($added foo3)
 EOF
 	test_cmp expected actual
 "
 
 test_expect_success 'modified submodule(forward) --submodule' "
 	git diff --submodule >actual &&
-	cat >expected <<-EOF &&
+	cat >expected <<EOF
 Submodule sm1 $head1..$head2:
-  > Add foo3
+  > Add foo3 ($added foo3)
 EOF
 	test_cmp expected actual
 "
@@ -98,10 +104,10 @@ head3=$(
 
 test_expect_success 'modified submodule(backward)' "
 	git diff-index -p --submodule=log HEAD >actual &&
-	cat >expected <<-EOF &&
+	cat >expected <<EOF
 Submodule sm1 $head2..$head3 (rewind):
-  < Add foo3
-  < Add foo2
+  < Add foo3 ($added foo3)
+  < Add foo2 ($added foo2)
 EOF
 	test_cmp expected actual
 "
@@ -110,12 +116,12 @@ head4=$(add_file sm1 foo4 foo5) &&
 head4_full=$(GIT_DIR=sm1/.git git rev-parse --verify HEAD)
 test_expect_success 'modified submodule(backward and forward)' "
 	git diff-index -p --submodule=log HEAD >actual &&
-	cat >expected <<-EOF &&
+	cat >expected <<EOF
 Submodule sm1 $head2...$head4:
-  > Add foo5
-  > Add foo4
-  < Add foo3
-  < Add foo2
+  > Add foo5 ($added foo5)
+  > Add foo4 ($added foo4)
+  < Add foo3 ($added foo3)
+  < Add foo2 ($added foo2)
 EOF
 	test_cmp expected actual
 "
@@ -131,10 +137,10 @@ mv sm1-bak sm1
 test_expect_success 'typechanged submodule(submodule->blob), --cached' "
 	git diff --submodule=log --cached >actual &&
 	cat >expected <<-EOF &&
-Submodule sm1 41fbea9...0000000 (submodule deleted)
+Submodule sm1 $head4...0000000 (submodule deleted)
 diff --git a/sm1 b/sm1
 new file mode 100644
-index 0000000..9da5fb8
+index 0000000..$head5
 --- /dev/null
 +++ b/sm1
 @@ -0,0 +1 @@
@@ -148,7 +154,7 @@ test_expect_success 'typechanged submodule(submodule->blob)' "
 	cat >expected <<-EOF &&
 diff --git a/sm1 b/sm1
 deleted file mode 100644
-index 9da5fb8..0000000
+index $head5..0000000
 --- a/sm1
 +++ /dev/null
 @@ -1 +0,0 @@
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 2ae9faa..96e0229 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 #
 # Copyright (c) 2010, Will Palmer
+# Copyright (c) 2011, Alexey Shumkin (+ non-UTF-8 commit encoding tests)
 #
 
 test_description='Test pretty formats'
@@ -11,10 +12,13 @@ test_expect_success 'set up basic repos' '
 	>bar &&
 	git add foo &&
 	test_tick &&
-	git commit -m initial &&
+	git config i18n.commitEncoding cp1251 &&
+	printf "initial \320\272\320\276\320\274\320\274\320\270\321\202" \
+		| iconv -f utf-8 -t cp1251 | xargs -I{} git commit -m "{}" &&
 	git add bar &&
 	test_tick &&
-	git commit -m "add bar"
+	git commit -m "add bar" &&
+	git config --unset i18n.commitEncoding
 '
 
 test_expect_success 'alias builtin format' '
@@ -38,6 +42,20 @@ test_expect_success 'alias user-defined format' '
 	test_cmp expected actual
 '
 
+test_expect_success 'alias user-defined tformat with %s (cp1251 encoding)' '
+	git config i18n.logOutputEncoding cp1251 &&
+	git log --oneline >expected-s &&
+	git log --pretty="tformat:%h %s" >actual-s &&
+	git config --unset i18n.logOutputEncoding &&
+	test_cmp expected-s actual-s
+'
+
+test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' '
+	git log --oneline >expected-s &&
+	git log --pretty="tformat:%h %s" >actual-s &&
+	test_cmp expected-s actual-s
+'
+
 test_expect_success 'alias user-defined tformat' '
 	git log --pretty="tformat:%h" >expected &&
 	git config pretty.test-alias "tformat:%h" &&
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index d918cc0..8d99635 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -1,13 +1,34 @@
 #!/bin/sh
 
+# Copyright (c) 2009 Jens Lehmann
+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
+
 test_description='git rev-list --pretty=format test'
 
 . ./test-lib.sh
 
 test_tick
+added=$(printf "added (\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275) foo")
+added_cp1251=$(echo "$added" | iconv -f utf-8 -t cp1251)
+changed=$(printf "changed (\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275) foo")
+changed_cp1251=$(echo "$changed" | iconv -f utf-8 -t cp1251)
+
 test_expect_success 'setup' '
-touch foo && git add foo && git commit -m "added foo" &&
-  echo changed >foo && git commit -a -m "changed foo"
+	touch foo &&
+	git add foo &&
+	git config i18n.commitEncoding cp1251 &&
+	git commit -m "$added_cp1251" &&
+	head1=$(git rev-parse --verify HEAD) &&
+	head1_7=$(echo $head1 | cut -c1-7) &&
+	echo "$changed" > foo &&
+	git commit -a -m "$changed_cp1251" &&
+	head2=$(git rev-parse --verify HEAD) &&
+	head2_7=$(echo $head2 | cut -c1-7) &&
+	tree2=$(git cat-file -p HEAD | grep tree | cut -f 2 -d" ") &&
+	tree2_7=$(echo $tree2 | cut -c1-7) &&
+	head2_parent=$(git cat-file -p HEAD | grep parent | cut -f 2 -d" ") &&
+	head2_parent_7=$(echo $head2_parent | cut -c1-7) &&
+	git config --unset i18n.commitEncoding
 '
 
 # usage: test_format name format_string <expected_output
@@ -19,49 +40,49 @@ test_cmp expect.$1 output.$1
 "
 }
 
-test_format percent %%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format percent %%h <<EOF
+commit $head2
 %h
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 %h
 EOF
 
-test_format hash %H%n%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-131a310eb913d107dd3c09a65d1651175898735d
-131a310
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
+test_format hash %H%n%h <<EOF
+commit $head2
+$head2
+$head2_7
+commit $head1
+$head1
+$head1_7
 EOF
 
-test_format tree %T%n%t <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-fe722612f26da5064c32ca3843aa154bdb0b08a0
-fe72261
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format tree %T%n%t <<EOF
+commit $head2
+$tree2
+$tree2_7
+commit $head1
 4d5fcadc293a348e88f777dc0920f11e7d71441c
 4d5fcad
 EOF
 
-test_format parents %P%n%p <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format parents %P%n%p <<EOF
+commit $head2
+$head1
+$head2_parent_7
+commit $head1
 
 
 EOF
 
 # we don't test relative here
-test_format author %an%n%ae%n%ad%n%aD%n%at <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format author %an%n%ae%n%ad%n%aD%n%at <<EOF
+commit $head2
 A U Thor
 author@example.com
 Thu Apr 7 15:13:13 2005 -0700
 Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 A U Thor
 author@example.com
 Thu Apr 7 15:13:13 2005 -0700
@@ -69,14 +90,14 @@ Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
 EOF
 
-test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<EOF
+commit $head2
 C O Mitter
 committer@example.com
 Thu Apr 7 15:13:13 2005 -0700
 Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 C O Mitter
 committer@example.com
 Thu Apr 7 15:13:13 2005 -0700
@@ -84,86 +105,105 @@ Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
 EOF
 
-test_format encoding %e <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format encoding %e <<EOF
+commit $head2
+commit $head1
 EOF
 
-test_format subject %s <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-added foo
+expected=$(printf "commit $head2\n\
+$changed\n\
+commit $head1\n\
+$added
+")
+
+test_format subject %s <<EOF
+$expected
 EOF
 
-test_format body %b <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format body %b <<EOF
+commit $head2
+commit $head1
 EOF
 
-test_format raw-body %B <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-changed foo
+expected=$(printf "commit $head2\n\
+$changed\n\
+\n\
+commit $head1\n\
+$added
+")
 
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-added foo
+test_format raw-body %B <<EOF
+$expected
 
 EOF
 
-test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<EOF
+commit $head2
 ^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 ^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
 EOF
 
-test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<EOF
+commit $head2
 ^[[1;31;43mfoo^[[m
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 ^[[1;31;43mfoo^[[m
 EOF
 
-cat >commit-msg <<'EOF'
+iconv -f utf-8 -t cp1251 > commit-msg <<EOF
 Test printing of complex bodies
 
 This commit message is much longer than the others,
-and it will be encoded in iso8859-1. We should therefore
-include an iso8859 character: ¡bueno!
+and it will be encoded in cp1251. We should therefore
+include an cp1251 character: так вот!
 EOF
+
 test_expect_success 'setup complex body' '
-git config i18n.commitencoding iso8859-1 &&
-  echo change2 >foo && git commit -a -F commit-msg
+	git config i18n.commitencoding cp1251 &&
+	echo change2 >foo && git commit -a -F commit-msg &&
+	head3=$(git rev-parse --verify HEAD) &&
+	head3_7=$(echo $head3 | cut -c1-7)
 '
 
-test_format complex-encoding %e <<'EOF'
-commit f58db70b055c5718631e5c61528b28b12090cdea
-iso8859-1
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format complex-encoding %e <<EOF
+commit $head3
+cp1251
+commit $head2
+cp1251
+commit $head1
+cp1251
 EOF
 
-test_format complex-subject %s <<'EOF'
-commit f58db70b055c5718631e5c61528b28b12090cdea
-Test printing of complex bodies
-commit 131a310eb913d107dd3c09a65d1651175898735d
-changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-added foo
+# unset commit encoding config
+# otherwise %e does not print encoding value
+# and following test fails
+git config --unset i18n.commitencoding
+
+expected=$(printf "commit $head3\n\
+Test printing of complex bodies\n\
+commit $head2\n\
+$changed\n\
+commit $head1\n\
+$added
+")
+
+test_format complex-subject %s <<EOF
+$expected
 EOF
 
-test_format complex-body %b <<'EOF'
-commit f58db70b055c5718631e5c61528b28b12090cdea
+test_format complex-body %b <<EOF
+commit $head3
 This commit message is much longer than the others,
-and it will be encoded in iso8859-1. We should therefore
-include an iso8859 character: ¡bueno!
+and it will be encoded in cp1251. We should therefore
+include an cp1251 character: так вот!
 
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head2
+commit $head1
 EOF
 
 test_expect_success '%x00 shows NUL' '
-	echo  >expect commit f58db70b055c5718631e5c61528b28b12090cdea &&
+	echo  >expect commit $head3 &&
 	echo >>expect fooQbar &&
 	git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
 	nul_to_q <actual.nul >actual &&
@@ -210,12 +250,12 @@ test_expect_success 'add LF before non-empty (2)' '
 
 test_expect_success 'add SP before non-empty (1)' '
 	git show -s --pretty=format:"%s% bThanks" HEAD^^ >actual &&
-	test $(wc -w <actual) = 2
+	test $(wc -w <actual) = 3
 '
 
 test_expect_success 'add SP before non-empty (2)' '
 	git show -s --pretty=format:"%s% sThanks" HEAD^^ >actual &&
-	test $(wc -w <actual) = 4
+	test $(wc -w <actual) = 6
 '
 
 test_expect_success '--abbrev' '
-- 
1.7.6.1.g8f21c

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

* [PATCH 2/2] pretty: user format ignores i18n.logOutputEncoding setting
  2011-09-09  8:53         ` [PATCH v2] " Alexey Shumkin
  2011-09-09  8:53           ` [PATCH 1/2] pretty: Add failing tests: " Alexey Shumkin
@ 2011-09-09  8:53           ` Alexey Shumkin
  1 sibling, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2011-09-09  8:53 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Alexey Shumkin

The following two ought to give the same output to a terminal:

	$ git log --oneline --no-color
	$ git log --pretty=format:'%h %s'

However, the former pays attention to i18n.logOutputEncoding
configuration, while the latter does not when it format "%s". A log
messages written in an encoding i18n.commitEncoding that differs
from terminal encoding are shown corrupted with the latter even
when i18n.logOutputEncoding and terminal encoding are the same.

The same corruption is true for
	$ git diff --submodule=log
and
	$ git rev-list --pretty=format:%s HEAD

Signed-off-by: Alexey Shumkin <zapped@mail.ru>
---
 builtin/rev-list.c |    1 +
 builtin/shortlog.c |    1 +
 log-tree.c         |    1 +
 submodule.c        |    3 +++
 4 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 56727e8..831077d 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -105,6 +105,7 @@ static void show_commit(struct commit *commit, void *data)
 		ctx.abbrev = revs->abbrev;
 		ctx.date_mode = revs->date_mode;
 		ctx.fmt = revs->commit_format;
+		ctx.output_encoding = get_log_output_encoding();
 		pretty_print_commit(&ctx, commit, &buf);
 		if (revs->graph) {
 			if (buf.len) {
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 37f3193..eba4086 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -163,6 +163,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
 		ctx.subject = "";
 		ctx.after_subject = "";
 		ctx.date_mode = DATE_NORMAL;
+		ctx.output_encoding = get_log_output_encoding();
 		pretty_print_commit(&ctx, commit, &ufbuf);
 		buffer = ufbuf.buf;
 	} else if (*buffer) {
diff --git a/log-tree.c b/log-tree.c
index e945701..39913d7 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -488,6 +488,7 @@ void show_log(struct rev_info *opt)
 	ctx.preserve_subject = opt->preserve_subject;
 	ctx.reflog_info = opt->reflog_info;
 	ctx.fmt = opt->commit_format;
+	ctx.output_encoding = get_log_output_encoding();
 	pretty_print_commit(&ctx, commit, &msgbuf);
 
 	if (opt->add_signoff)
diff --git a/submodule.c b/submodule.c
index b6dec70..26efef4 100644
--- a/submodule.c
+++ b/submodule.c
@@ -213,10 +213,13 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
 	static const char format[] = "  %m %s";
 	struct strbuf sb = STRBUF_INIT;
 	struct commit *commit;
+	const char *log_output_encoding;
 
+	log_output_encoding = get_log_output_encoding();
 	while ((commit = get_revision(rev))) {
 		struct pretty_print_context ctx = {0};
 		ctx.date_mode = rev->date_mode;
+		ctx.output_encoding = log_output_encoding;
 		strbuf_setlen(&sb, 0);
 		if (commit->object.flags & SYMMETRIC_LEFT) {
 			if (del)
-- 
1.7.6.1.g8f21c

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

* Re: [PATCH 1/2] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting
  2011-09-09  8:53           ` [PATCH 1/2] pretty: Add failing tests: " Alexey Shumkin
@ 2011-09-09 22:54             ` Junio C Hamano
  2011-09-20  8:20               ` [PATCH v3 0/2] pretty: " Alexey Shumkin
                                 ` (2 more replies)
  0 siblings, 3 replies; 104+ messages in thread
From: Junio C Hamano @ 2011-09-09 22:54 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git

Alexey Shumkin <zapped@mail.ru> writes:

> The following two ought to give the same output to a terminal:
>
> 	$ git log --oneline --no-color
> 	$ git log --pretty=format:'%h %s'
>
> However, the former pays attention to i18n.logOutputEncoding
> configuration, while the latter does not when it format "%s". A log
> messages written in an encoding i18n.commitEncoding that differs
> from terminal encoding are shown corrupted with the latter even
> when i18n.logOutputEncoding and terminal encoding are the same.

You seem to have inherited bad grammar from some example; I wonder
where... ;-)

> @@ -19,8 +21,12 @@ add_file () {
>  		echo "$name" > "$name" &&
>  		git add "$name" &&
>  		test_tick &&
> -		git commit -m "Add $name"
> +		git config i18n.commitEncoding cp1251 &&
> +		echo "Add $name ($added $name)" \
> +			| iconv -f utf-8 -t cp1251 \
> +			| xargs -I{} git commit -m "{}"

Don't do this. Format it this way instead if you want to use multi-line:

	echo "..." |
        iconv ... |
        xargs ...

I also am not sure if -I{} in xargs is all that portable. Why isn't it
more like this, which would be far easier to read?

	msg_in_cp1251=$(echo "Add ..." | iconv ...) &&
        git commit -m "$msg_in_cp1251" &&
        ...

Also do not break the && chain.

>  	done >/dev/null
> +	git config --unset i18n.commitEncoding
>  	git rev-parse --verify HEAD | cut -c1-7
>  	cd "$owd"
>  }

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

* [PATCH v3 0/2] pretty: user format ignores i18n.logOutputEncoding setting
  2011-09-09 22:54             ` Junio C Hamano
@ 2011-09-20  8:20               ` Alexey Shumkin
  2011-09-20  8:21               ` [PATCH v3 1/2] pretty: Add failing tests: " Alexey Shumkin
  2011-09-20  8:21               ` [PATCH v3 2/2] " Alexey Shumkin
  2 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2011-09-20  8:20 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

>>You seem to have inherited bad grammar from some example; I wonder
>>where... ;-)
I rephrased... I made an attempt to as least ;)

>>Format it this way instead if you want to use multi-line:
>>	echo "..." |
>>    iconv ... |
>>    xargs ...
done

Alexey Shumkin (2):
  pretty: Add failing tests: user format ignores i18n.logOutputEncoding
    setting
  pretty: user format ignores i18n.logOutputEncoding setting

 builtin/rev-list.c               |    1 +
 builtin/shortlog.c               |    1 +
 log-tree.c                       |    1 +
 submodule.c                      |    3 +
 t/t4041-diff-submodule-option.sh |   56 ++++++------
 t/t4205-log-pretty-formats.sh    |   22 ++++-
 t/t6006-rev-list-format.sh       |  192 +++++++++++++++++++++++---------------
 7 files changed, 170 insertions(+), 106 deletions(-)

-- 
1.7.6.3.4.gf71f

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

* [PATCH v3 1/2] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting
  2011-09-09 22:54             ` Junio C Hamano
  2011-09-20  8:20               ` [PATCH v3 0/2] pretty: " Alexey Shumkin
@ 2011-09-20  8:21               ` Alexey Shumkin
  2011-09-20 19:12                 ` Junio C Hamano
  2011-09-20  8:21               ` [PATCH v3 2/2] " Alexey Shumkin
  2 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2011-09-20  8:21 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

The following two commands are expected to give the same output to a terminal:

	$ git log --oneline --no-color
	$ git log --pretty=format:'%h %s'

However, the former pays attention to i18n.logOutputEncoding
configuration, while the latter does not when it format "%s".
Log messages written in an encoding i18n.commitEncoding which differs
from terminal encoding are shown corrupted with the latter even
when i18n.logOutputEncoding and terminal encoding are the same.

The same corruption is true for
	$ git diff --submodule=log
and
	$ git rev-list --pretty=format:%s HEAD

Signed-off-by: Alexey Shumkin <zapped@mail.ru>
---
 t/t4041-diff-submodule-option.sh |   56 ++++++------
 t/t4205-log-pretty-formats.sh    |   22 ++++-
 t/t6006-rev-list-format.sh       |  192 +++++++++++++++++++++++---------------
 3 files changed, 164 insertions(+), 106 deletions(-)

diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index bf9a752..b0cec5e 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 #
 # Copyright (c) 2009 Jens Lehmann, based on t7401 by Ping Yin
+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
 #
 
 test_description='Support for verbose submodule differences in git diff
@@ -10,6 +11,7 @@ This test tries to verify the sanity of the --submodule option of git diff.
 
 . ./test-lib.sh
 
+added=$(printf "\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275")
 add_file () {
 	sm=$1
 	shift
@@ -19,8 +21,11 @@ add_file () {
 		echo "$name" > "$name" &&
 		git add "$name" &&
 		test_tick &&
-		git commit -m "Add $name"
+		msg_added_cp1251=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t cp1251) && 
+		git config i18n.commitEncoding cp1251 &&
+		git commit -m "$msg_added_cp1251"
 	done >/dev/null
+	git config --unset i18n.commitEncoding
 	git rev-parse --verify HEAD | cut -c1-7
 	cd "$owd"
 }
@@ -48,28 +53,25 @@ head2=$(add_file sm1 foo3)
 
 test_expect_success 'modified submodule(forward)' "
 	git diff-index -p --submodule=log HEAD >actual &&
-	cat >expected <<-EOF &&
-Submodule sm1 $head1..$head2:
-  > Add foo3
-EOF
+	printf \"Submodule sm1 $head1..$head2:\n\
+  > Add foo3 ($added foo3)\n\
+\" > expected &&
 	test_cmp expected actual
 "
 
 test_expect_success 'modified submodule(forward)' "
 	git diff --submodule=log >actual &&
-	cat >expected <<-EOF &&
-Submodule sm1 $head1..$head2:
-  > Add foo3
-EOF
+	printf \"Submodule sm1 $head1..$head2:\n\
+  > Add foo3 ($added foo3)\n\
+\" > expected &&
 	test_cmp expected actual
 "
 
 test_expect_success 'modified submodule(forward) --submodule' "
 	git diff --submodule >actual &&
-	cat >expected <<-EOF &&
-Submodule sm1 $head1..$head2:
-  > Add foo3
-EOF
+	printf \"Submodule sm1 $head1..$head2:\n\
+  > Add foo3 ($added foo3)\n\
+\" > expected &&
 	test_cmp expected actual
 "
 
@@ -98,11 +100,10 @@ head3=$(
 
 test_expect_success 'modified submodule(backward)' "
 	git diff-index -p --submodule=log HEAD >actual &&
-	cat >expected <<-EOF &&
-Submodule sm1 $head2..$head3 (rewind):
-  < Add foo3
-  < Add foo2
-EOF
+	printf \"Submodule sm1 $head2..$head3 (rewind):\n\
+  < Add foo3 ($added foo3)\n\
+  < Add foo2 ($added foo2)\n\
+\" > expected &&
 	test_cmp expected actual
 "
 
@@ -110,13 +111,12 @@ head4=$(add_file sm1 foo4 foo5) &&
 head4_full=$(GIT_DIR=sm1/.git git rev-parse --verify HEAD)
 test_expect_success 'modified submodule(backward and forward)' "
 	git diff-index -p --submodule=log HEAD >actual &&
-	cat >expected <<-EOF &&
-Submodule sm1 $head2...$head4:
-  > Add foo5
-  > Add foo4
-  < Add foo3
-  < Add foo2
-EOF
+	printf \"Submodule sm1 $head2...$head4:\n\
+  > Add foo5 ($added foo5)\n\
+  > Add foo4 ($added foo4)\n\
+  < Add foo3 ($added foo3)\n\
+  < Add foo2 ($added foo2)\n\
+\" > expected &&
 	test_cmp expected actual
 "
 
@@ -131,10 +131,10 @@ mv sm1-bak sm1
 test_expect_success 'typechanged submodule(submodule->blob), --cached' "
 	git diff --submodule=log --cached >actual &&
 	cat >expected <<-EOF &&
-Submodule sm1 41fbea9...0000000 (submodule deleted)
+Submodule sm1 $head4...0000000 (submodule deleted)
 diff --git a/sm1 b/sm1
 new file mode 100644
-index 0000000..9da5fb8
+index 0000000..$head5
 --- /dev/null
 +++ b/sm1
 @@ -0,0 +1 @@
@@ -148,7 +148,7 @@ test_expect_success 'typechanged submodule(submodule->blob)' "
 	cat >expected <<-EOF &&
 diff --git a/sm1 b/sm1
 deleted file mode 100644
-index 9da5fb8..0000000
+index $head5..0000000
 --- a/sm1
 +++ /dev/null
 @@ -1 +0,0 @@
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 2ae9faa..9da6835 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 #
 # Copyright (c) 2010, Will Palmer
+# Copyright (c) 2011, Alexey Shumkin (+ non-UTF-8 commit encoding tests)
 #
 
 test_description='Test pretty formats'
@@ -11,10 +12,13 @@ test_expect_success 'set up basic repos' '
 	>bar &&
 	git add foo &&
 	test_tick &&
-	git commit -m initial &&
+	git config i18n.commitEncoding cp1251 &&
+	msg_commit_cp1251=$(printf "initial \320\272\320\276\320\274\320\274\320\270\321\202" | iconv -f utf-8 -t cp1251) &&
+	git commit -m "$msg_commit_cp1251" &&
 	git add bar &&
 	test_tick &&
-	git commit -m "add bar"
+	git commit -m "add bar" &&
+	git config --unset i18n.commitEncoding
 '
 
 test_expect_success 'alias builtin format' '
@@ -38,6 +42,20 @@ test_expect_success 'alias user-defined format' '
 	test_cmp expected actual
 '
 
+test_expect_success 'alias user-defined tformat with %s (cp1251 encoding)' '
+	git config i18n.logOutputEncoding cp1251 &&
+	git log --oneline >expected-s &&
+	git log --pretty="tformat:%h %s" >actual-s &&
+	git config --unset i18n.logOutputEncoding &&
+	test_cmp expected-s actual-s
+'
+
+test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' '
+	git log --oneline >expected-s &&
+	git log --pretty="tformat:%h %s" >actual-s &&
+	test_cmp expected-s actual-s
+'
+
 test_expect_success 'alias user-defined tformat' '
 	git log --pretty="tformat:%h" >expected &&
 	git config pretty.test-alias "tformat:%h" &&
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index d918cc0..8d99635 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -1,13 +1,34 @@
 #!/bin/sh
 
+# Copyright (c) 2009 Jens Lehmann
+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
+
 test_description='git rev-list --pretty=format test'
 
 . ./test-lib.sh
 
 test_tick
+added=$(printf "added (\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275) foo")
+added_cp1251=$(echo "$added" | iconv -f utf-8 -t cp1251)
+changed=$(printf "changed (\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275) foo")
+changed_cp1251=$(echo "$changed" | iconv -f utf-8 -t cp1251)
+
 test_expect_success 'setup' '
-touch foo && git add foo && git commit -m "added foo" &&
-  echo changed >foo && git commit -a -m "changed foo"
+	touch foo &&
+	git add foo &&
+	git config i18n.commitEncoding cp1251 &&
+	git commit -m "$added_cp1251" &&
+	head1=$(git rev-parse --verify HEAD) &&
+	head1_7=$(echo $head1 | cut -c1-7) &&
+	echo "$changed" > foo &&
+	git commit -a -m "$changed_cp1251" &&
+	head2=$(git rev-parse --verify HEAD) &&
+	head2_7=$(echo $head2 | cut -c1-7) &&
+	tree2=$(git cat-file -p HEAD | grep tree | cut -f 2 -d" ") &&
+	tree2_7=$(echo $tree2 | cut -c1-7) &&
+	head2_parent=$(git cat-file -p HEAD | grep parent | cut -f 2 -d" ") &&
+	head2_parent_7=$(echo $head2_parent | cut -c1-7) &&
+	git config --unset i18n.commitEncoding
 '
 
 # usage: test_format name format_string <expected_output
@@ -19,49 +40,49 @@ test_cmp expect.$1 output.$1
 "
 }
 
-test_format percent %%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format percent %%h <<EOF
+commit $head2
 %h
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 %h
 EOF
 
-test_format hash %H%n%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-131a310eb913d107dd3c09a65d1651175898735d
-131a310
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
+test_format hash %H%n%h <<EOF
+commit $head2
+$head2
+$head2_7
+commit $head1
+$head1
+$head1_7
 EOF
 
-test_format tree %T%n%t <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-fe722612f26da5064c32ca3843aa154bdb0b08a0
-fe72261
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format tree %T%n%t <<EOF
+commit $head2
+$tree2
+$tree2_7
+commit $head1
 4d5fcadc293a348e88f777dc0920f11e7d71441c
 4d5fcad
 EOF
 
-test_format parents %P%n%p <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format parents %P%n%p <<EOF
+commit $head2
+$head1
+$head2_parent_7
+commit $head1
 
 
 EOF
 
 # we don't test relative here
-test_format author %an%n%ae%n%ad%n%aD%n%at <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format author %an%n%ae%n%ad%n%aD%n%at <<EOF
+commit $head2
 A U Thor
 author@example.com
 Thu Apr 7 15:13:13 2005 -0700
 Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 A U Thor
 author@example.com
 Thu Apr 7 15:13:13 2005 -0700
@@ -69,14 +90,14 @@ Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
 EOF
 
-test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<EOF
+commit $head2
 C O Mitter
 committer@example.com
 Thu Apr 7 15:13:13 2005 -0700
 Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 C O Mitter
 committer@example.com
 Thu Apr 7 15:13:13 2005 -0700
@@ -84,86 +105,105 @@ Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
 EOF
 
-test_format encoding %e <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format encoding %e <<EOF
+commit $head2
+commit $head1
 EOF
 
-test_format subject %s <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-added foo
+expected=$(printf "commit $head2\n\
+$changed\n\
+commit $head1\n\
+$added
+")
+
+test_format subject %s <<EOF
+$expected
 EOF
 
-test_format body %b <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format body %b <<EOF
+commit $head2
+commit $head1
 EOF
 
-test_format raw-body %B <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-changed foo
+expected=$(printf "commit $head2\n\
+$changed\n\
+\n\
+commit $head1\n\
+$added
+")
 
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-added foo
+test_format raw-body %B <<EOF
+$expected
 
 EOF
 
-test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<EOF
+commit $head2
 ^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 ^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
 EOF
 
-test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<EOF
+commit $head2
 ^[[1;31;43mfoo^[[m
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 ^[[1;31;43mfoo^[[m
 EOF
 
-cat >commit-msg <<'EOF'
+iconv -f utf-8 -t cp1251 > commit-msg <<EOF
 Test printing of complex bodies
 
 This commit message is much longer than the others,
-and it will be encoded in iso8859-1. We should therefore
-include an iso8859 character: ¡bueno!
+and it will be encoded in cp1251. We should therefore
+include an cp1251 character: так вот!
 EOF
+
 test_expect_success 'setup complex body' '
-git config i18n.commitencoding iso8859-1 &&
-  echo change2 >foo && git commit -a -F commit-msg
+	git config i18n.commitencoding cp1251 &&
+	echo change2 >foo && git commit -a -F commit-msg &&
+	head3=$(git rev-parse --verify HEAD) &&
+	head3_7=$(echo $head3 | cut -c1-7)
 '
 
-test_format complex-encoding %e <<'EOF'
-commit f58db70b055c5718631e5c61528b28b12090cdea
-iso8859-1
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format complex-encoding %e <<EOF
+commit $head3
+cp1251
+commit $head2
+cp1251
+commit $head1
+cp1251
 EOF
 
-test_format complex-subject %s <<'EOF'
-commit f58db70b055c5718631e5c61528b28b12090cdea
-Test printing of complex bodies
-commit 131a310eb913d107dd3c09a65d1651175898735d
-changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-added foo
+# unset commit encoding config
+# otherwise %e does not print encoding value
+# and following test fails
+git config --unset i18n.commitencoding
+
+expected=$(printf "commit $head3\n\
+Test printing of complex bodies\n\
+commit $head2\n\
+$changed\n\
+commit $head1\n\
+$added
+")
+
+test_format complex-subject %s <<EOF
+$expected
 EOF
 
-test_format complex-body %b <<'EOF'
-commit f58db70b055c5718631e5c61528b28b12090cdea
+test_format complex-body %b <<EOF
+commit $head3
 This commit message is much longer than the others,
-and it will be encoded in iso8859-1. We should therefore
-include an iso8859 character: ¡bueno!
+and it will be encoded in cp1251. We should therefore
+include an cp1251 character: так вот!
 
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head2
+commit $head1
 EOF
 
 test_expect_success '%x00 shows NUL' '
-	echo  >expect commit f58db70b055c5718631e5c61528b28b12090cdea &&
+	echo  >expect commit $head3 &&
 	echo >>expect fooQbar &&
 	git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
 	nul_to_q <actual.nul >actual &&
@@ -210,12 +250,12 @@ test_expect_success 'add LF before non-empty (2)' '
 
 test_expect_success 'add SP before non-empty (1)' '
 	git show -s --pretty=format:"%s% bThanks" HEAD^^ >actual &&
-	test $(wc -w <actual) = 2
+	test $(wc -w <actual) = 3
 '
 
 test_expect_success 'add SP before non-empty (2)' '
 	git show -s --pretty=format:"%s% sThanks" HEAD^^ >actual &&
-	test $(wc -w <actual) = 4
+	test $(wc -w <actual) = 6
 '
 
 test_expect_success '--abbrev' '
-- 
1.7.6.3.4.gf71f

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

* [PATCH v3 2/2] pretty: user format ignores i18n.logOutputEncoding setting
  2011-09-09 22:54             ` Junio C Hamano
  2011-09-20  8:20               ` [PATCH v3 0/2] pretty: " Alexey Shumkin
  2011-09-20  8:21               ` [PATCH v3 1/2] pretty: Add failing tests: " Alexey Shumkin
@ 2011-09-20  8:21               ` Alexey Shumkin
  2 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2011-09-20  8:21 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

The following two commands are expected to give the same output to a terminal:

	$ git log --oneline --no-color
	$ git log --pretty=format:'%h %s'

However, the former pays attention to i18n.logOutputEncoding
configuration, while the latter does not when it format "%s".
Log messages written in an encoding i18n.commitEncoding which differs
from terminal encoding are shown corrupted with the latter even
when i18n.logOutputEncoding and terminal encoding are the same.

The same corruption is true for
	$ git diff --submodule=log
and
	$ git rev-list --pretty=format:%s HEAD

Signed-off-by: Alexey Shumkin <zapped@mail.ru>
---
 builtin/rev-list.c |    1 +
 builtin/shortlog.c |    1 +
 log-tree.c         |    1 +
 submodule.c        |    3 +++
 4 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 56727e8..831077d 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -105,6 +105,7 @@ static void show_commit(struct commit *commit, void *data)
 		ctx.abbrev = revs->abbrev;
 		ctx.date_mode = revs->date_mode;
 		ctx.fmt = revs->commit_format;
+		ctx.output_encoding = get_log_output_encoding();
 		pretty_print_commit(&ctx, commit, &buf);
 		if (revs->graph) {
 			if (buf.len) {
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 37f3193..eba4086 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -163,6 +163,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
 		ctx.subject = "";
 		ctx.after_subject = "";
 		ctx.date_mode = DATE_NORMAL;
+		ctx.output_encoding = get_log_output_encoding();
 		pretty_print_commit(&ctx, commit, &ufbuf);
 		buffer = ufbuf.buf;
 	} else if (*buffer) {
diff --git a/log-tree.c b/log-tree.c
index e945701..39913d7 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -488,6 +488,7 @@ void show_log(struct rev_info *opt)
 	ctx.preserve_subject = opt->preserve_subject;
 	ctx.reflog_info = opt->reflog_info;
 	ctx.fmt = opt->commit_format;
+	ctx.output_encoding = get_log_output_encoding();
 	pretty_print_commit(&ctx, commit, &msgbuf);
 
 	if (opt->add_signoff)
diff --git a/submodule.c b/submodule.c
index b648927..8c96de7 100644
--- a/submodule.c
+++ b/submodule.c
@@ -213,10 +213,13 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
 	static const char format[] = "  %m %s";
 	struct strbuf sb = STRBUF_INIT;
 	struct commit *commit;
+	const char *log_output_encoding;
 
+	log_output_encoding = get_log_output_encoding();
 	while ((commit = get_revision(rev))) {
 		struct pretty_print_context ctx = {0};
 		ctx.date_mode = rev->date_mode;
+		ctx.output_encoding = log_output_encoding;
 		strbuf_setlen(&sb, 0);
 		if (commit->object.flags & SYMMETRIC_LEFT) {
 			if (del)
-- 
1.7.6.3.4.gf71f

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

* Re: [PATCH v3 1/2] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting
  2011-09-20  8:21               ` [PATCH v3 1/2] pretty: Add failing tests: " Alexey Shumkin
@ 2011-09-20 19:12                 ` Junio C Hamano
  2011-09-20 20:46                   ` Alexey Shumkin
  0 siblings, 1 reply; 104+ messages in thread
From: Junio C Hamano @ 2011-09-20 19:12 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git

Alexey Shumkin <zapped@mail.ru> writes:

> diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
> ...
> @@ -48,28 +53,25 @@ head2=$(add_file sm1 foo3)
>  
>  test_expect_success 'modified submodule(forward)' "

As this is [PATCH 1/2], doesn't this patch make this test fail, calling
for test_expect_failure here (and then later in 2/2 to be flipped back to
test_expect_success)?

>  	git diff-index -p --submodule=log HEAD >actual &&
> -	cat >expected <<-EOF &&
> -Submodule sm1 $head1..$head2:
> -  > Add foo3
> -EOF
> +	printf \"Submodule sm1 $head1..$head2:\n\
> +  > Add foo3 ($added foo3)\n\
> +\" > expected &&
>  	test_cmp expected actual
>  "

Hmmm... why printf?  Is it worth to force reviewers wonder what would
happen if any of these $variables happened to have "%" in them?  Are you
benefiting from any printf features that you cannot achieve with the
original cat?

This hunk and others throughout your patch that change cat with here doc
into printf seem to make the tests less legible, at least to me.

Perhaps like this instead, if the "flushed left" of the original looked
ugly to your eyes?

@@ -49,27 +54,25 @@ head2=$(add_file sm1 foo3)
 test_expect_success 'modified submodule(forward)' "
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
-Submodule sm1 $head1..$head2:
-  > Add foo3
-EOF
+	Submodule sm1 $head1..$head2:
+	  > Add foo3 ($added foo3)
+	EOF
 	test_cmp expected actual
 "

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

* Re: [PATCH v3 1/2] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting
  2011-09-20 19:12                 ` Junio C Hamano
@ 2011-09-20 20:46                   ` Alexey Shumkin
  2013-01-24  9:10                     ` [PATCH v4 0/4] Reroll patches against v1.8.1.1 Alexey Shumkin
                                       ` (4 more replies)
  0 siblings, 5 replies; 104+ messages in thread
From: Alexey Shumkin @ 2011-09-20 20:46 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

> Alexey Shumkin <zapped@mail.ru> writes:
> 
> > diff --git a/t/t4041-diff-submodule-option.sh
> > b/t/t4041-diff-submodule-option.sh ...
> > @@ -48,28 +53,25 @@ head2=$(add_file sm1 foo3)
> >  
> >  test_expect_success 'modified submodule(forward)' "
> 
> As this is [PATCH 1/2], doesn't this patch make this test fail,
> calling for test_expect_failure here (and then later in 2/2 to be
> flipped back to test_expect_success)?
I did not know how is right.
AFAIK, XP way tells to write failing tests and then 
patch/fix the code to pass them.

Here, As I understand now all tests must be successful
The difference is in expectation of failure or success.
Ok. I got it and I will reroll the patches.
> 
> >  	git diff-index -p --submodule=log HEAD >actual &&
> > -	cat >expected <<-EOF &&
> > -Submodule sm1 $head1..$head2:
> > -  > Add foo3
> > -EOF
> > +	printf \"Submodule sm1 $head1..$head2:\n\
> > +  > Add foo3 ($added foo3)\n\
> > +\" > expected &&
> >  	test_cmp expected actual
> >  "
> 
> Hmmm... why printf?  Is it worth to force reviewers wonder what would
> happen if any of these $variables happened to have "%" in them?  Are
> you benefiting from any printf features that you cannot achieve with
> the original cat?
This is a remained from v1 patch code. It is not required now.
I'll fix it. Thanks. 

> This hunk and others throughout your patch that change cat with here
> doc into printf seem to make the tests less legible, at least to me.
> 
> Perhaps like this instead, if the "flushed left" of the original
> looked ugly to your eyes?
No, the reason was not in "flushed left". And, BTW, this code generates
expected output that has predefined format...
> 
> @@ -49,27 +54,25 @@ head2=$(add_file sm1 foo3)
>  test_expect_success 'modified submodule(forward)' "
>  	git diff-index -p --submodule=log HEAD >actual &&
>  	cat >expected <<-EOF &&
> -Submodule sm1 $head1..$head2:
> -  > Add foo3
> -EOF
> +	Submodule sm1 $head1..$head2:
> +	  > Add foo3 ($added foo3)
> +	EOF
>  	test_cmp expected actual
>  "
> 
-- 
С уважением, Алексей Шумкин
Программист компании 1С-Рарус
E-mail: ashu@rarus.ru
ICQ: 118001447
Jabber (GoogleTalk): ashu@rarus.ru
Skype: crezoff

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

* [PATCH v4 0/4] Reroll patches against v1.8.1.1
  2011-09-20 20:46                   ` Alexey Shumkin
@ 2013-01-24  9:10                     ` Alexey Shumkin
  2013-06-20  9:26                       ` [PATCH v5 0/5] Reroll patches against v1.8.3.1 Alexey Shumkin
                                         ` (5 more replies)
  2013-01-24  9:10                     ` [PATCH v4 1/4] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
                                       ` (3 subsequent siblings)
  4 siblings, 6 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-01-24  9:10 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

Woooof! 
Reroll my patches again after 1.5 years ;)
They must be applied against v1.8.1.1
Sorry for my laziness ;)

Alexey Shumkin (4):
  t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
  t7102 (reset): refactoring: don't hardcode SHA-1 in expected outputs
  pretty: Add failing tests: user format ignores i18n.logOutputEncoding
    setting
  pretty: user format ignores i18n.logOutputEncoding setting

 builtin/reset.c                  |   8 +-
 builtin/rev-list.c               |   1 +
 builtin/shortlog.c               |   1 +
 log-tree.c                       |   1 +
 submodule.c                      |   3 +
 t/t4041-diff-submodule-option.sh |  23 +++--
 t/t4205-log-pretty-formats.sh    |  37 ++++++--
 t/t6006-rev-list-format.sh       | 200 +++++++++++++++++++++++----------------
 t/t7102-reset.sh                 |  71 +++++++++-----
 9 files changed, 224 insertions(+), 121 deletions(-)

-- 
1.8.1.1.10.g9255f3f

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

* [PATCH v4 1/4] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
  2011-09-20 20:46                   ` Alexey Shumkin
  2013-01-24  9:10                     ` [PATCH v4 0/4] Reroll patches against v1.8.1.1 Alexey Shumkin
@ 2013-01-24  9:10                     ` Alexey Shumkin
  2013-01-24 20:29                       ` Junio C Hamano
  2013-01-24  9:10                     ` [PATCH v4 2/4] t7102 (reset): refactoring: " Alexey Shumkin
                                       ` (2 subsequent siblings)
  4 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-01-24  9:10 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

The expected SHA-1 digests are always available in variables.  Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 t/t6006-rev-list-format.sh | 130 +++++++++++++++++++++++++--------------------
 1 file changed, 72 insertions(+), 58 deletions(-)

diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index f94f0c4..c248509 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -6,8 +6,19 @@ test_description='git rev-list --pretty=format test'
 
 test_tick
 test_expect_success 'setup' '
-touch foo && git add foo && git commit -m "added foo" &&
-  echo changed >foo && git commit -a -m "changed foo"
+	touch foo &&
+	git add foo &&
+	git commit -m "added foo" &&
+	head1=$(git rev-parse --verify HEAD) &&
+	head1_7=$(echo $head1 | cut -c1-7) &&
+	echo changed >foo &&
+	git commit -a -m "changed foo" &&
+	head2=$(git rev-parse --verify HEAD) &&
+	head2_7=$(echo $head2 | cut -c1-7) &&
+	head2_parent=$(git cat-file -p HEAD | grep parent | cut -f 2 -d" ") &&
+	head2_parent_7=$(echo $head2_parent | cut -c1-7) &&
+	tree2=$(git cat-file -p HEAD | grep tree | cut -f 2 -d" ") &&
+	tree2_7=$(echo $tree2 | cut -c1-7)
 '
 
 # usage: test_format name format_string <expected_output
@@ -19,49 +30,49 @@ test_cmp expect.$1 output.$1
 "
 }
 
-test_format percent %%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format percent %%h <<EOF
+commit $head2
 %h
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 %h
 EOF
 
-test_format hash %H%n%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-131a310eb913d107dd3c09a65d1651175898735d
-131a310
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
+test_format hash %H%n%h <<EOF
+commit $head2
+$head2
+$head2_7
+commit $head1
+$head1
+$head1_7
 EOF
 
-test_format tree %T%n%t <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-fe722612f26da5064c32ca3843aa154bdb0b08a0
-fe72261
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format tree %T%n%t <<EOF
+commit $head2
+$tree2
+$tree2_7
+commit $head1
 4d5fcadc293a348e88f777dc0920f11e7d71441c
 4d5fcad
 EOF
 
-test_format parents %P%n%p <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format parents %P%n%p <<EOF
+commit $head2
+$head1
+$head2_parent_7
+commit $head1
 
 
 EOF
 
 # we don't test relative here
-test_format author %an%n%ae%n%ad%n%aD%n%at <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format author %an%n%ae%n%ad%n%aD%n%at <<EOF
+commit $head2
 A U Thor
 author@example.com
 Thu Apr 7 15:13:13 2005 -0700
 Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 A U Thor
 author@example.com
 Thu Apr 7 15:13:13 2005 -0700
@@ -69,14 +80,14 @@ Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
 EOF
 
-test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<EOF
+commit $head2
 C O Mitter
 committer@example.com
 Thu Apr 7 15:13:13 2005 -0700
 Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 C O Mitter
 committer@example.com
 Thu Apr 7 15:13:13 2005 -0700
@@ -84,21 +95,21 @@ Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
 EOF
 
-test_format encoding %e <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format encoding %e <<EOF
+commit $head2
+commit $head1
 EOF
 
-test_format subject %s <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format subject %s <<EOF
+commit $head2
 changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 added foo
 EOF
 
-test_format body %b <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format body %b <<EOF
+commit $head2
+commit $head1
 EOF
 
 test_format raw-body %B <<'EOF'
@@ -110,17 +121,17 @@ added foo
 
 EOF
 
-test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<EOF
+commit $head2
 ^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 ^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
 EOF
 
-test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<EOF
+commit $head2
 ^[[1;31;43mfoo^[[m
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 ^[[1;31;43mfoo^[[m
 EOF
 
@@ -131,39 +142,42 @@ This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
 include an iso8859 character: ¡bueno!
 EOF
+
 test_expect_success 'setup complex body' '
-git config i18n.commitencoding iso8859-1 &&
-  echo change2 >foo && git commit -a -F commit-msg
+	git config i18n.commitencoding iso8859-1 &&
+	echo change2 >foo && git commit -a -F commit-msg &&
+	head3=$(git rev-parse --verify HEAD) &&
+	head3_7=$(echo $head3 | cut -c1-7)
 '
 
-test_format complex-encoding %e <<'EOF'
-commit f58db70b055c5718631e5c61528b28b12090cdea
+test_format complex-encoding %e <<EOF
+commit $head3
 iso8859-1
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head2
+commit $head1
 EOF
 
-test_format complex-subject %s <<'EOF'
-commit f58db70b055c5718631e5c61528b28b12090cdea
+test_format complex-subject %s <<EOF
+commit $head3
 Test printing of complex bodies
-commit 131a310eb913d107dd3c09a65d1651175898735d
+commit $head2
 changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 added foo
 EOF
 
-test_format complex-body %b <<'EOF'
-commit f58db70b055c5718631e5c61528b28b12090cdea
+test_format complex-body %b <<EOF
+commit $head3
 This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
 include an iso8859 character: ¡bueno!
 
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head2
+commit $head1
 EOF
 
 test_expect_success '%x00 shows NUL' '
-	echo  >expect commit f58db70b055c5718631e5c61528b28b12090cdea &&
+	echo  >expect commit $head3 &&
 	echo >>expect fooQbar &&
 	git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
 	nul_to_q <actual.nul >actual &&
-- 
1.8.1.1.10.g9255f3f

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

* [PATCH v4 2/4] t7102 (reset): refactoring: don't hardcode SHA-1 in expected outputs
  2011-09-20 20:46                   ` Alexey Shumkin
  2013-01-24  9:10                     ` [PATCH v4 0/4] Reroll patches against v1.8.1.1 Alexey Shumkin
  2013-01-24  9:10                     ` [PATCH v4 1/4] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
@ 2013-01-24  9:10                     ` Alexey Shumkin
  2013-01-24 20:30                       ` Junio C Hamano
  2013-01-24  9:10                     ` [PATCH v4 3/4] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting Alexey Shumkin
  2013-01-24  9:10                     ` [PATCH v4 4/4] pretty: " Alexey Shumkin
  4 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-01-24  9:10 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

The expected SHA-1 digests are always available in variables.  Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 t/t7102-reset.sh | 41 +++++++++++++++++++++--------------------
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index b096dc8..cf492f4 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -28,7 +28,8 @@ test_expect_success 'creating initial files and commits' '
 
 	echo "1st line 2nd file" >secondfile &&
 	echo "2nd line 2nd file" >>secondfile &&
-	git commit -a -m "modify 2nd file"
+	git commit -a -m "modify 2nd file" &&
+	head5=$(git rev-parse --verify HEAD)
 '
 # git log --pretty=oneline # to see those SHA1 involved
 
@@ -56,7 +57,7 @@ test_expect_success 'giving a non existing revision should fail' '
 	test_must_fail git reset --mixed aaaaaa &&
 	test_must_fail git reset --soft aaaaaa &&
 	test_must_fail git reset --hard aaaaaa &&
-	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
+	check_changes $head5
 '
 
 test_expect_success 'reset --soft with unmerged index should fail' '
@@ -74,7 +75,7 @@ test_expect_success \
 	test_must_fail git reset --hard -- first &&
 	test_must_fail git reset --soft HEAD^ -- first &&
 	test_must_fail git reset --hard HEAD^ -- first &&
-	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
+	check_changes $head5
 '
 
 test_expect_success 'giving unrecognized options should fail' '
@@ -86,7 +87,7 @@ test_expect_success 'giving unrecognized options should fail' '
 	test_must_fail git reset --soft -o &&
 	test_must_fail git reset --hard --other &&
 	test_must_fail git reset --hard -o &&
-	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
+	check_changes $head5
 '
 
 test_expect_success \
@@ -110,7 +111,7 @@ test_expect_success \
 
 	git checkout master &&
 	git branch -D branch1 branch2 &&
-	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
+	check_changes $head5
 '
 
 test_expect_success \
@@ -133,27 +134,27 @@ test_expect_success \
 
 	git checkout master &&
 	git branch -D branch3 branch4 &&
-	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
+	check_changes $head5
 '
 
 test_expect_success \
 	'resetting to HEAD with no changes should succeed and do nothing' '
 	git reset --hard &&
-		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
+		check_changes $head5 &&
 	git reset --hard HEAD &&
-		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
+		check_changes $head5 &&
 	git reset --soft &&
-		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
+		check_changes $head5 &&
 	git reset --soft HEAD &&
-		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
+		check_changes $head5 &&
 	git reset --mixed &&
-		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
+		check_changes $head5 &&
 	git reset --mixed HEAD &&
-		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
+		check_changes $head5 &&
 	git reset &&
-		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
+		check_changes $head5 &&
 	git reset HEAD &&
-		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
+		check_changes $head5
 '
 
 >.diff_expect
@@ -176,7 +177,7 @@ test_expect_success '--soft reset only should show changes in diff --cached' '
 	git reset --soft HEAD^ &&
 	check_changes d1a4bc3abce4829628ae2dcb0d60ef3d1a78b1c4 &&
 	test "$(git rev-parse ORIG_HEAD)" = \
-			3ec39651e7f44ea531a5de18a9fa791c0fd370fc
+			$head5
 '
 
 >.diff_expect
@@ -193,7 +194,7 @@ test_expect_success \
 	git commit -a -C ORIG_HEAD &&
 	check_changes 3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d &&
 	test "$(git rev-parse ORIG_HEAD)" = \
-			3ec39651e7f44ea531a5de18a9fa791c0fd370fc
+			$head5
 '
 
 >.diff_expect
@@ -303,7 +304,7 @@ test_expect_success 'redoing the last two commits should succeed' '
 	echo "1st line 2nd file" >secondfile &&
 	echo "2nd line 2nd file" >>secondfile &&
 	git commit -a -m "modify 2nd file" &&
-	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
+	check_changes $head5
 '
 
 >.diff_expect
@@ -341,15 +342,15 @@ EOF
 test_expect_success \
 	'--hard reset to ORIG_HEAD should clear a fast-forward merge' '
 	git reset --hard HEAD^ &&
-	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
+	check_changes $head5 &&
 
 	git pull . branch1 &&
 	git reset --hard ORIG_HEAD &&
-	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
+	check_changes $head5 &&
 
 	git checkout master &&
 	git branch -D branch1 branch2 &&
-	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
+	check_changes $head5
 '
 
 cat > expect << EOF
-- 
1.8.1.1.10.g9255f3f

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

* [PATCH v4 3/4] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting
  2011-09-20 20:46                   ` Alexey Shumkin
                                       ` (2 preceding siblings ...)
  2013-01-24  9:10                     ` [PATCH v4 2/4] t7102 (reset): refactoring: " Alexey Shumkin
@ 2013-01-24  9:10                     ` Alexey Shumkin
  2013-01-24 20:44                       ` Junio C Hamano
  2013-01-24 21:02                       ` Junio C Hamano
  2013-01-24  9:10                     ` [PATCH v4 4/4] pretty: " Alexey Shumkin
  4 siblings, 2 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-01-24  9:10 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

The following two commands are expected to give the same output to a terminal:

	$ git log --oneline --no-color
	$ git log --pretty=format:'%h %s'

However, the former pays attention to i18n.logOutputEncoding
configuration, while the latter does not when it format "%s".
Log messages written in an encoding i18n.commitEncoding which differs
from terminal encoding are shown corrupted with the latter even
when i18n.logOutputEncoding and terminal encoding are the same.

The same corruption is true for
	$ git diff --submodule=log
and
	$ git rev-list --pretty=format:%s HEAD
and
	$ git reset --hard

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 t/t4041-diff-submodule-option.sh | 33 ++++++++-------
 t/t4205-log-pretty-formats.sh    | 43 +++++++++++++++----
 t/t6006-rev-list-format.sh       | 90 ++++++++++++++++++++++++++--------------
 t/t7102-reset.sh                 | 32 +++++++++++---
 4 files changed, 138 insertions(+), 60 deletions(-)

diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 32d4a60..e7d6363 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 #
 # Copyright (c) 2009 Jens Lehmann, based on t7401 by Ping Yin
+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
 #
 
 test_description='Support for verbose submodule differences in git diff
@@ -10,6 +11,7 @@ This test tries to verify the sanity of the --submodule option of git diff.
 
 . ./test-lib.sh
 
+added=$(printf "\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275")
 add_file () {
 	(
 		cd "$1" &&
@@ -19,7 +21,8 @@ add_file () {
 			echo "$name" >"$name" &&
 			git add "$name" &&
 			test_tick &&
-			git commit -m "Add $name" || exit
+			msg_added_cp1251=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t cp1251) &&
+			git -c 'i18n.commitEncoding=cp1251' commit -m "$msg_added_cp1251"
 		done >/dev/null &&
 		git rev-parse --short --verify HEAD
 	)
@@ -89,29 +92,29 @@ test_expect_success 'diff.submodule does not affect plumbing' '
 commit_file sm1 &&
 head2=$(add_file sm1 foo3)
 
-test_expect_success 'modified submodule(forward)' '
+test_expect_failure 'modified submodule(forward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
-	  > Add foo3
+	  > Add foo3 ($added foo3)
 	EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'modified submodule(forward)' '
+test_expect_failure 'modified submodule(forward)' '
 	git diff --submodule=log >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
-	  > Add foo3
+	  > Add foo3 ($added foo3)
 	EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'modified submodule(forward) --submodule' '
+test_expect_failure 'modified submodule(forward) --submodule' '
 	git diff --submodule >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
-	  > Add foo3
+	  > Add foo3 ($added foo3)
 	EOF
 	test_cmp expected actual
 '
@@ -138,25 +141,25 @@ head3=$(
 	git rev-parse --short --verify HEAD
 )
 
-test_expect_success 'modified submodule(backward)' '
+test_expect_failure 'modified submodule(backward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head2..$head3 (rewind):
-	  < Add foo3
-	  < Add foo2
+	  < Add foo3 ($added foo3)
+	  < Add foo2 ($added foo2)
 	EOF
 	test_cmp expected actual
 '
 
 head4=$(add_file sm1 foo4 foo5)
-test_expect_success 'modified submodule(backward and forward)' '
+test_expect_failure 'modified submodule(backward and forward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head2...$head4:
-	  > Add foo5
-	  > Add foo4
-	  < Add foo3
-	  < Add foo2
+	  > Add foo5 ($added foo5)
+	  > Add foo4 ($added foo4)
+	  < Add foo3 ($added foo3)
+	  < Add foo2 ($added foo2)
 	EOF
 	test_cmp expected actual
 '
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 98a43d4..76ffa0d 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -1,20 +1,31 @@
 #!/bin/sh
 #
 # Copyright (c) 2010, Will Palmer
+# Copyright (c) 2011, Alexey Shumkin (+ non-UTF-8 commit encoding tests)
 #
 
 test_description='Test pretty formats'
 . ./test-lib.sh
 
+commit_msg() {
+	msg=$(printf "initial \320\272\320\276\320\274\320\274\320\270\321\202")
+	if test -n "$1"; then
+		msg=$(echo $msg | iconv -f utf-8 -t $1)
+	fi
+	echo $msg
+}
+
 test_expect_success 'set up basic repos' '
 	>foo &&
 	>bar &&
 	git add foo &&
 	test_tick &&
-	git commit -m initial &&
+	git config i18n.commitEncoding cp1251 &&
+	git commit -m "$(commit_msg cp1251)" &&
 	git add bar &&
 	test_tick &&
-	git commit -m "add bar"
+	git commit -m "add bar" &&
+	git config --unset i18n.commitEncoding
 '
 
 test_expect_success 'alias builtin format' '
@@ -38,6 +49,20 @@ test_expect_success 'alias user-defined format' '
 	test_cmp expected actual
 '
 
+test_expect_success 'alias user-defined tformat with %s (cp1251 encoding)' '
+	git config i18n.logOutputEncoding cp1251 &&
+	git log --oneline >expected-s &&
+	git log --pretty="tformat:%h %s" >actual-s &&
+	git config --unset i18n.logOutputEncoding &&
+	test_cmp expected-s actual-s
+'
+
+test_expect_failure 'alias user-defined tformat with %s (utf-8 encoding)' '
+	git log --oneline >expected-s &&
+	git log --pretty="tformat:%h %s" >actual-s &&
+	test_cmp expected-s actual-s
+'
+
 test_expect_success 'alias user-defined tformat' '
 	git log --pretty="tformat:%h" >expected &&
 	git config pretty.test-alias "tformat:%h" &&
@@ -71,22 +96,22 @@ test_expect_success 'alias loop' '
 	test_must_fail git log --pretty=test-foo
 '
 
-test_expect_success 'NUL separation' '
-	printf "add bar\0initial" >expected &&
+test_expect_failure 'NUL separation' '
+	printf "add bar\0$(commit_msg)" >expected &&
 	git log -z --pretty="format:%s" >actual &&
 	test_cmp expected actual
 '
 
-test_expect_success 'NUL termination' '
-	printf "add bar\0initial\0" >expected &&
+test_expect_failure 'NUL termination' '
+	printf "add bar\0$(commit_msg)\0" >expected &&
 	git log -z --pretty="tformat:%s" >actual &&
 	test_cmp expected actual
 '
 
-test_expect_success 'NUL separation with --stat' '
+test_expect_failure 'NUL separation with --stat' '
 	stat0_part=$(git diff --stat HEAD^ HEAD) &&
 	stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
-	printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n" >expected &&
+	printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected &&
 	git log -z --stat --pretty="format:%s" >actual &&
 	test_i18ncmp expected actual
 '
@@ -94,7 +119,7 @@ test_expect_success 'NUL separation with --stat' '
 test_expect_failure 'NUL termination with --stat' '
 	stat0_part=$(git diff --stat HEAD^ HEAD) &&
 	stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
-	printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n\0" >expected &&
+	printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n0" >expected &&
 	git log -z --stat --pretty="tformat:%s" >actual &&
 	test_i18ncmp expected actual
 '
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index c248509..4db43a4 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -1,33 +1,54 @@
 #!/bin/sh
 
+# Copyright (c) 2009 Jens Lehmann
+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
+
 test_description='git rev-list --pretty=format test'
 
 . ./test-lib.sh
 
 test_tick
+added=$(printf "added (\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275) foo")
+added_cp1251=$(echo "$added" | iconv -f utf-8 -t cp1251)
+changed=$(printf "changed (\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275) foo")
+changed_cp1251=$(echo "$changed" | iconv -f utf-8 -t cp1251)
+
 test_expect_success 'setup' '
 	touch foo &&
 	git add foo &&
-	git commit -m "added foo" &&
+	git config i18n.commitEncoding cp1251 &&
+	git commit -m "$added_cp1251" &&
 	head1=$(git rev-parse --verify HEAD) &&
 	head1_7=$(echo $head1 | cut -c1-7) &&
-	echo changed >foo &&
-	git commit -a -m "changed foo" &&
+	echo "$changed" > foo &&
+	git commit -a -m "$changed_cp1251" &&
 	head2=$(git rev-parse --verify HEAD) &&
 	head2_7=$(echo $head2 | cut -c1-7) &&
+	tree2=$(git cat-file -p HEAD | grep tree | cut -f 2 -d" ") &&
+	tree2_7=$(echo $tree2 | cut -c1-7) &&
 	head2_parent=$(git cat-file -p HEAD | grep parent | cut -f 2 -d" ") &&
 	head2_parent_7=$(echo $head2_parent | cut -c1-7) &&
-	tree2=$(git cat-file -p HEAD | grep tree | cut -f 2 -d" ") &&
-	tree2_7=$(echo $tree2 | cut -c1-7)
+	git config --unset i18n.commitEncoding
 '
 
 # usage: test_format name format_string <expected_output
 test_format() {
+	local must_fail=0
+	# if parameters count is more than 2 then test must fail
+	if [ $# -gt 2 ]; then
+		must_fail=1
+		# remove first parameter which is flag for test failure
+		shift
+	fi
 	cat >expect.$1
-	test_expect_success "format $1" "
-git rev-list --pretty=format:'$2' master >output.$1 &&
-test_cmp expect.$1 output.$1
-"
+	name="format $1"
+	command="git rev-list --pretty=format:'$2' master >output.$1 &&
+test_cmp expect.$1 output.$1"
+	if [ $must_fail -eq 1 ]; then
+		test_expect_failure "$name" "$command"
+	else
+		test_expect_success "$name" "$command"
+	fi
 }
 
 test_format percent %%h <<EOF
@@ -95,16 +116,16 @@ Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
 EOF
 
-test_format encoding %e <<EOF
+test_format failure encoding %e <<EOF
 commit $head2
 commit $head1
 EOF
 
-test_format subject %s <<EOF
+test_format failure subject %s <<EOF
 commit $head2
-changed foo
+$changed
 commit $head1
-added foo
+$added
 EOF
 
 test_format body %b <<EOF
@@ -112,12 +133,12 @@ commit $head2
 commit $head1
 EOF
 
-test_format raw-body %B <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-changed foo
+test_format failure raw-body %B <<EOF
+commit $head2
+$changed
 
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-added foo
+commit $head1
+$added
 
 EOF
 
@@ -135,16 +156,16 @@ commit $head1
 ^[[1;31;43mfoo^[[m
 EOF
 
-cat >commit-msg <<'EOF'
+iconv -f utf-8 -t cp1251 > commit-msg <<EOF
 Test printing of complex bodies
 
 This commit message is much longer than the others,
-and it will be encoded in iso8859-1. We should therefore
-include an iso8859 character: ¡bueno!
+and it will be encoded in cp1251. We should therefore
+include an cp1251 character: так вот!
 EOF
 
 test_expect_success 'setup complex body' '
-	git config i18n.commitencoding iso8859-1 &&
+	git config i18n.commitencoding cp1251 &&
 	echo change2 >foo && git commit -a -F commit-msg &&
 	head3=$(git rev-parse --verify HEAD) &&
 	head3_7=$(echo $head3 | cut -c1-7)
@@ -152,25 +173,32 @@ test_expect_success 'setup complex body' '
 
 test_format complex-encoding %e <<EOF
 commit $head3
-iso8859-1
+cp1251
 commit $head2
+cp1251
 commit $head1
+cp1251
 EOF
 
-test_format complex-subject %s <<EOF
+# unset commit encoding config
+# otherwise %e does not print encoding value
+# and following test fails
+git config --unset i18n.commitencoding
+
+test_format failure complex-subject %s <<EOF
 commit $head3
 Test printing of complex bodies
 commit $head2
-changed foo
+$changed
 commit $head1
-added foo
+$added
 EOF
 
-test_format complex-body %b <<EOF
+test_format failure complex-body %b <<EOF
 commit $head3
 This commit message is much longer than the others,
-and it will be encoded in iso8859-1. We should therefore
-include an iso8859 character: ¡bueno!
+and it will be encoded in cp1251. We should therefore
+include an cp1251 character: так вот!
 
 commit $head2
 commit $head1
@@ -224,12 +252,12 @@ test_expect_success 'add LF before non-empty (2)' '
 
 test_expect_success 'add SP before non-empty (1)' '
 	git show -s --pretty=format:"%s% bThanks" HEAD^^ >actual &&
-	test $(wc -w <actual) = 2
+	test $(wc -w <actual) = 3
 '
 
 test_expect_success 'add SP before non-empty (2)' '
 	git show -s --pretty=format:"%s% sThanks" HEAD^^ >actual &&
-	test $(wc -w <actual) = 4
+	test $(wc -w <actual) = 6
 '
 
 test_expect_success '--abbrev' '
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index cf492f4..699c824 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -9,6 +9,14 @@ Documented tests for git reset'
 
 . ./test-lib.sh
 
+commit_msg() {
+	msg=$(printf "modify 2nd file (\320\270\320\267\320\274\320\265\320\275\321\221\320\275 \321\204\320\260\320\271\320\273)")
+	if test -n "$1"; then
+		msg=$(echo $msg | iconv -f utf-8 -t $1)
+	fi
+	echo $msg
+}
+
 test_expect_success 'creating initial files and commits' '
 	test_tick &&
 	echo "1st file" >first &&
@@ -28,7 +36,7 @@ test_expect_success 'creating initial files and commits' '
 
 	echo "1st line 2nd file" >secondfile &&
 	echo "2nd line 2nd file" >>secondfile &&
-	git commit -a -m "modify 2nd file" &&
+	git -c "i18n.commitEncoding=cp1251" commit -a -m "$(commit_msg cp1251)" &&
 	head5=$(git rev-parse --verify HEAD)
 '
 # git log --pretty=oneline # to see those SHA1 involved
@@ -44,6 +52,20 @@ check_changes () {
 	done | test_cmp .cat_expect -
 }
 
+test_expect_failure 'reset --hard message' '
+	hex=$(git log -1 --format="%h") &&
+	git reset --hard > .actual &&
+	echo HEAD is now at $hex $(commit_msg) > .expected &&
+	test_cmp .actual .expected
+'
+
+test_expect_success 'reset --hard message (cp1251 logoutencoding)' '
+	hex=$(git log -1 --format="%h") &&
+	git -c "i18n.logOutputEncoding=cp1251" reset --hard > .actual &&
+	echo HEAD is now at $hex $(commit_msg cp1251) > .expected &&
+	test_cmp .actual .expected
+'
+
 >.diff_expect
 >.cached_expect
 cat >.cat_expect <<EOF
@@ -192,7 +214,7 @@ test_expect_success \
 	'changing files and redo the last commit should succeed' '
 	echo "3rd line 2nd file" >>secondfile &&
 	git commit -a -C ORIG_HEAD &&
-	check_changes 3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d &&
+	check_changes f06f78b8dd468c722952b77569dd0db212442c25 &&
 	test "$(git rev-parse ORIG_HEAD)" = \
 			$head5
 '
@@ -211,7 +233,7 @@ test_expect_success \
 	git reset --hard HEAD~2 &&
 	check_changes ddaefe00f1da16864591c61fdc7adb5d7cd6b74e &&
 	test "$(git rev-parse ORIG_HEAD)" = \
-			3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d
+			f06f78b8dd468c722952b77569dd0db212442c25
 '
 
 >.diff_expect
@@ -303,7 +325,7 @@ test_expect_success 'redoing the last two commits should succeed' '
 
 	echo "1st line 2nd file" >secondfile &&
 	echo "2nd line 2nd file" >>secondfile &&
-	git commit -a -m "modify 2nd file" &&
+	git -c "i18n.commitEncoding=cp1251" commit -a -m "$(commit_msg cp1251)" &&
 	check_changes $head5
 '
 
@@ -329,7 +351,7 @@ test_expect_success '--hard reset to HEAD should clear a failed merge' '
 
 	test_must_fail git pull . branch1 &&
 	git reset --hard &&
-	check_changes 77abb337073fb4369a7ad69ff6f5ec0e4d6b54bb
+	check_changes f26fb896db2344fe158ce3720249e1df4d26174b
 '
 
 >.diff_expect
-- 
1.8.1.1.10.g9255f3f

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

* [PATCH v4 4/4] pretty: user format ignores i18n.logOutputEncoding setting
  2011-09-20 20:46                   ` Alexey Shumkin
                                       ` (3 preceding siblings ...)
  2013-01-24  9:10                     ` [PATCH v4 3/4] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting Alexey Shumkin
@ 2013-01-24  9:10                     ` Alexey Shumkin
  4 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-01-24  9:10 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano, Alexey Shumkin

From: Alexey Shumkin <zapped@mail.ru>

The following two commands are expected to give the same output to a terminal:

	$ git log --oneline --no-color
	$ git log --pretty=format:'%h %s'

However, the former pays attention to i18n.logOutputEncoding
configuration, while the latter does not when it format "%s".
Log messages written in an encoding i18n.commitEncoding which differs
from terminal encoding are shown corrupted with the latter even
when i18n.logOutputEncoding and terminal encoding are the same.

The same corruption is true for
	$ git diff --submodule=log
and
	$ git rev-list --pretty=format:%s HEAD
and
	$ git reset --hard

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 builtin/reset.c                  |  8 ++++++--
 builtin/rev-list.c               |  1 +
 builtin/shortlog.c               |  1 +
 log-tree.c                       |  1 +
 submodule.c                      |  3 +++
 t/t4041-diff-submodule-option.sh | 10 +++++-----
 t/t4205-log-pretty-formats.sh    |  8 ++++----
 t/t6006-rev-list-format.sh       | 10 +++++-----
 t/t7102-reset.sh                 |  2 +-
 9 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/builtin/reset.c b/builtin/reset.c
index 915cc9f..11c0aa4 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -100,11 +100,15 @@ static int reset_index_file(const unsigned char *sha1, int reset_type, int quiet
 
 static void print_new_head_line(struct commit *commit)
 {
-	const char *hex, *body;
+	const char *hex, *body, *encoding;
 
 	hex = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
 	printf(_("HEAD is now at %s"), hex);
-	body = strstr(commit->buffer, "\n\n");
+	encoding = get_log_output_encoding();
+	body = logmsg_reencode(commit, encoding);
+	if (!body)
+		body = commit->buffer;
+	body = strstr(body, "\n\n");
 	if (body) {
 		const char *eol;
 		size_t len;
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 67701be..a5ec30d 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -111,6 +111,7 @@ static void show_commit(struct commit *commit, void *data)
 		ctx.date_mode = revs->date_mode;
 		ctx.date_mode_explicit = revs->date_mode_explicit;
 		ctx.fmt = revs->commit_format;
+		ctx.output_encoding = get_log_output_encoding();
 		pretty_print_commit(&ctx, commit, &buf);
 		if (revs->graph) {
 			if (buf.len) {
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 8360514..23c05cd 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -163,6 +163,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
 		ctx.subject = "";
 		ctx.after_subject = "";
 		ctx.date_mode = DATE_NORMAL;
+		ctx.output_encoding = get_log_output_encoding();
 		pretty_print_commit(&ctx, commit, &ufbuf);
 		buffer = ufbuf.buf;
 	} else if (*buffer) {
diff --git a/log-tree.c b/log-tree.c
index 4f86def..e1ff3a5 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -671,6 +671,7 @@ void show_log(struct rev_info *opt)
 	ctx.preserve_subject = opt->preserve_subject;
 	ctx.reflog_info = opt->reflog_info;
 	ctx.fmt = opt->commit_format;
+	ctx.output_encoding = get_log_output_encoding();
 	pretty_print_commit(&ctx, commit, &msgbuf);
 
 	if (opt->add_signoff)
diff --git a/submodule.c b/submodule.c
index 2f55436..8e42750 100644
--- a/submodule.c
+++ b/submodule.c
@@ -222,10 +222,13 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
 	static const char format[] = "  %m %s";
 	struct strbuf sb = STRBUF_INIT;
 	struct commit *commit;
+	const char *log_output_encoding;
 
+	log_output_encoding = get_log_output_encoding();
 	while ((commit = get_revision(rev))) {
 		struct pretty_print_context ctx = {0};
 		ctx.date_mode = rev->date_mode;
+		ctx.output_encoding = log_output_encoding;
 		strbuf_setlen(&sb, 0);
 		if (commit->object.flags & SYMMETRIC_LEFT) {
 			if (del)
diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index e7d6363..39f0609 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -92,7 +92,7 @@ test_expect_success 'diff.submodule does not affect plumbing' '
 commit_file sm1 &&
 head2=$(add_file sm1 foo3)
 
-test_expect_failure 'modified submodule(forward)' '
+test_expect_success 'modified submodule(forward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
@@ -101,7 +101,7 @@ test_expect_failure 'modified submodule(forward)' '
 	test_cmp expected actual
 '
 
-test_expect_failure 'modified submodule(forward)' '
+test_expect_success 'modified submodule(forward)' '
 	git diff --submodule=log >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
@@ -110,7 +110,7 @@ test_expect_failure 'modified submodule(forward)' '
 	test_cmp expected actual
 '
 
-test_expect_failure 'modified submodule(forward) --submodule' '
+test_expect_success 'modified submodule(forward) --submodule' '
 	git diff --submodule >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
@@ -141,7 +141,7 @@ head3=$(
 	git rev-parse --short --verify HEAD
 )
 
-test_expect_failure 'modified submodule(backward)' '
+test_expect_success 'modified submodule(backward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head2..$head3 (rewind):
@@ -152,7 +152,7 @@ test_expect_failure 'modified submodule(backward)' '
 '
 
 head4=$(add_file sm1 foo4 foo5)
-test_expect_failure 'modified submodule(backward and forward)' '
+test_expect_success 'modified submodule(backward and forward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head2...$head4:
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 76ffa0d..54a9704 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -57,7 +57,7 @@ test_expect_success 'alias user-defined tformat with %s (cp1251 encoding)' '
 	test_cmp expected-s actual-s
 '
 
-test_expect_failure 'alias user-defined tformat with %s (utf-8 encoding)' '
+test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' '
 	git log --oneline >expected-s &&
 	git log --pretty="tformat:%h %s" >actual-s &&
 	test_cmp expected-s actual-s
@@ -96,19 +96,19 @@ test_expect_success 'alias loop' '
 	test_must_fail git log --pretty=test-foo
 '
 
-test_expect_failure 'NUL separation' '
+test_expect_success 'NUL separation' '
 	printf "add bar\0$(commit_msg)" >expected &&
 	git log -z --pretty="format:%s" >actual &&
 	test_cmp expected actual
 '
 
-test_expect_failure 'NUL termination' '
+test_expect_success 'NUL termination' '
 	printf "add bar\0$(commit_msg)\0" >expected &&
 	git log -z --pretty="tformat:%s" >actual &&
 	test_cmp expected actual
 '
 
-test_expect_failure 'NUL separation with --stat' '
+test_expect_success 'NUL separation with --stat' '
 	stat0_part=$(git diff --stat HEAD^ HEAD) &&
 	stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
 	printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected &&
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 4db43a4..006e6ab 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -116,12 +116,12 @@ Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
 EOF
 
-test_format failure encoding %e <<EOF
+test_format encoding %e <<EOF
 commit $head2
 commit $head1
 EOF
 
-test_format failure subject %s <<EOF
+test_format subject %s <<EOF
 commit $head2
 $changed
 commit $head1
@@ -133,7 +133,7 @@ commit $head2
 commit $head1
 EOF
 
-test_format failure raw-body %B <<EOF
+test_format raw-body %B <<EOF
 commit $head2
 $changed
 
@@ -185,7 +185,7 @@ EOF
 # and following test fails
 git config --unset i18n.commitencoding
 
-test_format failure complex-subject %s <<EOF
+test_format complex-subject %s <<EOF
 commit $head3
 Test printing of complex bodies
 commit $head2
@@ -194,7 +194,7 @@ commit $head1
 $added
 EOF
 
-test_format failure complex-body %b <<EOF
+test_format complex-body %b <<EOF
 commit $head3
 This commit message is much longer than the others,
 and it will be encoded in cp1251. We should therefore
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 699c824..ea14c97 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -52,7 +52,7 @@ check_changes () {
 	done | test_cmp .cat_expect -
 }
 
-test_expect_failure 'reset --hard message' '
+test_expect_success 'reset --hard message' '
 	hex=$(git log -1 --format="%h") &&
 	git reset --hard > .actual &&
 	echo HEAD is now at $hex $(commit_msg) > .expected &&
-- 
1.8.1.1.10.g9255f3f

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

* Re: [PATCH v4 1/4] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
  2013-01-24  9:10                     ` [PATCH v4 1/4] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
@ 2013-01-24 20:29                       ` Junio C Hamano
  2013-01-25  9:20                         ` Alexey Shumkin
  2013-01-25 11:06                         ` Alexey Shumkin
  0 siblings, 2 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-01-24 20:29 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git

Alexey Shumkin <alex.crezoff@gmail.com> writes:

> The expected SHA-1 digests are always available in variables.  Use
> them instead of hardcoding.
>
> Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
> ---
>  t/t6006-rev-list-format.sh | 130 +++++++++++++++++++++++++--------------------
>  1 file changed, 72 insertions(+), 58 deletions(-)
>
> diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
> index f94f0c4..c248509 100755
> --- a/t/t6006-rev-list-format.sh
> +++ b/t/t6006-rev-list-format.sh
> @@ -6,8 +6,19 @@ test_description='git rev-list --pretty=format test'
>  
>  test_tick
>  test_expect_success 'setup' '
> -touch foo && git add foo && git commit -m "added foo" &&
> -  echo changed >foo && git commit -a -m "changed foo"
> +	touch foo &&

This is inherited from the original, but these days we try to avoid
touch, unless it is about setting a new file timestamp.  The
canonical (in the script we write) way to create an empty file is:

    : >foo

with or without ": ", it does not matter that much.

> +	git add foo &&
> +	git commit -m "added foo" &&
> +	head1=$(git rev-parse --verify HEAD) &&
> +	head1_7=$(echo $head1 | cut -c1-7) &&

Why do we want "whatever_7" variables and use "cut -c1-7" to produce
them?  Is "7" something we care deeply about?

I think what we care a lot more than "7" that happens to be the
current default value is to make sure that, if we ever update the
default abbreviation length to a larger value, the abbreviation
shown with --format=%h is consistent with the abbreviation that is
given by rev-parse --short.

    head1_short=$(git rev-parse --short $head1)

perhaps?

> +	echo changed >foo &&
> +	git commit -a -m "changed foo" &&
> +	head2=$(git rev-parse --verify HEAD) &&
> +	head2_7=$(echo $head2 | cut -c1-7) &&
> +	head2_parent=$(git cat-file -p HEAD | grep parent | cut -f 2 -d" ") &&

Do not use "cat-file -p" that is for human consumption in scripts,
unless you are testing how the format for human consumption should
look like (we may later add more pretty-print to them), which is not
the case here.

Also be careful and pay attention to the end of the header; you do
not want to pick up a random "parent" string in the middle of a log
message.

    head2_parent=$(git cat-file commit HEAD | sed -n -e "s/^parent //p" -e "/^$/q")

would be much better.

> +	head2_parent_7=$(echo $head2_parent | cut -c1-7) &&
> +	tree2=$(git cat-file -p HEAD | grep tree | cut -f 2 -d" ") &&

Likewise.

> +	tree2_7=$(echo $tree2 | cut -c1-7)

Likewise.

> @@ -131,39 +142,42 @@ This commit message is much longer than the others,
>  and it will be encoded in iso8859-1. We should therefore
>  include an iso8859 character: ¡bueno!
>  EOF
> +
>  test_expect_success 'setup complex body' '
> -git config i18n.commitencoding iso8859-1 &&
> -  echo change2 >foo && git commit -a -F commit-msg
> +	git config i18n.commitencoding iso8859-1 &&
> +	echo change2 >foo && git commit -a -F commit-msg &&
> +	head3=$(git rev-parse --verify HEAD) &&
> +	head3_7=$(echo $head3 | cut -c1-7)
>  '

Likewise.

Thanks.

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

* Re: [PATCH v4 2/4] t7102 (reset): refactoring: don't hardcode SHA-1 in expected outputs
  2013-01-24  9:10                     ` [PATCH v4 2/4] t7102 (reset): refactoring: " Alexey Shumkin
@ 2013-01-24 20:30                       ` Junio C Hamano
  2013-01-25  9:08                         ` Alexey Shumkin
  0 siblings, 1 reply; 104+ messages in thread
From: Junio C Hamano @ 2013-01-24 20:30 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git

Alexey Shumkin <alex.crezoff@gmail.com> writes:

> The expected SHA-1 digests are always available in variables.  Use
> them instead of hardcoding.
>
> Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
> ---

Looks good (" refactoring:" in the title may not want to be there,
though).

Thanks.

>  t/t7102-reset.sh | 41 +++++++++++++++++++++--------------------
>  1 file changed, 21 insertions(+), 20 deletions(-)
>
> diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
> index b096dc8..cf492f4 100755
> --- a/t/t7102-reset.sh
> +++ b/t/t7102-reset.sh
> @@ -28,7 +28,8 @@ test_expect_success 'creating initial files and commits' '
>  
>  	echo "1st line 2nd file" >secondfile &&
>  	echo "2nd line 2nd file" >>secondfile &&
> -	git commit -a -m "modify 2nd file"
> +	git commit -a -m "modify 2nd file" &&
> +	head5=$(git rev-parse --verify HEAD)
>  '
>  # git log --pretty=oneline # to see those SHA1 involved
>  
> @@ -56,7 +57,7 @@ test_expect_success 'giving a non existing revision should fail' '
>  	test_must_fail git reset --mixed aaaaaa &&
>  	test_must_fail git reset --soft aaaaaa &&
>  	test_must_fail git reset --hard aaaaaa &&
> -	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
> +	check_changes $head5
>  '
>  
>  test_expect_success 'reset --soft with unmerged index should fail' '
> @@ -74,7 +75,7 @@ test_expect_success \
>  	test_must_fail git reset --hard -- first &&
>  	test_must_fail git reset --soft HEAD^ -- first &&
>  	test_must_fail git reset --hard HEAD^ -- first &&
> -	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
> +	check_changes $head5
>  '
>  
>  test_expect_success 'giving unrecognized options should fail' '
> @@ -86,7 +87,7 @@ test_expect_success 'giving unrecognized options should fail' '
>  	test_must_fail git reset --soft -o &&
>  	test_must_fail git reset --hard --other &&
>  	test_must_fail git reset --hard -o &&
> -	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
> +	check_changes $head5
>  '
>  
>  test_expect_success \
> @@ -110,7 +111,7 @@ test_expect_success \
>  
>  	git checkout master &&
>  	git branch -D branch1 branch2 &&
> -	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
> +	check_changes $head5
>  '
>  
>  test_expect_success \
> @@ -133,27 +134,27 @@ test_expect_success \
>  
>  	git checkout master &&
>  	git branch -D branch3 branch4 &&
> -	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
> +	check_changes $head5
>  '
>  
>  test_expect_success \
>  	'resetting to HEAD with no changes should succeed and do nothing' '
>  	git reset --hard &&
> -		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
> +		check_changes $head5 &&
>  	git reset --hard HEAD &&
> -		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
> +		check_changes $head5 &&
>  	git reset --soft &&
> -		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
> +		check_changes $head5 &&
>  	git reset --soft HEAD &&
> -		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
> +		check_changes $head5 &&
>  	git reset --mixed &&
> -		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
> +		check_changes $head5 &&
>  	git reset --mixed HEAD &&
> -		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
> +		check_changes $head5 &&
>  	git reset &&
> -		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
> +		check_changes $head5 &&
>  	git reset HEAD &&
> -		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
> +		check_changes $head5
>  '
>  
>  >.diff_expect
> @@ -176,7 +177,7 @@ test_expect_success '--soft reset only should show changes in diff --cached' '
>  	git reset --soft HEAD^ &&
>  	check_changes d1a4bc3abce4829628ae2dcb0d60ef3d1a78b1c4 &&
>  	test "$(git rev-parse ORIG_HEAD)" = \
> -			3ec39651e7f44ea531a5de18a9fa791c0fd370fc
> +			$head5
>  '
>  
>  >.diff_expect
> @@ -193,7 +194,7 @@ test_expect_success \
>  	git commit -a -C ORIG_HEAD &&
>  	check_changes 3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d &&
>  	test "$(git rev-parse ORIG_HEAD)" = \
> -			3ec39651e7f44ea531a5de18a9fa791c0fd370fc
> +			$head5
>  '
>  
>  >.diff_expect
> @@ -303,7 +304,7 @@ test_expect_success 'redoing the last two commits should succeed' '
>  	echo "1st line 2nd file" >secondfile &&
>  	echo "2nd line 2nd file" >>secondfile &&
>  	git commit -a -m "modify 2nd file" &&
> -	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
> +	check_changes $head5
>  '
>  
>  >.diff_expect
> @@ -341,15 +342,15 @@ EOF
>  test_expect_success \
>  	'--hard reset to ORIG_HEAD should clear a fast-forward merge' '
>  	git reset --hard HEAD^ &&
> -	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
> +	check_changes $head5 &&
>  
>  	git pull . branch1 &&
>  	git reset --hard ORIG_HEAD &&
> -	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
> +	check_changes $head5 &&
>  
>  	git checkout master &&
>  	git branch -D branch1 branch2 &&
> -	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
> +	check_changes $head5
>  '
>  
>  cat > expect << EOF

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

* Re: [PATCH v4 3/4] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting
  2013-01-24  9:10                     ` [PATCH v4 3/4] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting Alexey Shumkin
@ 2013-01-24 20:44                       ` Junio C Hamano
  2013-01-25  9:07                         ` Alexey Shumkin
  2013-01-24 21:02                       ` Junio C Hamano
  1 sibling, 1 reply; 104+ messages in thread
From: Junio C Hamano @ 2013-01-24 20:44 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git

Alexey Shumkin <alex.crezoff@gmail.com> writes:

> The following two commands are expected to give the same output to a terminal:
>
> 	$ git log --oneline --no-color
> 	$ git log --pretty=format:'%h %s'
>
> However, the former pays attention to i18n.logOutputEncoding
> configuration, while the latter does not when it format "%s".
> Log messages written in an encoding i18n.commitEncoding which differs
> from terminal encoding are shown corrupted with the latter even
> when i18n.logOutputEncoding and terminal encoding are the same.
>
> The same corruption is true for
> 	$ git diff --submodule=log
> and
> 	$ git rev-list --pretty=format:%s HEAD
> and
> 	$ git reset --hard
>
> Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
> ---
>  t/t4041-diff-submodule-option.sh | 33 ++++++++-------
>  t/t4205-log-pretty-formats.sh    | 43 +++++++++++++++----
>  t/t6006-rev-list-format.sh       | 90 ++++++++++++++++++++++++++--------------
>  t/t7102-reset.sh                 | 32 +++++++++++---
>  4 files changed, 138 insertions(+), 60 deletions(-)
>
> diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
> index 32d4a60..e7d6363 100755
> --- a/t/t4041-diff-submodule-option.sh
> +++ b/t/t4041-diff-submodule-option.sh
> @@ -1,6 +1,7 @@
>  #!/bin/sh
>  #
>  # Copyright (c) 2009 Jens Lehmann, based on t7401 by Ping Yin
> +# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
>  #
>  
>  test_description='Support for verbose submodule differences in git diff
> @@ -10,6 +11,7 @@ This test tries to verify the sanity of the --submodule option of git diff.
>  
>  . ./test-lib.sh
>  
> +added=$(printf "\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275")

Please have an in-code comment before this line to explain what this
variable is about, e.g.

	# String "added" in Russian, encoded in UTF-8, used in
        # sample commit log messages in add_file() function below.
        added=$(printf "...")

>  add_file () {
>  	(
>  		cd "$1" &&
> @@ -19,7 +21,8 @@ add_file () {
>  			echo "$name" >"$name" &&
>  			git add "$name" &&
>  			test_tick &&
> -			git commit -m "Add $name" || exit
> +			msg_added_cp1251=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t cp1251) &&
> +			git -c 'i18n.commitEncoding=cp1251' commit -m "$msg_added_cp1251"
>  		done >/dev/null &&
>  		git rev-parse --short --verify HEAD
>  	)

Does this patch make the all tests in this script fail for people
without cp1251 locale installed?  We already have tests that depend
on 8859-1 and some other locales, and we'd be better off limiting
such dependency to the minimum.

Same comment applies to the changes to other test scripts.

Thanks.

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

* Re: [PATCH v4 3/4] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting
  2013-01-24  9:10                     ` [PATCH v4 3/4] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting Alexey Shumkin
  2013-01-24 20:44                       ` Junio C Hamano
@ 2013-01-24 21:02                       ` Junio C Hamano
  2013-01-25  9:01                         ` Alexey Shumkin
  1 sibling, 1 reply; 104+ messages in thread
From: Junio C Hamano @ 2013-01-24 21:02 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git

Alexey Shumkin <alex.crezoff@gmail.com> writes:

> diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
> index c248509..4db43a4 100755
> --- a/t/t6006-rev-list-format.sh
> +++ b/t/t6006-rev-list-format.sh
> ...
> @@ -112,12 +133,12 @@ commit $head2
>  commit $head1
>  EOF
>  
> -test_format raw-body %B <<'EOF'
> -commit 131a310eb913d107dd3c09a65d1651175898735d
> -changed foo
> +test_format failure raw-body %B <<EOF
> +commit $head2
> +$changed
>  
> -commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
> -added foo
> +commit $head1
> +$added
>  
>  EOF

It may have been easier to follow if you did this "Don't hardcode"
as a separate preparatory patch, like your first two patches.

> @@ -135,16 +156,16 @@ commit $head1
>  foo
>  EOF
>  
> -cat >commit-msg <<'EOF'
> +iconv -f utf-8 -t cp1251 > commit-msg <<EOF
>  Test printing of complex bodies
>  
>  This commit message is much longer than the others,
> -and it will be encoded in iso8859-1. We should therefore
> -include an iso8859 character: ¡bueno!
> +and it will be encoded in cp1251. We should therefore
> +include an cp1251 character: так вот!
>  EOF
>  
>  test_expect_success 'setup complex body' '
> -	git config i18n.commitencoding iso8859-1 &&
> +	git config i18n.commitencoding cp1251 &&

What is going on here?

Is this an example that shows that i18n.commitencoding works
correctly with iso8859-1 but not with cp1251?  

> diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
> index cf492f4..699c824 100755
> --- a/t/t7102-reset.sh
> +++ b/t/t7102-reset.sh
> ...
> @@ -192,7 +214,7 @@ test_expect_success \
>  	'changing files and redo the last commit should succeed' '
>  	echo "3rd line 2nd file" >>secondfile &&
>  	git commit -a -C ORIG_HEAD &&
> -	check_changes 3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d &&
> +	check_changes f06f78b8dd468c722952b77569dd0db212442c25 &&
>  	test "$(git rev-parse ORIG_HEAD)" = \
>  			$head5
>  '

This and remaining hunks to this script shows that it would be
helped by the same love you gave to other scripts with your first
two patches before you add the "non-unicode" tests, no?

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

* Re: [PATCH v4 3/4] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting
  2013-01-24 21:02                       ` Junio C Hamano
@ 2013-01-25  9:01                         ` Alexey Shumkin
  0 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-01-25  9:01 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

> Alexey Shumkin <alex.crezoff@gmail.com> writes:
> 
> > diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
> > index c248509..4db43a4 100755
> > --- a/t/t6006-rev-list-format.sh
> > +++ b/t/t6006-rev-list-format.sh
> > ...
> > @@ -112,12 +133,12 @@ commit $head2
> >  commit $head1
> >  EOF
> >  
> > -test_format raw-body %B <<'EOF'
> > -commit 131a310eb913d107dd3c09a65d1651175898735d
> > -changed foo
> > +test_format failure raw-body %B <<EOF
> > +commit $head2
> > +$changed
> >  
> > -commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
> > -added foo
> > +commit $head1
> > +$added
> >  
> >  EOF
> 
> It may have been easier to follow if you did this "Don't hardcode"
> as a separate preparatory patch, like your first two patches.
Yep, I missed that in my bunch of rebasing ;)

> 
> > @@ -135,16 +156,16 @@ commit $head1
> >  foo
> >  EOF
> >  
> > -cat >commit-msg <<'EOF'
> > +iconv -f utf-8 -t cp1251 > commit-msg <<EOF
> >  Test printing of complex bodies
> >  
> >  This commit message is much longer than the others,
> > -and it will be encoded in iso8859-1. We should therefore
> > -include an iso8859 character: ¡bueno!
> > +and it will be encoded in cp1251. We should therefore
> > +include an cp1251 character: так вот!
> >  EOF
> >  
> >  test_expect_success 'setup complex body' '
> > -	git config i18n.commitencoding iso8859-1 &&
> > +	git config i18n.commitencoding cp1251 &&
> 
> What is going on here?
> 
> Is this an example that shows that i18n.commitencoding works
> correctly with iso8859-1 but not with cp1251?
It show only that I speak and write Russian not Spanish ))
I'll revert back these changes.

> 
> > diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
> > index cf492f4..699c824 100755
> > --- a/t/t7102-reset.sh
> > +++ b/t/t7102-reset.sh
> > ...
> > @@ -192,7 +214,7 @@ test_expect_success \
> >  	'changing files and redo the last commit should succeed' '
> >  	echo "3rd line 2nd file" >>secondfile &&
> >  	git commit -a -C ORIG_HEAD &&
> > -	check_changes 3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d &&
> > +	check_changes f06f78b8dd468c722952b77569dd0db212442c25 &&
> >  	test "$(git rev-parse ORIG_HEAD)" = \
> >  			$head5
> >  '
> 
> This and remaining hunks to this script shows that it would be
> helped by the same love you gave to other scripts with your first
> two patches before you add the "non-unicode" tests, no?
Sorry, I haven't got you :-[ (it seems, my English is not good enough)
Do you mean "avoid hardcoded SHA-1"?

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

* Re: [PATCH v4 3/4] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting
  2013-01-24 20:44                       ` Junio C Hamano
@ 2013-01-25  9:07                         ` Alexey Shumkin
  0 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-01-25  9:07 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

> Alexey Shumkin <alex.crezoff@gmail.com> writes:
> 
> > The following two commands are expected to give the same output to
> > a terminal:
> >
> > 	$ git log --oneline --no-color
> > 	$ git log --pretty=format:'%h %s'
> >
> > However, the former pays attention to i18n.logOutputEncoding
> > configuration, while the latter does not when it format "%s".
> > Log messages written in an encoding i18n.commitEncoding which
> > differs from terminal encoding are shown corrupted with the latter
> > even when i18n.logOutputEncoding and terminal encoding are the same.
> >
> > The same corruption is true for
> > 	$ git diff --submodule=log
> > and
> > 	$ git rev-list --pretty=format:%s HEAD
> > and
> > 	$ git reset --hard
> >
> > Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
> > ---
> >  t/t4041-diff-submodule-option.sh | 33 ++++++++-------
> >  t/t4205-log-pretty-formats.sh    | 43 +++++++++++++++----
> >  t/t6006-rev-list-format.sh       | 90
> > ++++++++++++++++++++++++++--------------
> > t/t7102-reset.sh                 | 32 +++++++++++--- 4 files
> > changed, 138 insertions(+), 60 deletions(-)
> >
> > diff --git a/t/t4041-diff-submodule-option.sh
> > b/t/t4041-diff-submodule-option.sh index 32d4a60..e7d6363 100755
> > --- a/t/t4041-diff-submodule-option.sh
> > +++ b/t/t4041-diff-submodule-option.sh
> > @@ -1,6 +1,7 @@
> >  #!/bin/sh
> >  #
> >  # Copyright (c) 2009 Jens Lehmann, based on t7401 by Ping Yin
> > +# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding
> > tests) #
> >  
> >  test_description='Support for verbose submodule differences in git
> > diff @@ -10,6 +11,7 @@ This test tries to verify the sanity of the
> > --submodule option of git diff. 
> >  . ./test-lib.sh
> >  
> > +added=$(printf
> > "\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275")
> 
> Please have an in-code comment before this line to explain what this
> variable is about, e.g.
> 
> 	# String "added" in Russian, encoded in UTF-8, used in
>         # sample commit log messages in add_file() function below.
>         added=$(printf "...")
Ok!

> 
> >  add_file () {
> >  	(
> >  		cd "$1" &&
> > @@ -19,7 +21,8 @@ add_file () {
> >  			echo "$name" >"$name" &&
> >  			git add "$name" &&
> >  			test_tick &&
> > -			git commit -m "Add $name" || exit
> > +			msg_added_cp1251=$(echo "Add $name ($added
> > $name)" | iconv -f utf-8 -t cp1251) &&
> > +			git -c 'i18n.commitEncoding=cp1251' commit
> > -m "$msg_added_cp1251" done >/dev/null &&
> >  		git rev-parse --short --verify HEAD
> >  	)
> 
> Does this patch make the all tests in this script fail for people
> without cp1251 locale installed?  We already have tests that depend
> on 8859-1 and some other locales, and we'd be better off limiting
> such dependency to the minimum.
Hmmm, I'll try to feign something to avoid using cp1251

> 
> Same comment applies to the changes to other test scripts.
> 
> Thanks.

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

* Re: [PATCH v4 2/4] t7102 (reset): refactoring: don't hardcode SHA-1 in expected outputs
  2013-01-24 20:30                       ` Junio C Hamano
@ 2013-01-25  9:08                         ` Alexey Shumkin
  0 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-01-25  9:08 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

> Alexey Shumkin <alex.crezoff@gmail.com> writes:
> 
> > The expected SHA-1 digests are always available in variables.  Use
> > them instead of hardcoding.
> >
> > Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
> > ---
> 
> Looks good (" refactoring:" in the title may not want to be there,
> though).
oops, it's remained from "working version" after rebasing

> 
> Thanks.
> 
> >  t/t7102-reset.sh | 41 +++++++++++++++++++++--------------------
> >  1 file changed, 21 insertions(+), 20 deletions(-)
> >
> > diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
> > index b096dc8..cf492f4 100755
> > --- a/t/t7102-reset.sh
> > +++ b/t/t7102-reset.sh
> > @@ -28,7 +28,8 @@ test_expect_success 'creating initial files and
> > commits' ' 
> >  	echo "1st line 2nd file" >secondfile &&
> >  	echo "2nd line 2nd file" >>secondfile &&
> > -	git commit -a -m "modify 2nd file"
> > +	git commit -a -m "modify 2nd file" &&
> > +	head5=$(git rev-parse --verify HEAD)
> >  '
> >  # git log --pretty=oneline # to see those SHA1 involved
> >  
> > @@ -56,7 +57,7 @@ test_expect_success 'giving a non existing
> > revision should fail' ' test_must_fail git reset --mixed aaaaaa &&
> >  	test_must_fail git reset --soft aaaaaa &&
> >  	test_must_fail git reset --hard aaaaaa &&
> > -	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
> > +	check_changes $head5
> >  '
> >  
> >  test_expect_success 'reset --soft with unmerged index should fail'
> > ' @@ -74,7 +75,7 @@ test_expect_success \
> >  	test_must_fail git reset --hard -- first &&
> >  	test_must_fail git reset --soft HEAD^ -- first &&
> >  	test_must_fail git reset --hard HEAD^ -- first &&
> > -	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
> > +	check_changes $head5
> >  '
> >  
> >  test_expect_success 'giving unrecognized options should fail' '
> > @@ -86,7 +87,7 @@ test_expect_success 'giving unrecognized options
> > should fail' ' test_must_fail git reset --soft -o &&
> >  	test_must_fail git reset --hard --other &&
> >  	test_must_fail git reset --hard -o &&
> > -	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
> > +	check_changes $head5
> >  '
> >  
> >  test_expect_success \
> > @@ -110,7 +111,7 @@ test_expect_success \
> >  
> >  	git checkout master &&
> >  	git branch -D branch1 branch2 &&
> > -	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
> > +	check_changes $head5
> >  '
> >  
> >  test_expect_success \
> > @@ -133,27 +134,27 @@ test_expect_success \
> >  
> >  	git checkout master &&
> >  	git branch -D branch3 branch4 &&
> > -	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
> > +	check_changes $head5
> >  '
> >  
> >  test_expect_success \
> >  	'resetting to HEAD with no changes should succeed and do
> > nothing' ' git reset --hard &&
> > -		check_changes
> > 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
> > +		check_changes $head5 &&
> >  	git reset --hard HEAD &&
> > -		check_changes
> > 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
> > +		check_changes $head5 &&
> >  	git reset --soft &&
> > -		check_changes
> > 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
> > +		check_changes $head5 &&
> >  	git reset --soft HEAD &&
> > -		check_changes
> > 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
> > +		check_changes $head5 &&
> >  	git reset --mixed &&
> > -		check_changes
> > 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
> > +		check_changes $head5 &&
> >  	git reset --mixed HEAD &&
> > -		check_changes
> > 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
> > +		check_changes $head5 &&
> >  	git reset &&
> > -		check_changes
> > 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
> > +		check_changes $head5 &&
> >  	git reset HEAD &&
> > -		check_changes
> > 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
> > +		check_changes $head5
> >  '
> >  
> >  >.diff_expect
> > @@ -176,7 +177,7 @@ test_expect_success '--soft reset only should
> > show changes in diff --cached' ' git reset --soft HEAD^ &&
> >  	check_changes d1a4bc3abce4829628ae2dcb0d60ef3d1a78b1c4 &&
> >  	test "$(git rev-parse ORIG_HEAD)" = \
> > -			3ec39651e7f44ea531a5de18a9fa791c0fd370fc
> > +			$head5
> >  '
> >  
> >  >.diff_expect
> > @@ -193,7 +194,7 @@ test_expect_success \
> >  	git commit -a -C ORIG_HEAD &&
> >  	check_changes 3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d &&
> >  	test "$(git rev-parse ORIG_HEAD)" = \
> > -			3ec39651e7f44ea531a5de18a9fa791c0fd370fc
> > +			$head5
> >  '
> >  
> >  >.diff_expect
> > @@ -303,7 +304,7 @@ test_expect_success 'redoing the last two
> > commits should succeed' ' echo "1st line 2nd file" >secondfile &&
> >  	echo "2nd line 2nd file" >>secondfile &&
> >  	git commit -a -m "modify 2nd file" &&
> > -	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
> > +	check_changes $head5
> >  '
> >  
> >  >.diff_expect
> > @@ -341,15 +342,15 @@ EOF
> >  test_expect_success \
> >  	'--hard reset to ORIG_HEAD should clear a fast-forward
> > merge' ' git reset --hard HEAD^ &&
> > -	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
> > +	check_changes $head5 &&
> >  
> >  	git pull . branch1 &&
> >  	git reset --hard ORIG_HEAD &&
> > -	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
> > +	check_changes $head5 &&
> >  
> >  	git checkout master &&
> >  	git branch -D branch1 branch2 &&
> > -	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
> > +	check_changes $head5
> >  '
> >  
> >  cat > expect << EOF

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

* Re: [PATCH v4 1/4] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
  2013-01-24 20:29                       ` Junio C Hamano
@ 2013-01-25  9:20                         ` Alexey Shumkin
  2013-01-25 11:06                         ` Alexey Shumkin
  1 sibling, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-01-25  9:20 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

> Alexey Shumkin <alex.crezoff@gmail.com> writes:
> 
> > The expected SHA-1 digests are always available in variables.  Use
> > them instead of hardcoding.
> >
> > Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
> > ---
> >  t/t6006-rev-list-format.sh | 130
> > +++++++++++++++++++++++++-------------------- 1 file changed, 72
> > insertions(+), 58 deletions(-)
> >
> > diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
> > index f94f0c4..c248509 100755
> > --- a/t/t6006-rev-list-format.sh
> > +++ b/t/t6006-rev-list-format.sh
> > @@ -6,8 +6,19 @@ test_description='git rev-list --pretty=format
> > test' 
> >  test_tick
> >  test_expect_success 'setup' '
> > -touch foo && git add foo && git commit -m "added foo" &&
> > -  echo changed >foo && git commit -a -m "changed foo"
> > +	touch foo &&
> 
> This is inherited from the original, but these days we try to avoid
> touch, unless it is about setting a new file timestamp.  The
> canonical (in the script we write) way to create an empty file is:
> 
>     : >foo
> 
> with or without ": ", it does not matter that much.
Ok!

> 
> > +	git add foo &&
> > +	git commit -m "added foo" &&
> > +	head1=$(git rev-parse --verify HEAD) &&
> > +	head1_7=$(echo $head1 | cut -c1-7) &&
> 
> Why do we want "whatever_7" variables and use "cut -c1-7" to produce
> them?  Is "7" something we care deeply about?
I did not spend too much time to think of names of variables at the
moment I was writing this code )
> 
> I think what we care a lot more than "7" that happens to be the
> current default value is to make sure that, if we ever update the
> default abbreviation length to a larger value, the abbreviation
> shown with --format=%h is consistent with the abbreviation that is
> given by rev-parse --short.
> 
>     head1_short=$(git rev-parse --short $head1)
> 
> perhaps?
It's an inherited code from 1.5 years ago Git ;) taken from some other
tests
I'll change it as you propose )

> 
> > +	echo changed >foo &&
> > +	git commit -a -m "changed foo" &&
> > +	head2=$(git rev-parse --verify HEAD) &&
> > +	head2_7=$(echo $head2 | cut -c1-7) &&
> > +	head2_parent=$(git cat-file -p HEAD | grep parent | cut -f
> > 2 -d" ") &&
> 
> Do not use "cat-file -p" that is for human consumption in scripts,
> unless you are testing how the format for human consumption should
> look like (we may later add more pretty-print to them), which is not
> the case here.
> 
> Also be careful and pay attention to the end of the header; you do
> not want to pick up a random "parent" string in the middle of a log
> message.
> 
>     head2_parent=$(git cat-file commit HEAD | sed -n -e
> "s/^parent //p" -e "/^$/q")
> 
> would be much better.
yep! you're definitely right

> 
> > +	head2_parent_7=$(echo $head2_parent | cut -c1-7) &&
> > +	tree2=$(git cat-file -p HEAD | grep tree | cut -f 2 -d" ")
> > &&
> 
> Likewise.
> 
> > +	tree2_7=$(echo $tree2 | cut -c1-7)
> 
> Likewise.
> 
> > @@ -131,39 +142,42 @@ This commit message is much longer than the
> > others, and it will be encoded in iso8859-1. We should therefore
> >  include an iso8859 character: ¡bueno!
> >  EOF
> > +
> >  test_expect_success 'setup complex body' '
> > -git config i18n.commitencoding iso8859-1 &&
> > -  echo change2 >foo && git commit -a -F commit-msg
> > +	git config i18n.commitencoding iso8859-1 &&
> > +	echo change2 >foo && git commit -a -F commit-msg &&
> > +	head3=$(git rev-parse --verify HEAD) &&
> > +	head3_7=$(echo $head3 | cut -c1-7)
> >  '
> 
> Likewise.
> 
> Thanks.

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

* Re: [PATCH v4 1/4] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
  2013-01-24 20:29                       ` Junio C Hamano
  2013-01-25  9:20                         ` Alexey Shumkin
@ 2013-01-25 11:06                         ` Alexey Shumkin
  2013-01-25 15:16                           ` Junio C Hamano
  1 sibling, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-01-25 11:06 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

> Why do we want "whatever_7" variables and use "cut -c1-7" to produce
> them?  Is "7" something we care deeply about?
> 
> I think what we care a lot more than "7" that happens to be the
> current default value is to make sure that, if we ever update the
> default abbreviation length to a larger value, the abbreviation
> shown with --format=%h is consistent with the abbreviation that is
> given by rev-parse --short.
> 
>     head1_short=$(git rev-parse --short $head1)
> 
> perhaps?
> 
> > +	echo changed >foo &&
> > +	git commit -a -m "changed foo" &&
> > +	head2=$(git rev-parse --verify HEAD) &&
> > +	head2_7=$(echo $head2 | cut -c1-7) &&
> > +	head2_parent=$(git cat-file -p HEAD | grep parent | cut -f
> > 2 -d" ") &&
> 
> Do not use "cat-file -p" that is for human consumption in scripts,
> unless you are testing how the format for human consumption should
> look like (we may later add more pretty-print to them), which is not
> the case here.
> 
> Also be careful and pay attention to the end of the header; you do
> not want to pick up a random "parent" string in the middle of a log
> message.
> 
>     head2_parent=$(git cat-file commit HEAD | sed -n -e
> "s/^parent //p" -e "/^$/q")
> 
> would be much better.
> 
> > +	head2_parent_7=$(echo $head2_parent | cut -c1-7) &&
> > +	tree2=$(git cat-file -p HEAD | grep tree | cut -f 2 -d" ")
> > &&
> 
> Likewise.
> 
> > +	tree2_7=$(echo $tree2 | cut -c1-7)
> 
> Likewise.
but is there "git something" to return abbreviated tree hash except
"pretty formats" that is implicitly tested here?

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

* Re: [PATCH v4 1/4] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
  2013-01-25 11:06                         ` Alexey Shumkin
@ 2013-01-25 15:16                           ` Junio C Hamano
  2013-01-25 15:27                             ` Alexey Shumkin
  0 siblings, 1 reply; 104+ messages in thread
From: Junio C Hamano @ 2013-01-25 15:16 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git

Alexey Shumkin <alex.crezoff@gmail.com> writes:

>> Why do we want "whatever_7" variables and use "cut -c1-7" to produce
>> them?  Is "7" something we care deeply about?
>> 
>> I think what we care a lot more than "7" that happens to be the
>> current default value is to make sure that, if we ever update the
>> default abbreviation length to a larger value, the abbreviation
>> shown with --format=%h is consistent with the abbreviation that is
>> given by rev-parse --short.
>> 
>>     head1_short=$(git rev-parse --short $head1)
>> 
>> perhaps?
>> ...
>> Likewise.
>> 
>> > +	tree2_7=$(echo $tree2 | cut -c1-7)
>> 
>> Likewise.
> but is there "git something" to return abbreviated tree hash except
> "pretty formats" that is implicitly tested here?

Does "git rev-parse --short $tree2" count?

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

* Re: [PATCH v4 1/4] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
  2013-01-25 15:16                           ` Junio C Hamano
@ 2013-01-25 15:27                             ` Alexey Shumkin
  0 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-01-25 15:27 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

> Alexey Shumkin <alex.crezoff@gmail.com> writes:
> 
> >> Why do we want "whatever_7" variables and use "cut -c1-7" to
> >> produce them?  Is "7" something we care deeply about?
> >> 
> >> I think what we care a lot more than "7" that happens to be the
> >> current default value is to make sure that, if we ever update the
> >> default abbreviation length to a larger value, the abbreviation
> >> shown with --format=%h is consistent with the abbreviation that is
> >> given by rev-parse --short.
> >> 
> >>     head1_short=$(git rev-parse --short $head1)
> >> 
> >> perhaps?
> >> ...
> >> Likewise.
> >> 
> >> > +	tree2_7=$(echo $tree2 | cut -c1-7)
> >> 
> >> Likewise.
> > but is there "git something" to return abbreviated tree hash except
> > "pretty formats" that is implicitly tested here?
> 
> Does "git rev-parse --short $tree2" count?
Oops! Yep!

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

* [PATCH v5 0/5] Reroll patches against v1.8.3.1
  2013-01-24  9:10                     ` [PATCH v4 0/4] Reroll patches against v1.8.1.1 Alexey Shumkin
@ 2013-06-20  9:26                       ` Alexey Shumkin
  2013-06-20 20:10                         ` Junio C Hamano
                                           ` (6 more replies)
  2013-06-20  9:26                       ` [PATCH v5 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
                                         ` (4 subsequent siblings)
  5 siblings, 7 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-20  9:26 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

Alexey Shumkin (5):
  t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
  t7102 (reset): don't hardcode SHA-1 in expected outputs
  t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
  pretty: Add failing tests: user format ignores i18n.logOutputEncoding
    setting
  pretty: user format ignores i18n.logOutputEncoding setting

 builtin/reset.c                  |   8 +-
 builtin/rev-list.c               |   1 +
 builtin/shortlog.c               |   1 +
 log-tree.c                       |   1 +
 submodule.c                      |   3 +
 t/t4041-diff-submodule-option.sh |  25 +++--
 t/t4205-log-pretty-formats.sh    | 179 ++++++++++++++++++++-------------
 t/t6006-rev-list-format.sh       | 209 ++++++++++++++++++++++++---------------
 t/t7102-reset.sh                 |  37 ++++++-
 9 files changed, 299 insertions(+), 165 deletions(-)

-- 
1.8.3.1.15.g5c23c1e

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

* [PATCH v5 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
  2013-01-24  9:10                     ` [PATCH v4 0/4] Reroll patches against v1.8.1.1 Alexey Shumkin
  2013-06-20  9:26                       ` [PATCH v5 0/5] Reroll patches against v1.8.3.1 Alexey Shumkin
@ 2013-06-20  9:26                       ` Alexey Shumkin
  2013-06-20 20:38                         ` Junio C Hamano
  2013-06-20  9:26                       ` [PATCH v5 2/5] t7102 (reset): " Alexey Shumkin
                                         ` (3 subsequent siblings)
  5 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-20  9:26 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 7248 bytes --]

The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 t/t6006-rev-list-format.sh | 142 +++++++++++++++++++++++++--------------------
 1 file changed, 79 insertions(+), 63 deletions(-)

diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 0393c9f..d32e65e 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -7,8 +7,21 @@ test_description='git rev-list --pretty=format test'
 
 test_tick
 test_expect_success 'setup' '
-touch foo && git add foo && git commit -m "added foo" &&
-  echo changed >foo && git commit -a -m "changed foo"
+	: >foo &&
+	git add foo &&
+	git commit -m "added foo" &&
+	head1=$(git rev-parse --verify HEAD) &&
+	head1_short=$(git rev-parse --short $head1) &&
+	tree1=$(git cat-file commit HEAD | sed -n -e "s/^tree //p" -e "/^$/q") &&
+	tree1_short=$(git rev-parse --short $tree1) &&
+	echo changed >foo &&
+	git commit -a -m "changed foo" &&
+	head2=$(git rev-parse --verify HEAD) &&
+	head2_short=$(git rev-parse --short $head2) &&
+	head2_parent=$(git cat-file commit HEAD | sed -n -e "s/^parent //p" -e "/^$/q") &&
+	head2_parent_short=$(git rev-parse --short $head2_parent) &&
+	tree2=$(git cat-file commit HEAD | sed -n -e "s/^tree //p" -e "/^$/q") &&
+	tree2_short=$(git rev-parse --short $tree2)
 '
 
 # usage: test_format name format_string <expected_output
@@ -32,49 +45,49 @@ has_no_color () {
 	test_cmp expect "$1"
 }
 
-test_format percent %%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format percent %%h <<EOF
+commit $head2
 %h
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 %h
 EOF
 
-test_format hash %H%n%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-131a310eb913d107dd3c09a65d1651175898735d
-131a310
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
+test_format hash %H%n%h <<EOF
+commit $head2
+$head2
+$head2_short
+commit $head1
+$head1
+$head1_short
 EOF
 
-test_format tree %T%n%t <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-fe722612f26da5064c32ca3843aa154bdb0b08a0
-fe72261
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-4d5fcadc293a348e88f777dc0920f11e7d71441c
-4d5fcad
+test_format tree %T%n%t <<EOF
+commit $head2
+$tree2
+$tree2_short
+commit $head1
+$tree1
+$tree1_short
 EOF
 
-test_format parents %P%n%p <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format parents %P%n%p <<EOF
+commit $head2
+$head1
+$head2_parent_short
+commit $head1
 
 
 EOF
 
 # we don't test relative here
-test_format author %an%n%ae%n%ad%n%aD%n%at <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format author %an%n%ae%n%ad%n%aD%n%at <<EOF
+commit $head2
 A U Thor
 author@example.com
 Thu Apr 7 15:13:13 2005 -0700
 Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 A U Thor
 author@example.com
 Thu Apr 7 15:13:13 2005 -0700
@@ -82,14 +95,14 @@ Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
 EOF
 
-test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<EOF
+commit $head2
 C O Mitter
 committer@example.com
 Thu Apr 7 15:13:13 2005 -0700
 Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 C O Mitter
 committer@example.com
 Thu Apr 7 15:13:13 2005 -0700
@@ -97,43 +110,43 @@ Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
 EOF
 
-test_format encoding %e <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format encoding %e <<EOF
+commit $head2
+commit $head1
 EOF
 
-test_format subject %s <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format subject %s <<EOF
+commit $head2
 changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 added foo
 EOF
 
-test_format body %b <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format body %b <<EOF
+commit $head2
+commit $head1
 EOF
 
-test_format raw-body %B <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format raw-body %B <<EOF
+commit $head2
 changed foo
 
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 added foo
 
 EOF
 
-test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<EOF
+commit $head2
 ^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 ^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
 EOF
 
-test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<EOF
+commit $head2
 ^[[1;31;43mfoo^[[m
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 ^[[1;31;43mfoo^[[m
 EOF
 
@@ -186,39 +199,42 @@ This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
 include an iso8859 character: ¡bueno!
 EOF
+
 test_expect_success 'setup complex body' '
-git config i18n.commitencoding iso8859-1 &&
-  echo change2 >foo && git commit -a -F commit-msg
+	git config i18n.commitencoding iso8859-1 &&
+	echo change2 >foo && git commit -a -F commit-msg &&
+	head3=$(git rev-parse --verify HEAD) &&
+	head3_short=$(git rev-parse --short $head3)
 '
 
-test_format complex-encoding %e <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
+test_format complex-encoding %e <<EOF
+commit $head3
 iso8859-1
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head2
+commit $head1
 EOF
 
-test_format complex-subject %s <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
+test_format complex-subject %s <<EOF
+commit $head3
 Test printing of complex bodies
-commit 131a310eb913d107dd3c09a65d1651175898735d
+commit $head2
 changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 added foo
 EOF
 
-test_format complex-body %b <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
+test_format complex-body %b <<EOF
+commit $head3
 This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
 include an iso8859 character: ¡bueno!
 
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head2
+commit $head1
 EOF
 
 test_expect_success '%x00 shows NUL' '
-	echo  >expect commit 1ed88da4a5b5ed8c449114ac131efc62178734c3 &&
+	echo  >expect commit $head3 &&
 	echo >>expect fooQbar &&
 	git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
 	nul_to_q <actual.nul >actual &&
-- 
1.8.3.1.15.g5c23c1e

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

* [PATCH v5 2/5] t7102 (reset): don't hardcode SHA-1 in expected outputs
  2013-01-24  9:10                     ` [PATCH v4 0/4] Reroll patches against v1.8.1.1 Alexey Shumkin
  2013-06-20  9:26                       ` [PATCH v5 0/5] Reroll patches against v1.8.3.1 Alexey Shumkin
  2013-06-20  9:26                       ` [PATCH v5 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
@ 2013-06-20  9:26                       ` Alexey Shumkin
  2013-06-20  9:26                       ` [PATCH v5 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
                                         ` (2 subsequent siblings)
  5 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-20  9:26 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 t/t7102-reset.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index df82ec9..05dfb27 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -192,7 +192,8 @@ test_expect_success \
 	'changing files and redo the last commit should succeed' '
 	echo "3rd line 2nd file" >>secondfile &&
 	git commit -a -C ORIG_HEAD &&
-	check_changes 3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d &&
+	head4=$(git rev-parse --verify HEAD) &&
+	check_changes $head4 &&
 	test "$(git rev-parse ORIG_HEAD)" = \
 			$head5
 '
@@ -211,7 +212,7 @@ test_expect_success \
 	git reset --hard HEAD~2 &&
 	check_changes ddaefe00f1da16864591c61fdc7adb5d7cd6b74e &&
 	test "$(git rev-parse ORIG_HEAD)" = \
-			3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d
+			$head4
 '
 
 >.diff_expect
@@ -326,10 +327,11 @@ test_expect_success '--hard reset to HEAD should clear a failed merge' '
 	git checkout branch2 &&
 	echo "3rd line in branch2" >>secondfile &&
 	git commit -a -m "change in branch2" &&
+	head3=$(git rev-parse --verify HEAD) &&
 
 	test_must_fail git pull . branch1 &&
 	git reset --hard &&
-	check_changes 77abb337073fb4369a7ad69ff6f5ec0e4d6b54bb
+	check_changes $head3
 '
 
 >.diff_expect
-- 
1.8.3.1.15.g5c23c1e

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

* [PATCH v5 3/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
  2013-01-24  9:10                     ` [PATCH v4 0/4] Reroll patches against v1.8.1.1 Alexey Shumkin
                                         ` (2 preceding siblings ...)
  2013-06-20  9:26                       ` [PATCH v5 2/5] t7102 (reset): " Alexey Shumkin
@ 2013-06-20  9:26                       ` Alexey Shumkin
  2013-06-20 20:38                         ` Junio C Hamano
  2013-06-20  9:26                       ` [PATCH v5 4/5] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting Alexey Shumkin
  2013-06-20  9:26                       ` [PATCH v5 5/5] pretty: " Alexey Shumkin
  5 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-20  9:26 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 t/t4205-log-pretty-formats.sh | 48 +++++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 22 deletions(-)

diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 26fbfde..6d8d457 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -101,7 +101,11 @@ test_expect_failure 'NUL termination with --stat' '
 
 test_expect_success 'setup more commits' '
 	test_commit "message one" one one message-one &&
-	test_commit "message two" two two message-two
+	test_commit "message two" two two message-two &&
+	head1=$(git rev-list --max-count=1 --abbrev-commit HEAD~0) &&
+	head2=$(git rev-list --max-count=1 --abbrev-commit HEAD~1) &&
+	head3=$(git rev-list --max-count=1 --abbrev-commit HEAD~2) &&
+	head4=$(git rev-list --max-count=1 --abbrev-commit HEAD~3)
 '
 
 test_expect_success 'left alignment formatting' '
@@ -117,18 +121,18 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'left alignment formatting at the nth column' '
-	git log --pretty="format:%h %<|(40)%s" >actual &&
+test_expect_success 'left alignment formatting at the nth column' "
+	git log --pretty='format:%h %<|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
-fa33ab1 message two                    Z
-7cd6c63 message one                    Z
-1711bf9 add bar                        Z
-af20c06 initial                        Z
+$head1 message two                    Z
+$head2 message one                    Z
+$head3 add bar                        Z
+$head4 initial                        Z
 EOF
 	test_cmp expected actual
-'
+"
 
 test_expect_success 'left alignment formatting with no padding' '
 	git log --pretty="format:%<(1)%s" >actual &&
@@ -195,18 +199,18 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'right alignment formatting at the nth column' '
-	git log --pretty="format:%h %>|(40)%s" >actual &&
+test_expect_success 'right alignment formatting at the nth column' "
+	git log --pretty='format:%h %>|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
-fa33ab1                      message two
-7cd6c63                      message one
-1711bf9                          add bar
-af20c06                          initial
+$head1                      message two
+$head2                      message one
+$head3                          add bar
+$head4                          initial
 EOF
 	test_cmp expected actual
-'
+"
 
 test_expect_success 'right alignment formatting with no padding' '
 	git log --pretty="format:%>(1)%s" >actual &&
@@ -234,18 +238,18 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'center alignment formatting at the nth column' '
-	git log --pretty="format:%h %><|(40)%s" >actual &&
+test_expect_success 'center alignment formatting at the nth column' "
+	git log --pretty='format:%h %><|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
-fa33ab1           message two          Z
-7cd6c63           message one          Z
-1711bf9             add bar            Z
-af20c06             initial            Z
+$head1           message two          Z
+$head2           message one          Z
+$head3             add bar            Z
+$head4             initial            Z
 EOF
 	test_cmp expected actual
-'
+"
 
 test_expect_success 'center alignment formatting with no padding' '
 	git log --pretty="format:%><(1)%s" >actual &&
-- 
1.8.3.1.15.g5c23c1e

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

* [PATCH v5 4/5] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting
  2013-01-24  9:10                     ` [PATCH v4 0/4] Reroll patches against v1.8.1.1 Alexey Shumkin
                                         ` (3 preceding siblings ...)
  2013-06-20  9:26                       ` [PATCH v5 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
@ 2013-06-20  9:26                       ` Alexey Shumkin
  2013-06-20 20:23                         ` Junio C Hamano
  2013-06-20  9:26                       ` [PATCH v5 5/5] pretty: " Alexey Shumkin
  5 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-20  9:26 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 22349 bytes --]

The following two commands are expected to give the same output to a terminal:

	$ git log --oneline --no-color
	$ git log --pretty=format:'%h %s'

However, the former pays attention to i18n.logOutputEncoding
configuration, while the latter does not when it format "%s".
Log messages written in an encoding i18n.commitEncoding which differs
from terminal encoding are shown corrupted with the latter even
when i18n.logOutputEncoding and terminal encoding are the same.

The same corruption is true for
	$ git diff --submodule=log
and
	$ git rev-list --pretty=format:%s HEAD
and
	$ git reset --hard

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 t/t4041-diff-submodule-option.sh |  35 +++++----
 t/t4205-log-pretty-formats.sh    | 149 ++++++++++++++++++++++++---------------
 t/t6006-rev-list-format.sh       |  85 +++++++++++++++-------
 t/t7102-reset.sh                 |  29 +++++++-
 4 files changed, 200 insertions(+), 98 deletions(-)

diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 32d4a60..22bf4df 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 #
 # Copyright (c) 2009 Jens Lehmann, based on t7401 by Ping Yin
+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
 #
 
 test_description='Support for verbose submodule differences in git diff
@@ -10,6 +11,9 @@ This test tries to verify the sanity of the --submodule option of git diff.
 
 . ./test-lib.sh
 
+# String "added" in Russian, encoded in UTF-8, used in
+# sample commit log messages in add_file() function below.
+added=$(printf "\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275")
 add_file () {
 	(
 		cd "$1" &&
@@ -19,7 +23,8 @@ add_file () {
 			echo "$name" >"$name" &&
 			git add "$name" &&
 			test_tick &&
-			git commit -m "Add $name" || exit
+			msg_added_iso88595=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t iso88595) &&
+			git -c 'i18n.commitEncoding=iso88595' commit -m "$msg_added_iso88595"
 		done >/dev/null &&
 		git rev-parse --short --verify HEAD
 	)
@@ -89,29 +94,29 @@ test_expect_success 'diff.submodule does not affect plumbing' '
 commit_file sm1 &&
 head2=$(add_file sm1 foo3)
 
-test_expect_success 'modified submodule(forward)' '
+test_expect_failure 'modified submodule(forward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
-	  > Add foo3
+	  > Add foo3 ($added foo3)
 	EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'modified submodule(forward)' '
+test_expect_failure 'modified submodule(forward)' '
 	git diff --submodule=log >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
-	  > Add foo3
+	  > Add foo3 ($added foo3)
 	EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'modified submodule(forward) --submodule' '
+test_expect_failure 'modified submodule(forward) --submodule' '
 	git diff --submodule >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
-	  > Add foo3
+	  > Add foo3 ($added foo3)
 	EOF
 	test_cmp expected actual
 '
@@ -138,25 +143,25 @@ head3=$(
 	git rev-parse --short --verify HEAD
 )
 
-test_expect_success 'modified submodule(backward)' '
+test_expect_failure 'modified submodule(backward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head2..$head3 (rewind):
-	  < Add foo3
-	  < Add foo2
+	  < Add foo3 ($added foo3)
+	  < Add foo2 ($added foo2)
 	EOF
 	test_cmp expected actual
 '
 
 head4=$(add_file sm1 foo4 foo5)
-test_expect_success 'modified submodule(backward and forward)' '
+test_expect_failure 'modified submodule(backward and forward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head2...$head4:
-	  > Add foo5
-	  > Add foo4
-	  < Add foo3
-	  < Add foo2
+	  > Add foo5 ($added foo5)
+	  > Add foo4 ($added foo4)
+	  < Add foo3 ($added foo3)
+	  < Add foo2 ($added foo2)
 	EOF
 	test_cmp expected actual
 '
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 6d8d457..6a56019 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -1,20 +1,43 @@
 #!/bin/sh
 #
 # Copyright (c) 2010, Will Palmer
+# Copyright (c) 2011, Alexey Shumkin (+ non-UTF-8 commit encoding tests)
 #
 
 test_description='Test pretty formats'
 . ./test-lib.sh
 
+commit_msg() {
+	# String "initial commit" partly in Russian, encoded in UTF-8,
+	# used as a commit log message below.
+	msg=$(printf "initial \320\272\320\276\320\274\320\274\320\270\321\202")
+	if test -n "$1"
+	then
+		msg=$(echo $msg | iconv -f utf-8 -t $1)
+	fi
+	if test -n "$2" -a -n "$3"
+	then
+		# cut string, replace cut part with two dots
+		# $2 - chars count from the beginning of the string
+		# $3 - "trailing" chars
+		# LC_ALL is set to make `sed` interpret "." as a UTF-8 char not a byte
+		# as it does with C locale
+		msg=$(echo $msg | LC_ALL=en_US.UTF-8 sed -e "s/^\(.\{$2\}\)$3/\1../")
+	fi
+	echo $msg
+}
+
 test_expect_success 'set up basic repos' '
 	>foo &&
 	>bar &&
 	git add foo &&
 	test_tick &&
-	git commit -m initial &&
+	git config i18n.commitEncoding iso88595 &&
+	git commit -m "$(commit_msg iso88595)" &&
 	git add bar &&
 	test_tick &&
-	git commit -m "add bar"
+	git commit -m "add bar" &&
+	git config --unset i18n.commitEncoding
 '
 
 test_expect_success 'alias builtin format' '
@@ -38,6 +61,20 @@ test_expect_success 'alias user-defined format' '
 	test_cmp expected actual
 '
 
+test_expect_success 'alias user-defined tformat with %s (iso88595 encoding)' '
+	git config i18n.logOutputEncoding iso88595 &&
+	git log --oneline >expected-s &&
+	git log --pretty="tformat:%h %s" >actual-s &&
+	git config --unset i18n.logOutputEncoding &&
+	test_cmp expected-s actual-s
+'
+
+test_expect_failure 'alias user-defined tformat with %s (utf-8 encoding)' '
+	git log --oneline >expected-s &&
+	git log --pretty="tformat:%h %s" >actual-s &&
+	test_cmp expected-s actual-s
+'
+
 test_expect_success 'alias user-defined tformat' '
 	git log --pretty="tformat:%h" >expected &&
 	git config pretty.test-alias "tformat:%h" &&
@@ -71,22 +108,22 @@ test_expect_success 'alias loop' '
 	test_must_fail git log --pretty=test-foo
 '
 
-test_expect_success 'NUL separation' '
-	printf "add bar\0initial" >expected &&
+test_expect_failure 'NUL separation' '
+	printf "add bar\0$(commit_msg)" >expected &&
 	git log -z --pretty="format:%s" >actual &&
 	test_cmp expected actual
 '
 
-test_expect_success 'NUL termination' '
-	printf "add bar\0initial\0" >expected &&
+test_expect_failure 'NUL termination' '
+	printf "add bar\0$(commit_msg)\0" >expected &&
 	git log -z --pretty="tformat:%s" >actual &&
 	test_cmp expected actual
 '
 
-test_expect_success 'NUL separation with --stat' '
+test_expect_failure 'NUL separation with --stat' '
 	stat0_part=$(git diff --stat HEAD^ HEAD) &&
 	stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
-	printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n" >expected &&
+	printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected &&
 	git log -z --stat --pretty="format:%s" >actual &&
 	test_i18ncmp expected actual
 '
@@ -94,7 +131,7 @@ test_expect_success 'NUL separation with --stat' '
 test_expect_failure 'NUL termination with --stat' '
 	stat0_part=$(git diff --stat HEAD^ HEAD) &&
 	stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
-	printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n\0" >expected &&
+	printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n0" >expected &&
 	git log -z --stat --pretty="tformat:%s" >actual &&
 	test_i18ncmp expected actual
 '
@@ -108,20 +145,20 @@ test_expect_success 'setup more commits' '
 	head4=$(git rev-list --max-count=1 --abbrev-commit HEAD~3)
 '
 
-test_expect_success 'left alignment formatting' '
-	git log --pretty="format:%<(40)%s" >actual &&
+test_expect_failure 'left alignment formatting' "
+	git log --pretty='format:%<(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
 message two                            Z
 message one                            Z
 add bar                                Z
-initial                                Z
+$(commit_msg)                         Z
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'left alignment formatting at the nth column' "
+test_expect_failure 'left alignment formatting at the nth column' "
 	git log --pretty='format:%h %<|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -129,77 +166,77 @@ test_expect_success 'left alignment formatting at the nth column' "
 $head1 message two                    Z
 $head2 message one                    Z
 $head3 add bar                        Z
-$head4 initial                        Z
+$head4 $(commit_msg)                 Z
 EOF
 	test_cmp expected actual
 "
 
-test_expect_success 'left alignment formatting with no padding' '
-	git log --pretty="format:%<(1)%s" >actual &&
+test_expect_failure 'left alignment formatting with no padding' "
+	git log --pretty='format:%<(1)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	cat <<\EOF >expected &&
 message two
 message one
 add bar
-initial
+$(commit_msg)
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'left alignment formatting with trunc' '
-	git log --pretty="format:%<(10,trunc)%s" >actual &&
+test_expect_failure 'left alignment formatting with trunc' "
+	git log --pretty='format:%<(10,trunc)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
 message ..
 message ..
 add bar  Z
-initial  Z
+$(commit_msg "" "8" ".\+$")
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'left alignment formatting with ltrunc' '
-	git log --pretty="format:%<(10,ltrunc)%s" >actual &&
+test_expect_failure 'left alignment formatting with ltrunc' "
+	git log --pretty='format:%<(10,ltrunc)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
 ..sage two
 ..sage one
 add bar  Z
-initial  Z
+$(commit_msg "" "0" ".\{6\}")
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'left alignment formatting with mtrunc' '
-	git log --pretty="format:%<(10,mtrunc)%s" >actual &&
+test_expect_failure 'left alignment formatting with mtrunc' "
+	git log --pretty='format:%<(10,mtrunc)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
 mess.. two
 mess.. one
 add bar  Z
-initial  Z
+$(commit_msg "" "4" ".\{6\}")
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'right alignment formatting' '
-	git log --pretty="format:%>(40)%s" >actual &&
+test_expect_failure 'right alignment formatting' "
+	git log --pretty='format:%>(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
 Z                            message two
 Z                            message one
 Z                                add bar
-Z                                initial
+Z                         $(commit_msg)
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'right alignment formatting at the nth column' "
+test_expect_failure 'right alignment formatting at the nth column' "
 	git log --pretty='format:%h %>|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -207,38 +244,38 @@ test_expect_success 'right alignment formatting at the nth column' "
 $head1                      message two
 $head2                      message one
 $head3                          add bar
-$head4                          initial
+$head4                   $(commit_msg)
 EOF
 	test_cmp expected actual
 "
 
-test_expect_success 'right alignment formatting with no padding' '
-	git log --pretty="format:%>(1)%s" >actual &&
+test_expect_failure 'right alignment formatting with no padding' "
+	git log --pretty='format:%>(1)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	cat <<\EOF >expected &&
 message two
 message one
 add bar
-initial
+$(commit_msg)
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'center alignment formatting' '
-	git log --pretty="format:%><(40)%s" >actual &&
+test_expect_failure 'center alignment formatting' "
+	git log --pretty='format:%><(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
 Z             message two              Z
 Z             message one              Z
 Z               add bar                Z
-Z               initial                Z
+Z            $(commit_msg)            Z
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'center alignment formatting at the nth column' "
+test_expect_failure 'center alignment formatting at the nth column' "
 	git log --pretty='format:%h %><|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -246,36 +283,36 @@ test_expect_success 'center alignment formatting at the nth column' "
 $head1           message two          Z
 $head2           message one          Z
 $head3             add bar            Z
-$head4             initial            Z
+$head4          $(commit_msg)        Z
 EOF
 	test_cmp expected actual
 "
 
-test_expect_success 'center alignment formatting with no padding' '
-	git log --pretty="format:%><(1)%s" >actual &&
+test_expect_failure 'center alignment formatting with no padding' "
+	git log --pretty='format:%><(1)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	cat <<\EOF >expected &&
 message two
 message one
 add bar
-initial
+$(commit_msg)
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'left/right alignment formatting with stealing' '
-	git commit --amend -m short --author "long long long <long@me.com>" &&
-	git log --pretty="format:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
+test_expect_failure 'left/right alignment formatting with stealing' "
+	git commit --amend -m short --author 'long long long <long@me.com>' &&
+	git log --pretty='format:%<(10,trunc)%s%>>(10,ltrunc)% an' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	cat <<\EOF >expected &&
 short long  long long
 message ..   A U Thor
 add bar      A U Thor
-initial      A U Thor
+$(commit_msg "" "8" ".\+$")   A U Thor
 EOF
 	test_cmp expected actual
-'
+"
 
 test_done
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index d32e65e..36e4cc0 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -1,36 +1,62 @@
 #!/bin/sh
 
+# Copyright (c) 2009 Jens Lehmann
+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
+
 test_description='git rev-list --pretty=format test'
 
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-terminal.sh
 
 test_tick
+# String "added" in Russian, encoded in UTF-8,
+# used as a commit log message below.
+added=$(printf "added (\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275) foo")
+added_iso88595=$(echo "$added" | iconv -f utf-8 -t iso88595)
+# same but "changed"
+changed=$(printf "changed (\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275) foo")
+changed_iso88595=$(echo "$changed" | iconv -f utf-8 -t iso88595)
+
 test_expect_success 'setup' '
 	: >foo &&
 	git add foo &&
-	git commit -m "added foo" &&
+	git config i18n.commitEncoding iso88595 &&
+	git commit -m "$added_iso88595" &&
 	head1=$(git rev-parse --verify HEAD) &&
 	head1_short=$(git rev-parse --short $head1) &&
 	tree1=$(git cat-file commit HEAD | sed -n -e "s/^tree //p" -e "/^$/q") &&
 	tree1_short=$(git rev-parse --short $tree1) &&
-	echo changed >foo &&
-	git commit -a -m "changed foo" &&
+	echo "$changed" > foo &&
+	git commit -a -m "$changed_iso88595" &&
 	head2=$(git rev-parse --verify HEAD) &&
 	head2_short=$(git rev-parse --short $head2) &&
 	head2_parent=$(git cat-file commit HEAD | sed -n -e "s/^parent //p" -e "/^$/q") &&
 	head2_parent_short=$(git rev-parse --short $head2_parent) &&
 	tree2=$(git cat-file commit HEAD | sed -n -e "s/^tree //p" -e "/^$/q") &&
-	tree2_short=$(git rev-parse --short $tree2)
+	tree2_short=$(git rev-parse --short $tree2) &&
+	git config --unset i18n.commitEncoding
 '
 
-# usage: test_format name format_string <expected_output
+# usage: test_format [failure] name format_string <expected_output
 test_format () {
+	local must_fail=0
+	# if parameters count is more than 2 then test must fail
+	if test $# -gt 2
+	then
+		must_fail=1
+		# remove first parameter which is flag for test failure
+		shift
+	fi
 	cat >expect.$1
-	test_expect_success "format $1" "
-		git rev-list --pretty=format:'$2' master >output.$1 &&
-		test_cmp expect.$1 output.$1
-	"
+	name="format $1"
+	command="git rev-list --pretty=format:'$2' master >output.$1 &&
+		test_cmp expect.$1 output.$1"
+	if test $must_fail -eq 1
+	then
+		test_expect_failure "$name" "$command"
+	else
+		test_expect_success "$name" "$command"
+	fi
 }
 
 # Feed to --format to provide predictable colored sequences.
@@ -112,14 +138,16 @@ EOF
 
 test_format encoding %e <<EOF
 commit $head2
+iso88595
 commit $head1
+iso88595
 EOF
 
-test_format subject %s <<EOF
+test_format failure subject %s <<EOF
 commit $head2
-changed foo
+$changed
 commit $head1
-added foo
+$added
 EOF
 
 test_format body %b <<EOF
@@ -127,12 +155,12 @@ commit $head2
 commit $head1
 EOF
 
-test_format raw-body %B <<EOF
+test_format failure raw-body %B <<EOF
 commit $head2
-changed foo
+$changed
 
 commit $head1
-added foo
+$added
 
 EOF
 
@@ -192,42 +220,49 @@ test_expect_success '%C(auto) respects --color=auto (stdout not tty)' '
 	)
 '
 
-cat >commit-msg <<'EOF'
+iconv -f utf-8 -t iso8859-1 > commit-msg <<EOF
 Test printing of complex bodies
 
 This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
-include an iso8859 character: ¡bueno!
+include an iso8859 character: ¡bueno!
 EOF
 
 test_expect_success 'setup complex body' '
 	git config i18n.commitencoding iso8859-1 &&
 	echo change2 >foo && git commit -a -F commit-msg &&
 	head3=$(git rev-parse --verify HEAD) &&
-	head3_short=$(git rev-parse --short $head3)
+	head3_short=$(git rev-parse --short $head3) &&
+	# unset commit encoding config
+	# otherwise %e does not print encoding value
+	# and following test fails
+	git config --unset i18n.commitEncoding
+
 '
 
 test_format complex-encoding %e <<EOF
 commit $head3
 iso8859-1
 commit $head2
+iso88595
 commit $head1
+iso88595
 EOF
 
-test_format complex-subject %s <<EOF
+test_format failure complex-subject %s <<EOF
 commit $head3
 Test printing of complex bodies
 commit $head2
-changed foo
+$changed
 commit $head1
-added foo
+$added
 EOF
 
-test_format complex-body %b <<EOF
+test_format failure complex-body %b <<EOF
 commit $head3
 This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
-include an iso8859 character: ¡bueno!
+include an iso8859 character: ¡bueno!
 
 commit $head2
 commit $head1
@@ -281,12 +316,12 @@ test_expect_success 'add LF before non-empty (2)' '
 
 test_expect_success 'add SP before non-empty (1)' '
 	git show -s --pretty=format:"%s% bThanks" HEAD^^ >actual &&
-	test $(wc -w <actual) = 2
+	test $(wc -w <actual) = 3
 '
 
 test_expect_success 'add SP before non-empty (2)' '
 	git show -s --pretty=format:"%s% sThanks" HEAD^^ >actual &&
-	test $(wc -w <actual) = 4
+	test $(wc -w <actual) = 6
 '
 
 test_expect_success '--abbrev' '
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 05dfb27..48534f1 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -9,6 +9,17 @@ Documented tests for git reset'
 
 . ./test-lib.sh
 
+commit_msg() {
+	# String "2nd file modified" in Russian, encoded in UTF-8,
+	# used as a commit log message below.
+	msg=$(printf "modify 2nd file (\320\270\320\267\320\274\320\265\320\275\321\221\320\275 \321\204\320\260\320\271\320\273)")
+	if test -n "$1"
+	then
+		msg=$(echo $msg | iconv -f utf-8 -t $1)
+	fi
+	echo $msg
+}
+
 test_expect_success 'creating initial files and commits' '
 	test_tick &&
 	echo "1st file" >first &&
@@ -28,7 +39,7 @@ test_expect_success 'creating initial files and commits' '
 
 	echo "1st line 2nd file" >secondfile &&
 	echo "2nd line 2nd file" >>secondfile &&
-	git commit -a -m "modify 2nd file" &&
+	git -c "i18n.commitEncoding=iso88595" commit -a -m "$(commit_msg iso88595)" &&
 	head5=$(git rev-parse --verify HEAD)
 '
 # git log --pretty=oneline # to see those SHA1 involved
@@ -44,6 +55,20 @@ check_changes () {
 	done | test_cmp .cat_expect -
 }
 
+test_expect_failure 'reset --hard message' '
+	hex=$(git log -1 --format="%h") &&
+	git reset --hard > .actual &&
+	echo HEAD is now at $hex $(commit_msg) > .expected &&
+	test_cmp .expected .actual
+'
+
+test_expect_success 'reset --hard message (iso88595 logoutencoding)' '
+	hex=$(git log -1 --format="%h") &&
+	git -c "i18n.logOutputEncoding=iso88595" reset --hard > .actual &&
+	echo HEAD is now at $hex $(commit_msg iso88595) > .expected &&
+	test_cmp .expected .actual
+'
+
 >.diff_expect
 >.cached_expect
 cat >.cat_expect <<EOF
@@ -304,7 +329,7 @@ test_expect_success 'redoing the last two commits should succeed' '
 
 	echo "1st line 2nd file" >secondfile &&
 	echo "2nd line 2nd file" >>secondfile &&
-	git commit -a -m "modify 2nd file" &&
+	git -c "i18n.commitEncoding=iso88595" commit -a -m "$(commit_msg iso88595)" &&
 	check_changes $head5
 '
 
-- 
1.8.3.1.15.g5c23c1e

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

* [PATCH v5 5/5] pretty: user format ignores i18n.logOutputEncoding setting
  2013-01-24  9:10                     ` [PATCH v4 0/4] Reroll patches against v1.8.1.1 Alexey Shumkin
                                         ` (4 preceding siblings ...)
  2013-06-20  9:26                       ` [PATCH v5 4/5] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting Alexey Shumkin
@ 2013-06-20  9:26                       ` Alexey Shumkin
  2013-06-20 20:37                         ` Junio C Hamano
  5 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-20  9:26 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

The following two commands are expected to give the same output to a terminal:

	$ git log --oneline --no-color
	$ git log --pretty=format:'%h %s'

However, the former pays attention to i18n.logOutputEncoding
configuration, while the latter does not when it format "%s".
Log messages written in an encoding i18n.commitEncoding which differs
from terminal encoding are shown corrupted with the latter even
when i18n.logOutputEncoding and terminal encoding are the same.

The same corruption is true for
	$ git diff --submodule=log
and
	$ git rev-list --pretty=format:%s HEAD
and
	$ git reset --hard

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 builtin/reset.c                  |  8 ++++++--
 builtin/rev-list.c               |  1 +
 builtin/shortlog.c               |  1 +
 log-tree.c                       |  1 +
 submodule.c                      |  3 +++
 t/t4041-diff-submodule-option.sh | 10 +++++-----
 t/t4205-log-pretty-formats.sh    | 34 +++++++++++++++++-----------------
 t/t6006-rev-list-format.sh       |  8 ++++----
 t/t7102-reset.sh                 |  2 +-
 9 files changed, 39 insertions(+), 29 deletions(-)

diff --git a/builtin/reset.c b/builtin/reset.c
index 6032131..b23ed63 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -92,11 +92,15 @@ static int reset_index(const unsigned char *sha1, int reset_type, int quiet)
 
 static void print_new_head_line(struct commit *commit)
 {
-	const char *hex, *body;
+	const char *hex, *body, *encoding;
 
 	hex = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
 	printf(_("HEAD is now at %s"), hex);
-	body = strstr(commit->buffer, "\n\n");
+	encoding = get_log_output_encoding();
+	body = logmsg_reencode(commit, NULL, encoding);
+	if (!body)
+		body = commit->buffer;
+	body = strstr(body, "\n\n");
 	if (body) {
 		const char *eol;
 		size_t len;
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 67701be..a5ec30d 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -111,6 +111,7 @@ static void show_commit(struct commit *commit, void *data)
 		ctx.date_mode = revs->date_mode;
 		ctx.date_mode_explicit = revs->date_mode_explicit;
 		ctx.fmt = revs->commit_format;
+		ctx.output_encoding = get_log_output_encoding();
 		pretty_print_commit(&ctx, commit, &buf);
 		if (revs->graph) {
 			if (buf.len) {
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 1fd6f8a..1434f8f 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -137,6 +137,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
 		ctx.subject = "";
 		ctx.after_subject = "";
 		ctx.date_mode = DATE_NORMAL;
+		ctx.output_encoding = get_log_output_encoding();
 		pretty_print_commit(&ctx, commit, &ufbuf);
 		buffer = ufbuf.buf;
 	} else if (*buffer) {
diff --git a/log-tree.c b/log-tree.c
index 1946e9c..5277d3e 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -616,6 +616,7 @@ void show_log(struct rev_info *opt)
 	ctx.fmt = opt->commit_format;
 	ctx.mailmap = opt->mailmap;
 	ctx.color = opt->diffopt.use_color;
+	ctx.output_encoding = get_log_output_encoding();
 	pretty_print_commit(&ctx, commit, &msgbuf);
 
 	if (opt->add_signoff)
diff --git a/submodule.c b/submodule.c
index 1821a5b..baa8669 100644
--- a/submodule.c
+++ b/submodule.c
@@ -222,10 +222,13 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
 	static const char format[] = "  %m %s";
 	struct strbuf sb = STRBUF_INIT;
 	struct commit *commit;
+	const char *log_output_encoding;
 
+	log_output_encoding = get_log_output_encoding();
 	while ((commit = get_revision(rev))) {
 		struct pretty_print_context ctx = {0};
 		ctx.date_mode = rev->date_mode;
+		ctx.output_encoding = log_output_encoding;
 		strbuf_setlen(&sb, 0);
 		strbuf_addstr(&sb, line_prefix);
 		if (commit->object.flags & SYMMETRIC_LEFT) {
diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 22bf4df..ce192b0 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -94,7 +94,7 @@ test_expect_success 'diff.submodule does not affect plumbing' '
 commit_file sm1 &&
 head2=$(add_file sm1 foo3)
 
-test_expect_failure 'modified submodule(forward)' '
+test_expect_success 'modified submodule(forward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
@@ -103,7 +103,7 @@ test_expect_failure 'modified submodule(forward)' '
 	test_cmp expected actual
 '
 
-test_expect_failure 'modified submodule(forward)' '
+test_expect_success 'modified submodule(forward)' '
 	git diff --submodule=log >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
@@ -112,7 +112,7 @@ test_expect_failure 'modified submodule(forward)' '
 	test_cmp expected actual
 '
 
-test_expect_failure 'modified submodule(forward) --submodule' '
+test_expect_success 'modified submodule(forward) --submodule' '
 	git diff --submodule >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
@@ -143,7 +143,7 @@ head3=$(
 	git rev-parse --short --verify HEAD
 )
 
-test_expect_failure 'modified submodule(backward)' '
+test_expect_success 'modified submodule(backward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head2..$head3 (rewind):
@@ -154,7 +154,7 @@ test_expect_failure 'modified submodule(backward)' '
 '
 
 head4=$(add_file sm1 foo4 foo5)
-test_expect_failure 'modified submodule(backward and forward)' '
+test_expect_success 'modified submodule(backward and forward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head2...$head4:
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 6a56019..1739a86 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -69,7 +69,7 @@ test_expect_success 'alias user-defined tformat with %s (iso88595 encoding)' '
 	test_cmp expected-s actual-s
 '
 
-test_expect_failure 'alias user-defined tformat with %s (utf-8 encoding)' '
+test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' '
 	git log --oneline >expected-s &&
 	git log --pretty="tformat:%h %s" >actual-s &&
 	test_cmp expected-s actual-s
@@ -108,19 +108,19 @@ test_expect_success 'alias loop' '
 	test_must_fail git log --pretty=test-foo
 '
 
-test_expect_failure 'NUL separation' '
+test_expect_success 'NUL separation' '
 	printf "add bar\0$(commit_msg)" >expected &&
 	git log -z --pretty="format:%s" >actual &&
 	test_cmp expected actual
 '
 
-test_expect_failure 'NUL termination' '
+test_expect_success 'NUL termination' '
 	printf "add bar\0$(commit_msg)\0" >expected &&
 	git log -z --pretty="tformat:%s" >actual &&
 	test_cmp expected actual
 '
 
-test_expect_failure 'NUL separation with --stat' '
+test_expect_success 'NUL separation with --stat' '
 	stat0_part=$(git diff --stat HEAD^ HEAD) &&
 	stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
 	printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected &&
@@ -145,7 +145,7 @@ test_expect_success 'setup more commits' '
 	head4=$(git rev-list --max-count=1 --abbrev-commit HEAD~3)
 '
 
-test_expect_failure 'left alignment formatting' "
+test_expect_success 'left alignment formatting' "
 	git log --pretty='format:%<(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -158,7 +158,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'left alignment formatting at the nth column' "
+test_expect_success 'left alignment formatting at the nth column' "
 	git log --pretty='format:%h %<|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -171,7 +171,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'left alignment formatting with no padding' "
+test_expect_success 'left alignment formatting with no padding' "
 	git log --pretty='format:%<(1)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -184,7 +184,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'left alignment formatting with trunc' "
+test_expect_success 'left alignment formatting with trunc' "
 	git log --pretty='format:%<(10,trunc)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -197,7 +197,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'left alignment formatting with ltrunc' "
+test_expect_success 'left alignment formatting with ltrunc' "
 	git log --pretty='format:%<(10,ltrunc)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -210,7 +210,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'left alignment formatting with mtrunc' "
+test_expect_success 'left alignment formatting with mtrunc' "
 	git log --pretty='format:%<(10,mtrunc)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -223,7 +223,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'right alignment formatting' "
+test_expect_success 'right alignment formatting' "
 	git log --pretty='format:%>(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -236,7 +236,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'right alignment formatting at the nth column' "
+test_expect_success 'right alignment formatting at the nth column' "
 	git log --pretty='format:%h %>|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -249,7 +249,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'right alignment formatting with no padding' "
+test_expect_success 'right alignment formatting with no padding' "
 	git log --pretty='format:%>(1)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -262,7 +262,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'center alignment formatting' "
+test_expect_success 'center alignment formatting' "
 	git log --pretty='format:%><(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -275,7 +275,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'center alignment formatting at the nth column' "
+test_expect_success 'center alignment formatting at the nth column' "
 	git log --pretty='format:%h %><|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -288,7 +288,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'center alignment formatting with no padding' "
+test_expect_success 'center alignment formatting with no padding' "
 	git log --pretty='format:%><(1)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -301,7 +301,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'left/right alignment formatting with stealing' "
+test_expect_success 'left/right alignment formatting with stealing' "
 	git commit --amend -m short --author 'long long long <long@me.com>' &&
 	git log --pretty='format:%<(10,trunc)%s%>>(10,ltrunc)% an' >actual &&
 	# complete the incomplete line at the end
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 36e4cc0..055655c 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -143,7 +143,7 @@ commit $head1
 iso88595
 EOF
 
-test_format failure subject %s <<EOF
+test_format subject %s <<EOF
 commit $head2
 $changed
 commit $head1
@@ -155,7 +155,7 @@ commit $head2
 commit $head1
 EOF
 
-test_format failure raw-body %B <<EOF
+test_format raw-body %B <<EOF
 commit $head2
 $changed
 
@@ -249,7 +249,7 @@ commit $head1
 iso88595
 EOF
 
-test_format failure complex-subject %s <<EOF
+test_format complex-subject %s <<EOF
 commit $head3
 Test printing of complex bodies
 commit $head2
@@ -258,7 +258,7 @@ commit $head1
 $added
 EOF
 
-test_format failure complex-body %b <<EOF
+test_format complex-body %b <<EOF
 commit $head3
 This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 48534f1..5a7b383 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -55,7 +55,7 @@ check_changes () {
 	done | test_cmp .cat_expect -
 }
 
-test_expect_failure 'reset --hard message' '
+test_expect_success 'reset --hard message' '
 	hex=$(git log -1 --format="%h") &&
 	git reset --hard > .actual &&
 	echo HEAD is now at $hex $(commit_msg) > .expected &&
-- 
1.8.3.1.15.g5c23c1e

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

* Re: [PATCH v5 0/5] Reroll patches against v1.8.3.1
  2013-06-20  9:26                       ` [PATCH v5 0/5] Reroll patches against v1.8.3.1 Alexey Shumkin
@ 2013-06-20 20:10                         ` Junio C Hamano
  2013-06-25  8:55                         ` [PATCH v6 " Alexey Shumkin
                                           ` (5 subsequent siblings)
  6 siblings, 0 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-06-20 20:10 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git

Alexey Shumkin <Alex.Crezoff@gmail.com> writes:

> Alexey Shumkin (5):
>   t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
>   t7102 (reset): don't hardcode SHA-1 in expected outputs
>   t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
>   pretty: Add failing tests: user format ignores i18n.logOutputEncoding
>     setting
>   pretty: user format ignores i18n.logOutputEncoding setting

Next time, please jog readers' memory better by giving a bit more
descriptive cover letter.  "Reroll" is known by "v5" alrady, and
"against v1.8.3.1" certainly helps, but what this series is about is
unclear, especially because the end-game patch "user format ignores"
is rather badly stated.  It is unclear if it is a good thing that
user format ignores it and the patch makes sure that is the case, if
we currently ignore it in user format and the patch fixes it by
making user format pay attention to it, etc.

Thanks.

>  builtin/reset.c                  |   8 +-
>  builtin/rev-list.c               |   1 +
>  builtin/shortlog.c               |   1 +
>  log-tree.c                       |   1 +
>  submodule.c                      |   3 +
>  t/t4041-diff-submodule-option.sh |  25 +++--
>  t/t4205-log-pretty-formats.sh    | 179 ++++++++++++++++++++-------------
>  t/t6006-rev-list-format.sh       | 209 ++++++++++++++++++++++++---------------
>  t/t7102-reset.sh                 |  37 ++++++-
>  9 files changed, 299 insertions(+), 165 deletions(-)

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

* Re: [PATCH v5 4/5] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting
  2013-06-20  9:26                       ` [PATCH v5 4/5] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting Alexey Shumkin
@ 2013-06-20 20:23                         ` Junio C Hamano
  0 siblings, 0 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-06-20 20:23 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git

Alexey Shumkin <Alex.Crezoff@gmail.com> writes:

> @@ -19,7 +23,8 @@ add_file () {
>  			echo "$name" >"$name" &&
>  			git add "$name" &&
>  			test_tick &&
> -			git commit -m "Add $name" || exit
> +			msg_added_iso88595=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t iso88595) &&
> +			git -c 'i18n.commitEncoding=iso88595' commit -m "$msg_added_iso88595"

Hmph.  Do we know 8859-5 is available or do these need to be
protected with prereq?

Can these tests be done with 8859-1 i.e. something we already depend
on, by changing that $added message to latin-1, or is there something
very Russian specific breakage we want to test here?

If the former, please redo this entire patch (not just t4041) with
8859-1.

If there is some Russian specific breakage you cannot demonstrate
with 8859-1, then please explain it in the log message.

> diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
> index d32e65e..36e4cc0 100755
> --- a/t/t6006-rev-list-format.sh
> +++ b/t/t6006-rev-list-format.sh
> ...
> -# usage: test_format name format_string <expected_output
> +# usage: test_format [failure] name format_string <expected_output
>  test_format () {
> +	local must_fail=0

This breaks tests for non-bash users.  "local" is not even in POSIX.

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

* Re: [PATCH v5 5/5] pretty: user format ignores i18n.logOutputEncoding setting
  2013-06-20  9:26                       ` [PATCH v5 5/5] pretty: " Alexey Shumkin
@ 2013-06-20 20:37                         ` Junio C Hamano
  0 siblings, 0 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-06-20 20:37 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git

Alexey Shumkin <Alex.Crezoff@gmail.com> writes:

Subject: Re: [PATCH v5 5/5] pretty: user format ignores i18n.logOutputEncoding setting

That is a statement of fact, and does not tell much to the reader.

I think you are saying that in the current implementation,
logoutputencoding is not honored in user format, that it is a bug
that needs to be fixed (as opposed to "that is by design, the
scripts that read from --format='' is responsible for doing the
conversion"), and that this patch fixes it.

So

	pretty: --format output should honor logOutputEncoding

or something?  At least it says what is the _desired_ outcome with
"should", hints that the status-quo is different from that desired
outcome and implies that this is a patch to fix it.

The "Subject" line is very important as that is the only thing we
see in many summarizing output format, e.g. shortlog, cover letter
and merge message.

> The following two commands are expected to give the same output to a terminal:
>
> 	$ git log --oneline --no-color
> 	$ git log --pretty=format:'%h %s'
>
> However, the former pays attention to i18n.logOutputEncoding
> configuration, while the latter does not when it format "%s".
> Log messages written in an encoding i18n.commitEncoding which differs
> from terminal encoding are shown corrupted with the latter even
> when i18n.logOutputEncoding and terminal encoding are the same.
>
> The same corruption is true for
> 	$ git diff --submodule=log
> and
> 	$ git rev-list --pretty=format:%s HEAD
> and
> 	$ git reset --hard
>
> Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
> ---
>  builtin/reset.c                  |  8 ++++++--
>  builtin/rev-list.c               |  1 +
>  builtin/shortlog.c               |  1 +
>  log-tree.c                       |  1 +
>  submodule.c                      |  3 +++
>  t/t4041-diff-submodule-option.sh | 10 +++++-----
>  t/t4205-log-pretty-formats.sh    | 34 +++++++++++++++++-----------------
>  t/t6006-rev-list-format.sh       |  8 ++++----
>  t/t7102-reset.sh                 |  2 +-
>  9 files changed, 39 insertions(+), 29 deletions(-)
>
> diff --git a/builtin/reset.c b/builtin/reset.c
> index 6032131..b23ed63 100644
> --- a/builtin/reset.c
> +++ b/builtin/reset.c
> @@ -92,11 +92,15 @@ static int reset_index(const unsigned char *sha1, int reset_type, int quiet)
>  
>  static void print_new_head_line(struct commit *commit)
>  {
> -	const char *hex, *body;
> +	const char *hex, *body, *encoding;
>  
>  	hex = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
>  	printf(_("HEAD is now at %s"), hex);
> -	body = strstr(commit->buffer, "\n\n");
> +	encoding = get_log_output_encoding();
> +	body = logmsg_reencode(commit, NULL, encoding);


> +	if (!body)
> +		body = commit->buffer;

Does this happen?  I thought body, without an error, can be the same
as commit->buffer.

> +	body = strstr(body, "\n\n");
>  	if (body) {
>  		const char *eol;
>  		size_t len;

Do we have a leak here?  body may point at a new piece of memory
logmsg_reencode() have allocated to hold the UTF-8 version of your
8859-5 message in commit->buffer.

It would be more like this, no?

diff --git a/builtin/reset.c b/builtin/reset.c
index 6032131..8d22ffe 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -92,11 +92,13 @@ static int reset_index(const unsigned char *sha1, int reset_type, int quiet)
 
 static void print_new_head_line(struct commit *commit)
 {
-	const char *hex, *body;
+	const char *hex, *body, *msg, *encoding; 
 
 	hex = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
 	printf(_("HEAD is now at %s"), hex);
-	body = strstr(commit->buffer, "\n\n");
+
+	msg = logmsg_reencode(commit, NULL, get_log_output_encoding());
+	body = strstr(msg, "\n\n");
 	if (body) {
 		const char *eol;
 		size_t len;
@@ -107,6 +109,7 @@ static void print_new_head_line(struct commit *commit)
 	}
 	else
 		printf("\n");
+	logmsg_free(msg, commit);
 }
 
 static void update_index_from_diff(struct diff_queue_struct *q,

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

* Re: [PATCH v5 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
  2013-06-20  9:26                       ` [PATCH v5 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
@ 2013-06-20 20:38                         ` Junio C Hamano
  0 siblings, 0 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-06-20 20:38 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git

Alexey Shumkin <Alex.Crezoff@gmail.com> writes:

> The expected SHA-1 digests are always available in variables. Use
> them instead of hardcoding.
>
> Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
> ---
>  t/t6006-rev-list-format.sh | 142 +++++++++++++++++++++++++--------------------
>  1 file changed, 79 insertions(+), 63 deletions(-)
>
> diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
> index 0393c9f..d32e65e 100755
> --- a/t/t6006-rev-list-format.sh
> +++ b/t/t6006-rev-list-format.sh
> @@ -7,8 +7,21 @@ test_description='git rev-list --pretty=format test'
>  
>  test_tick
>  test_expect_success 'setup' '
> -touch foo && git add foo && git commit -m "added foo" &&
> -  echo changed >foo && git commit -a -m "changed foo"
> +	: >foo &&
> +	git add foo &&
> +	git commit -m "added foo" &&
> +	head1=$(git rev-parse --verify HEAD) &&
> +	head1_short=$(git rev-parse --short $head1) &&
> +	tree1=$(git cat-file commit HEAD | sed -n -e "s/^tree //p" -e "/^$/q") &&
> +	tree1_short=$(git rev-parse --short $tree1) &&
> +	echo changed >foo &&
> +	git commit -a -m "changed foo" &&
> +	head2=$(git rev-parse --verify HEAD) &&
> +	head2_short=$(git rev-parse --short $head2) &&
> +	head2_parent=$(git cat-file commit HEAD | sed -n -e "s/^parent //p" -e "/^$/q") &&
> +	head2_parent_short=$(git rev-parse --short $head2_parent) &&
> +	tree2=$(git cat-file commit HEAD | sed -n -e "s/^tree //p" -e "/^$/q") &&

With modern Git, you can (and would) write this as

	tree2=$(git rev-parse HEAD:)

(the same for tree1).  Other than that, looks sensible.

Will queue with a tweak.

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

* Re: [PATCH v5 3/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
  2013-06-20  9:26                       ` [PATCH v5 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
@ 2013-06-20 20:38                         ` Junio C Hamano
  0 siblings, 0 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-06-20 20:38 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git

Alexey Shumkin <Alex.Crezoff@gmail.com> writes:

> The expected SHA-1 digests are always available in variables. Use
> them instead of hardcoding.
>
> Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
> ---
>  t/t4205-log-pretty-formats.sh | 48 +++++++++++++++++++++++--------------------
>  1 file changed, 26 insertions(+), 22 deletions(-)
>
> diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
> index 26fbfde..6d8d457 100755
> --- a/t/t4205-log-pretty-formats.sh
> +++ b/t/t4205-log-pretty-formats.sh
> @@ -101,7 +101,11 @@ test_expect_failure 'NUL termination with --stat' '
>  
>  test_expect_success 'setup more commits' '
>  	test_commit "message one" one one message-one &&
> -	test_commit "message two" two two message-two
> +	test_commit "message two" two two message-two &&
> +	head1=$(git rev-list --max-count=1 --abbrev-commit HEAD~0) &&
> +	head2=$(git rev-list --max-count=1 --abbrev-commit HEAD~1) &&
> +	head3=$(git rev-list --max-count=1 --abbrev-commit HEAD~2) &&
> +	head4=$(git rev-list --max-count=1 --abbrev-commit HEAD~3)

Hmmph.  Why not rev-parse --short like in your 1/5?

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

* [PATCH v6 0/5] Reroll patches against v1.8.3.1
  2013-06-20  9:26                       ` [PATCH v5 0/5] Reroll patches against v1.8.3.1 Alexey Shumkin
  2013-06-20 20:10                         ` Junio C Hamano
@ 2013-06-25  8:55                         ` Alexey Shumkin
  2013-06-25 19:28                           ` Junio C Hamano
                                             ` (6 more replies)
  2013-06-25  8:55                         ` [PATCH v6 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
                                           ` (4 subsequent siblings)
  6 siblings, 7 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-25  8:55 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

It's all started here [http://thread.gmane.org/gmane.comp.version-control.git/177634]
and recently continued later [http://thread.gmane.org/gmane.comp.version-control.git/214419]

v6 of this patch series includes Junio's suggestions against v5:

1. [PATCH v6 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
	using modern 'git rev-parse HEAD:' git syntax to get commit tree ID
2. [PATCH v6 2/5] t7102 (reset): don't hardcode SHA-1 in expected outputs
	untouched
3. [PATCH v6 3/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
	using 'rev-parse --short' instead of 'git rev-list --max-count=1 --abbrev-commit'
4. [PATCH v6 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
	iso8859-5 encoding reverted back to cp1251 encoding (as it was in v4 series)
	reworded log message
5. [PATCH v6 5/5] pretty: --format output should honor logOutputEncoding
	reworded log message


Alexey Shumkin (5):
  t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
  t7102 (reset): don't hardcode SHA-1 in expected outputs
  t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
  pretty: Add failing tests: --format output should honor
    logOutputEncoding
  pretty: --format output should honor logOutputEncoding

 builtin/reset.c                  |   6 +-
 builtin/rev-list.c               |   1 +
 builtin/shortlog.c               |   1 +
 log-tree.c                       |   1 +
 submodule.c                      |   1 +
 t/t4041-diff-submodule-option.sh |  25 +++--
 t/t4205-log-pretty-formats.sh    | 179 ++++++++++++++++++++-------------
 t/t6006-rev-list-format.sh       | 207 ++++++++++++++++++++++++---------------
 t/t7102-reset.sh                 |  37 ++++++-
 9 files changed, 293 insertions(+), 165 deletions(-)

-- 
1.8.3.1.15.g5c23c1e

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

* [PATCH v6 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
  2013-06-20  9:26                       ` [PATCH v5 0/5] Reroll patches against v1.8.3.1 Alexey Shumkin
  2013-06-20 20:10                         ` Junio C Hamano
  2013-06-25  8:55                         ` [PATCH v6 " Alexey Shumkin
@ 2013-06-25  8:55                         ` Alexey Shumkin
  2013-06-25  8:55                         ` [PATCH v6 2/5] t7102 (reset): " Alexey Shumkin
                                           ` (3 subsequent siblings)
  6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-25  8:55 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 7061 bytes --]

The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 t/t6006-rev-list-format.sh | 140 +++++++++++++++++++++++++--------------------
 1 file changed, 77 insertions(+), 63 deletions(-)

diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 0393c9f..cc1008d 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -7,8 +7,19 @@ test_description='git rev-list --pretty=format test'
 
 test_tick
 test_expect_success 'setup' '
-touch foo && git add foo && git commit -m "added foo" &&
-  echo changed >foo && git commit -a -m "changed foo"
+	: >foo &&
+	git add foo &&
+	git commit -m "added foo" &&
+	head1=$(git rev-parse --verify HEAD) &&
+	head1_short=$(git rev-parse --verify --short $head1) &&
+	tree1=$(git rev-parse --verify HEAD:) &&
+	tree1_short=$(git rev-parse --verify --short $tree1) &&
+	echo changed >foo &&
+	git commit -a -m "changed foo" &&
+	head2=$(git rev-parse --verify HEAD) &&
+	head2_short=$(git rev-parse --verify --short $head2) &&
+	tree2=$(git rev-parse --verify HEAD:) &&
+	tree2_short=$(git rev-parse --verify --short $tree2)
 '
 
 # usage: test_format name format_string <expected_output
@@ -32,49 +43,49 @@ has_no_color () {
 	test_cmp expect "$1"
 }
 
-test_format percent %%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format percent %%h <<EOF
+commit $head2
 %h
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 %h
 EOF
 
-test_format hash %H%n%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-131a310eb913d107dd3c09a65d1651175898735d
-131a310
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
+test_format hash %H%n%h <<EOF
+commit $head2
+$head2
+$head2_short
+commit $head1
+$head1
+$head1_short
 EOF
 
-test_format tree %T%n%t <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-fe722612f26da5064c32ca3843aa154bdb0b08a0
-fe72261
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-4d5fcadc293a348e88f777dc0920f11e7d71441c
-4d5fcad
+test_format tree %T%n%t <<EOF
+commit $head2
+$tree2
+$tree2_short
+commit $head1
+$tree1
+$tree1_short
 EOF
 
-test_format parents %P%n%p <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format parents %P%n%p <<EOF
+commit $head2
+$head1
+$head1_short
+commit $head1
 
 
 EOF
 
 # we don't test relative here
-test_format author %an%n%ae%n%ad%n%aD%n%at <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format author %an%n%ae%n%ad%n%aD%n%at <<EOF
+commit $head2
 A U Thor
 author@example.com
 Thu Apr 7 15:13:13 2005 -0700
 Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 A U Thor
 author@example.com
 Thu Apr 7 15:13:13 2005 -0700
@@ -82,14 +93,14 @@ Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
 EOF
 
-test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<EOF
+commit $head2
 C O Mitter
 committer@example.com
 Thu Apr 7 15:13:13 2005 -0700
 Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 C O Mitter
 committer@example.com
 Thu Apr 7 15:13:13 2005 -0700
@@ -97,43 +108,43 @@ Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
 EOF
 
-test_format encoding %e <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format encoding %e <<EOF
+commit $head2
+commit $head1
 EOF
 
-test_format subject %s <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format subject %s <<EOF
+commit $head2
 changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 added foo
 EOF
 
-test_format body %b <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format body %b <<EOF
+commit $head2
+commit $head1
 EOF
 
-test_format raw-body %B <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format raw-body %B <<EOF
+commit $head2
 changed foo
 
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 added foo
 
 EOF
 
-test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<EOF
+commit $head2
 ^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 ^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
 EOF
 
-test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<EOF
+commit $head2
 ^[[1;31;43mfoo^[[m
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 ^[[1;31;43mfoo^[[m
 EOF
 
@@ -186,39 +197,42 @@ This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
 include an iso8859 character: ¡bueno!
 EOF
+
 test_expect_success 'setup complex body' '
-git config i18n.commitencoding iso8859-1 &&
-  echo change2 >foo && git commit -a -F commit-msg
+	git config i18n.commitencoding iso8859-1 &&
+	echo change2 >foo && git commit -a -F commit-msg &&
+	head3=$(git rev-parse --verify HEAD) &&
+	head3_short=$(git rev-parse --short $head3)
 '
 
-test_format complex-encoding %e <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
+test_format complex-encoding %e <<EOF
+commit $head3
 iso8859-1
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head2
+commit $head1
 EOF
 
-test_format complex-subject %s <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
+test_format complex-subject %s <<EOF
+commit $head3
 Test printing of complex bodies
-commit 131a310eb913d107dd3c09a65d1651175898735d
+commit $head2
 changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 added foo
 EOF
 
-test_format complex-body %b <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
+test_format complex-body %b <<EOF
+commit $head3
 This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
 include an iso8859 character: ¡bueno!
 
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head2
+commit $head1
 EOF
 
 test_expect_success '%x00 shows NUL' '
-	echo  >expect commit 1ed88da4a5b5ed8c449114ac131efc62178734c3 &&
+	echo  >expect commit $head3 &&
 	echo >>expect fooQbar &&
 	git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
 	nul_to_q <actual.nul >actual &&
-- 
1.8.3.1.15.g5c23c1e

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

* [PATCH v6 2/5] t7102 (reset): don't hardcode SHA-1 in expected outputs
  2013-06-20  9:26                       ` [PATCH v5 0/5] Reroll patches against v1.8.3.1 Alexey Shumkin
                                           ` (2 preceding siblings ...)
  2013-06-25  8:55                         ` [PATCH v6 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
@ 2013-06-25  8:55                         ` Alexey Shumkin
  2013-06-25  8:55                         ` [PATCH v6 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
                                           ` (2 subsequent siblings)
  6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-25  8:55 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 t/t7102-reset.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index df82ec9..05dfb27 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -192,7 +192,8 @@ test_expect_success \
 	'changing files and redo the last commit should succeed' '
 	echo "3rd line 2nd file" >>secondfile &&
 	git commit -a -C ORIG_HEAD &&
-	check_changes 3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d &&
+	head4=$(git rev-parse --verify HEAD) &&
+	check_changes $head4 &&
 	test "$(git rev-parse ORIG_HEAD)" = \
 			$head5
 '
@@ -211,7 +212,7 @@ test_expect_success \
 	git reset --hard HEAD~2 &&
 	check_changes ddaefe00f1da16864591c61fdc7adb5d7cd6b74e &&
 	test "$(git rev-parse ORIG_HEAD)" = \
-			3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d
+			$head4
 '
 
 >.diff_expect
@@ -326,10 +327,11 @@ test_expect_success '--hard reset to HEAD should clear a failed merge' '
 	git checkout branch2 &&
 	echo "3rd line in branch2" >>secondfile &&
 	git commit -a -m "change in branch2" &&
+	head3=$(git rev-parse --verify HEAD) &&
 
 	test_must_fail git pull . branch1 &&
 	git reset --hard &&
-	check_changes 77abb337073fb4369a7ad69ff6f5ec0e4d6b54bb
+	check_changes $head3
 '
 
 >.diff_expect
-- 
1.8.3.1.15.g5c23c1e

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

* [PATCH v6 3/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
  2013-06-20  9:26                       ` [PATCH v5 0/5] Reroll patches against v1.8.3.1 Alexey Shumkin
                                           ` (3 preceding siblings ...)
  2013-06-25  8:55                         ` [PATCH v6 2/5] t7102 (reset): " Alexey Shumkin
@ 2013-06-25  8:55                         ` Alexey Shumkin
  2013-06-25  8:55                         ` [PATCH v6 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
  2013-06-25  8:55                         ` [PATCH v6 5/5] pretty: " Alexey Shumkin
  6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-25  8:55 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 t/t4205-log-pretty-formats.sh | 48 +++++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 22 deletions(-)

diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 26fbfde..73ba5e8 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -101,7 +101,11 @@ test_expect_failure 'NUL termination with --stat' '
 
 test_expect_success 'setup more commits' '
 	test_commit "message one" one one message-one &&
-	test_commit "message two" two two message-two
+	test_commit "message two" two two message-two &&
+	head1=$(git rev-parse --verify --short HEAD~0) &&
+	head2=$(git rev-parse --verify --short HEAD~1) &&
+	head3=$(git rev-parse --verify --short HEAD~2) &&
+	head4=$(git rev-parse --verify --short HEAD~3)
 '
 
 test_expect_success 'left alignment formatting' '
@@ -117,18 +121,18 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'left alignment formatting at the nth column' '
-	git log --pretty="format:%h %<|(40)%s" >actual &&
+test_expect_success 'left alignment formatting at the nth column' "
+	git log --pretty='format:%h %<|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
-fa33ab1 message two                    Z
-7cd6c63 message one                    Z
-1711bf9 add bar                        Z
-af20c06 initial                        Z
+$head1 message two                    Z
+$head2 message one                    Z
+$head3 add bar                        Z
+$head4 initial                        Z
 EOF
 	test_cmp expected actual
-'
+"
 
 test_expect_success 'left alignment formatting with no padding' '
 	git log --pretty="format:%<(1)%s" >actual &&
@@ -195,18 +199,18 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'right alignment formatting at the nth column' '
-	git log --pretty="format:%h %>|(40)%s" >actual &&
+test_expect_success 'right alignment formatting at the nth column' "
+	git log --pretty='format:%h %>|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
-fa33ab1                      message two
-7cd6c63                      message one
-1711bf9                          add bar
-af20c06                          initial
+$head1                      message two
+$head2                      message one
+$head3                          add bar
+$head4                          initial
 EOF
 	test_cmp expected actual
-'
+"
 
 test_expect_success 'right alignment formatting with no padding' '
 	git log --pretty="format:%>(1)%s" >actual &&
@@ -234,18 +238,18 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'center alignment formatting at the nth column' '
-	git log --pretty="format:%h %><|(40)%s" >actual &&
+test_expect_success 'center alignment formatting at the nth column' "
+	git log --pretty='format:%h %><|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
-fa33ab1           message two          Z
-7cd6c63           message one          Z
-1711bf9             add bar            Z
-af20c06             initial            Z
+$head1           message two          Z
+$head2           message one          Z
+$head3             add bar            Z
+$head4             initial            Z
 EOF
 	test_cmp expected actual
-'
+"
 
 test_expect_success 'center alignment formatting with no padding' '
 	git log --pretty="format:%><(1)%s" >actual &&
-- 
1.8.3.1.15.g5c23c1e

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

* [PATCH v6 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
  2013-06-20  9:26                       ` [PATCH v5 0/5] Reroll patches against v1.8.3.1 Alexey Shumkin
                                           ` (4 preceding siblings ...)
  2013-06-25  8:55                         ` [PATCH v6 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
@ 2013-06-25  8:55                         ` Alexey Shumkin
  2013-06-25  8:55                         ` [PATCH v6 5/5] pretty: " Alexey Shumkin
  6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-25  8:55 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 22539 bytes --]

One can set an alias
	$ git config alias.lg "log --graph --pretty=format:'%Cred%h%Creset
	-%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset'
	--abbrev-commit --date=local"

to see the log as a pretty tree (like *gitk* but in a terminal).

However, log messages written in an encoding i18n.commitEncoding which differs
from terminal encoding are shown corrupted even when i18n.logOutputEncoding
and terminal encoding are the same (e.g. log messages committed on a Cygwin box
with Windows-1251 encoding seen on a Linux box with a UTF-8 encoding and vice versa).

To simplify an example we can say the following two commands are expected
to give the same output to a terminal:

	$ git log --oneline --no-color
	$ git log --pretty=format:'%h %s'

However, the former pays attention to i18n.logOutputEncoding
configuration, while the latter does not when it formats "%s".

The same corruption is true for
	$ git diff --submodule=log
and
	$ git rev-list --pretty=format:%s HEAD
and
	$ git reset --hard

This patch adds failing tests for the next patch that fixes them.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 t/t4041-diff-submodule-option.sh |  35 +++++----
 t/t4205-log-pretty-formats.sh    | 149 ++++++++++++++++++++++++---------------
 t/t6006-rev-list-format.sh       |  83 +++++++++++++++-------
 t/t7102-reset.sh                 |  29 +++++++-
 4 files changed, 199 insertions(+), 97 deletions(-)

diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 32d4a60..67afb86 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 #
 # Copyright (c) 2009 Jens Lehmann, based on t7401 by Ping Yin
+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
 #
 
 test_description='Support for verbose submodule differences in git diff
@@ -10,6 +11,9 @@ This test tries to verify the sanity of the --submodule option of git diff.
 
 . ./test-lib.sh
 
+# String "added" in Russian, encoded in UTF-8, used in
+# sample commit log messages in add_file() function below.
+added=$(printf "\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275")
 add_file () {
 	(
 		cd "$1" &&
@@ -19,7 +23,8 @@ add_file () {
 			echo "$name" >"$name" &&
 			git add "$name" &&
 			test_tick &&
-			git commit -m "Add $name" || exit
+			msg_added_cp1251=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t cp1251) &&
+			git -c 'i18n.commitEncoding=cp1251' commit -m "$msg_added_cp1251"
 		done >/dev/null &&
 		git rev-parse --short --verify HEAD
 	)
@@ -89,29 +94,29 @@ test_expect_success 'diff.submodule does not affect plumbing' '
 commit_file sm1 &&
 head2=$(add_file sm1 foo3)
 
-test_expect_success 'modified submodule(forward)' '
+test_expect_failure 'modified submodule(forward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
-	  > Add foo3
+	  > Add foo3 ($added foo3)
 	EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'modified submodule(forward)' '
+test_expect_failure 'modified submodule(forward)' '
 	git diff --submodule=log >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
-	  > Add foo3
+	  > Add foo3 ($added foo3)
 	EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'modified submodule(forward) --submodule' '
+test_expect_failure 'modified submodule(forward) --submodule' '
 	git diff --submodule >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
-	  > Add foo3
+	  > Add foo3 ($added foo3)
 	EOF
 	test_cmp expected actual
 '
@@ -138,25 +143,25 @@ head3=$(
 	git rev-parse --short --verify HEAD
 )
 
-test_expect_success 'modified submodule(backward)' '
+test_expect_failure 'modified submodule(backward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head2..$head3 (rewind):
-	  < Add foo3
-	  < Add foo2
+	  < Add foo3 ($added foo3)
+	  < Add foo2 ($added foo2)
 	EOF
 	test_cmp expected actual
 '
 
 head4=$(add_file sm1 foo4 foo5)
-test_expect_success 'modified submodule(backward and forward)' '
+test_expect_failure 'modified submodule(backward and forward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head2...$head4:
-	  > Add foo5
-	  > Add foo4
-	  < Add foo3
-	  < Add foo2
+	  > Add foo5 ($added foo5)
+	  > Add foo4 ($added foo4)
+	  < Add foo3 ($added foo3)
+	  < Add foo2 ($added foo2)
 	EOF
 	test_cmp expected actual
 '
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 73ba5e8..a45bb55 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -1,20 +1,43 @@
 #!/bin/sh
 #
 # Copyright (c) 2010, Will Palmer
+# Copyright (c) 2011, Alexey Shumkin (+ non-UTF-8 commit encoding tests)
 #
 
 test_description='Test pretty formats'
 . ./test-lib.sh
 
+commit_msg() {
+	# String "initial commit" partly in Russian, encoded in UTF-8,
+	# used as a commit log message below.
+	msg=$(printf "initial \320\272\320\276\320\274\320\274\320\270\321\202")
+	if test -n "$1"
+	then
+		msg=$(echo $msg | iconv -f utf-8 -t $1)
+	fi
+	if test -n "$2" -a -n "$3"
+	then
+		# cut string, replace cut part with two dots
+		# $2 - chars count from the beginning of the string
+		# $3 - "trailing" chars
+		# LC_ALL is set to make `sed` interpret "." as a UTF-8 char not a byte
+		# as it does with C locale
+		msg=$(echo $msg | LC_ALL=en_US.UTF-8 sed -e "s/^\(.\{$2\}\)$3/\1../")
+	fi
+	echo $msg
+}
+
 test_expect_success 'set up basic repos' '
 	>foo &&
 	>bar &&
 	git add foo &&
 	test_tick &&
-	git commit -m initial &&
+	git config i18n.commitEncoding cp1251 &&
+	git commit -m "$(commit_msg cp1251)" &&
 	git add bar &&
 	test_tick &&
-	git commit -m "add bar"
+	git commit -m "add bar" &&
+	git config --unset i18n.commitEncoding
 '
 
 test_expect_success 'alias builtin format' '
@@ -38,6 +61,20 @@ test_expect_success 'alias user-defined format' '
 	test_cmp expected actual
 '
 
+test_expect_success 'alias user-defined tformat with %s (cp1251 encoding)' '
+	git config i18n.logOutputEncoding cp1251 &&
+	git log --oneline >expected-s &&
+	git log --pretty="tformat:%h %s" >actual-s &&
+	git config --unset i18n.logOutputEncoding &&
+	test_cmp expected-s actual-s
+'
+
+test_expect_failure 'alias user-defined tformat with %s (utf-8 encoding)' '
+	git log --oneline >expected-s &&
+	git log --pretty="tformat:%h %s" >actual-s &&
+	test_cmp expected-s actual-s
+'
+
 test_expect_success 'alias user-defined tformat' '
 	git log --pretty="tformat:%h" >expected &&
 	git config pretty.test-alias "tformat:%h" &&
@@ -71,22 +108,22 @@ test_expect_success 'alias loop' '
 	test_must_fail git log --pretty=test-foo
 '
 
-test_expect_success 'NUL separation' '
-	printf "add bar\0initial" >expected &&
+test_expect_failure 'NUL separation' '
+	printf "add bar\0$(commit_msg)" >expected &&
 	git log -z --pretty="format:%s" >actual &&
 	test_cmp expected actual
 '
 
-test_expect_success 'NUL termination' '
-	printf "add bar\0initial\0" >expected &&
+test_expect_failure 'NUL termination' '
+	printf "add bar\0$(commit_msg)\0" >expected &&
 	git log -z --pretty="tformat:%s" >actual &&
 	test_cmp expected actual
 '
 
-test_expect_success 'NUL separation with --stat' '
+test_expect_failure 'NUL separation with --stat' '
 	stat0_part=$(git diff --stat HEAD^ HEAD) &&
 	stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
-	printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n" >expected &&
+	printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected &&
 	git log -z --stat --pretty="format:%s" >actual &&
 	test_i18ncmp expected actual
 '
@@ -94,7 +131,7 @@ test_expect_success 'NUL separation with --stat' '
 test_expect_failure 'NUL termination with --stat' '
 	stat0_part=$(git diff --stat HEAD^ HEAD) &&
 	stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
-	printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n\0" >expected &&
+	printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n0" >expected &&
 	git log -z --stat --pretty="tformat:%s" >actual &&
 	test_i18ncmp expected actual
 '
@@ -108,20 +145,20 @@ test_expect_success 'setup more commits' '
 	head4=$(git rev-parse --verify --short HEAD~3)
 '
 
-test_expect_success 'left alignment formatting' '
-	git log --pretty="format:%<(40)%s" >actual &&
+test_expect_failure 'left alignment formatting' "
+	git log --pretty='format:%<(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
 message two                            Z
 message one                            Z
 add bar                                Z
-initial                                Z
+$(commit_msg)                         Z
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'left alignment formatting at the nth column' "
+test_expect_failure 'left alignment formatting at the nth column' "
 	git log --pretty='format:%h %<|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -129,77 +166,77 @@ test_expect_success 'left alignment formatting at the nth column' "
 $head1 message two                    Z
 $head2 message one                    Z
 $head3 add bar                        Z
-$head4 initial                        Z
+$head4 $(commit_msg)                 Z
 EOF
 	test_cmp expected actual
 "
 
-test_expect_success 'left alignment formatting with no padding' '
-	git log --pretty="format:%<(1)%s" >actual &&
+test_expect_failure 'left alignment formatting with no padding' "
+	git log --pretty='format:%<(1)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	cat <<\EOF >expected &&
 message two
 message one
 add bar
-initial
+$(commit_msg)
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'left alignment formatting with trunc' '
-	git log --pretty="format:%<(10,trunc)%s" >actual &&
+test_expect_failure 'left alignment formatting with trunc' "
+	git log --pretty='format:%<(10,trunc)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
 message ..
 message ..
 add bar  Z
-initial  Z
+$(commit_msg "" "8" ".\+$")
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'left alignment formatting with ltrunc' '
-	git log --pretty="format:%<(10,ltrunc)%s" >actual &&
+test_expect_failure 'left alignment formatting with ltrunc' "
+	git log --pretty='format:%<(10,ltrunc)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
 ..sage two
 ..sage one
 add bar  Z
-initial  Z
+$(commit_msg "" "0" ".\{6\}")
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'left alignment formatting with mtrunc' '
-	git log --pretty="format:%<(10,mtrunc)%s" >actual &&
+test_expect_failure 'left alignment formatting with mtrunc' "
+	git log --pretty='format:%<(10,mtrunc)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
 mess.. two
 mess.. one
 add bar  Z
-initial  Z
+$(commit_msg "" "4" ".\{6\}")
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'right alignment formatting' '
-	git log --pretty="format:%>(40)%s" >actual &&
+test_expect_failure 'right alignment formatting' "
+	git log --pretty='format:%>(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
 Z                            message two
 Z                            message one
 Z                                add bar
-Z                                initial
+Z                         $(commit_msg)
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'right alignment formatting at the nth column' "
+test_expect_failure 'right alignment formatting at the nth column' "
 	git log --pretty='format:%h %>|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -207,38 +244,38 @@ test_expect_success 'right alignment formatting at the nth column' "
 $head1                      message two
 $head2                      message one
 $head3                          add bar
-$head4                          initial
+$head4                   $(commit_msg)
 EOF
 	test_cmp expected actual
 "
 
-test_expect_success 'right alignment formatting with no padding' '
-	git log --pretty="format:%>(1)%s" >actual &&
+test_expect_failure 'right alignment formatting with no padding' "
+	git log --pretty='format:%>(1)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	cat <<\EOF >expected &&
 message two
 message one
 add bar
-initial
+$(commit_msg)
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'center alignment formatting' '
-	git log --pretty="format:%><(40)%s" >actual &&
+test_expect_failure 'center alignment formatting' "
+	git log --pretty='format:%><(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
 Z             message two              Z
 Z             message one              Z
 Z               add bar                Z
-Z               initial                Z
+Z            $(commit_msg)            Z
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'center alignment formatting at the nth column' "
+test_expect_failure 'center alignment formatting at the nth column' "
 	git log --pretty='format:%h %><|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -246,36 +283,36 @@ test_expect_success 'center alignment formatting at the nth column' "
 $head1           message two          Z
 $head2           message one          Z
 $head3             add bar            Z
-$head4             initial            Z
+$head4          $(commit_msg)        Z
 EOF
 	test_cmp expected actual
 "
 
-test_expect_success 'center alignment formatting with no padding' '
-	git log --pretty="format:%><(1)%s" >actual &&
+test_expect_failure 'center alignment formatting with no padding' "
+	git log --pretty='format:%><(1)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	cat <<\EOF >expected &&
 message two
 message one
 add bar
-initial
+$(commit_msg)
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'left/right alignment formatting with stealing' '
-	git commit --amend -m short --author "long long long <long@me.com>" &&
-	git log --pretty="format:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
+test_expect_failure 'left/right alignment formatting with stealing' "
+	git commit --amend -m short --author 'long long long <long@me.com>' &&
+	git log --pretty='format:%<(10,trunc)%s%>>(10,ltrunc)% an' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	cat <<\EOF >expected &&
 short long  long long
 message ..   A U Thor
 add bar      A U Thor
-initial      A U Thor
+$(commit_msg "" "8" ".\+$")   A U Thor
 EOF
 	test_cmp expected actual
-'
+"
 
 test_done
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index cc1008d..ce62214 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -1,34 +1,60 @@
 #!/bin/sh
 
+# Copyright (c) 2009 Jens Lehmann
+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
+
 test_description='git rev-list --pretty=format test'
 
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-terminal.sh
 
 test_tick
+# String "added" in Russian, encoded in UTF-8,
+# used as a commit log message below.
+added=$(printf "added (\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275) foo")
+added_cp1251=$(echo "$added" | iconv -f utf-8 -t cp1251)
+# same but "changed"
+changed=$(printf "changed (\320\264\320\276\320\261\320\260\320\262\320\273\320\265\320\275) foo")
+changed_cp1251=$(echo "$changed" | iconv -f utf-8 -t cp1251)
+
 test_expect_success 'setup' '
 	: >foo &&
 	git add foo &&
-	git commit -m "added foo" &&
+	git config i18n.commitEncoding cp1251 &&
+	git commit -m "$added_cp1251" &&
 	head1=$(git rev-parse --verify HEAD) &&
 	head1_short=$(git rev-parse --verify --short $head1) &&
 	tree1=$(git rev-parse --verify HEAD:) &&
 	tree1_short=$(git rev-parse --verify --short $tree1) &&
-	echo changed >foo &&
-	git commit -a -m "changed foo" &&
+	echo "$changed" > foo &&
+	git commit -a -m "$changed_cp1251" &&
 	head2=$(git rev-parse --verify HEAD) &&
 	head2_short=$(git rev-parse --verify --short $head2) &&
 	tree2=$(git rev-parse --verify HEAD:) &&
 	tree2_short=$(git rev-parse --verify --short $tree2)
+	git config --unset i18n.commitEncoding
 '
 
-# usage: test_format name format_string <expected_output
+# usage: test_format [failure] name format_string <expected_output
 test_format () {
+	must_fail=0
+	# if parameters count is more than 2 then test must fail
+	if test $# -gt 2
+	then
+		must_fail=1
+		# remove first parameter which is flag for test failure
+		shift
+	fi
 	cat >expect.$1
-	test_expect_success "format $1" "
-		git rev-list --pretty=format:'$2' master >output.$1 &&
-		test_cmp expect.$1 output.$1
-	"
+	name="format $1"
+	command="git rev-list --pretty=format:'$2' master >output.$1 &&
+		test_cmp expect.$1 output.$1"
+	if test $must_fail -eq 1
+	then
+		test_expect_failure "$name" "$command"
+	else
+		test_expect_success "$name" "$command"
+	fi
 }
 
 # Feed to --format to provide predictable colored sequences.
@@ -110,14 +136,16 @@ EOF
 
 test_format encoding %e <<EOF
 commit $head2
+cp1251
 commit $head1
+cp1251
 EOF
 
-test_format subject %s <<EOF
+test_format failure subject %s <<EOF
 commit $head2
-changed foo
+$changed
 commit $head1
-added foo
+$added
 EOF
 
 test_format body %b <<EOF
@@ -125,12 +153,12 @@ commit $head2
 commit $head1
 EOF
 
-test_format raw-body %B <<EOF
+test_format failure raw-body %B <<EOF
 commit $head2
-changed foo
+$changed
 
 commit $head1
-added foo
+$added
 
 EOF
 
@@ -190,42 +218,49 @@ test_expect_success '%C(auto) respects --color=auto (stdout not tty)' '
 	)
 '
 
-cat >commit-msg <<'EOF'
+iconv -f utf-8 -t iso8859-1 > commit-msg <<EOF
 Test printing of complex bodies
 
 This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
-include an iso8859 character: ¡bueno!
+include an iso8859 character: ¡bueno!
 EOF
 
 test_expect_success 'setup complex body' '
 	git config i18n.commitencoding iso8859-1 &&
 	echo change2 >foo && git commit -a -F commit-msg &&
 	head3=$(git rev-parse --verify HEAD) &&
-	head3_short=$(git rev-parse --short $head3)
+	head3_short=$(git rev-parse --short $head3) &&
+	# unset commit encoding config
+	# otherwise %e does not print encoding value
+	# and following test fails
+	git config --unset i18n.commitEncoding
+
 '
 
 test_format complex-encoding %e <<EOF
 commit $head3
 iso8859-1
 commit $head2
+cp1251
 commit $head1
+cp1251
 EOF
 
-test_format complex-subject %s <<EOF
+test_format failure complex-subject %s <<EOF
 commit $head3
 Test printing of complex bodies
 commit $head2
-changed foo
+$changed
 commit $head1
-added foo
+$added
 EOF
 
-test_format complex-body %b <<EOF
+test_format failure complex-body %b <<EOF
 commit $head3
 This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
-include an iso8859 character: ¡bueno!
+include an iso8859 character: ¡bueno!
 
 commit $head2
 commit $head1
@@ -279,12 +314,12 @@ test_expect_success 'add LF before non-empty (2)' '
 
 test_expect_success 'add SP before non-empty (1)' '
 	git show -s --pretty=format:"%s% bThanks" HEAD^^ >actual &&
-	test $(wc -w <actual) = 2
+	test $(wc -w <actual) = 3
 '
 
 test_expect_success 'add SP before non-empty (2)' '
 	git show -s --pretty=format:"%s% sThanks" HEAD^^ >actual &&
-	test $(wc -w <actual) = 4
+	test $(wc -w <actual) = 6
 '
 
 test_expect_success '--abbrev' '
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 05dfb27..19a4cf4 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -9,6 +9,17 @@ Documented tests for git reset'
 
 . ./test-lib.sh
 
+commit_msg() {
+	# String "2nd file modified" in Russian, encoded in UTF-8,
+	# used as a commit log message below.
+	msg=$(printf "modify 2nd file (\320\270\320\267\320\274\320\265\320\275\321\221\320\275 \321\204\320\260\320\271\320\273)")
+	if test -n "$1"
+	then
+		msg=$(echo $msg | iconv -f utf-8 -t $1)
+	fi
+	echo $msg
+}
+
 test_expect_success 'creating initial files and commits' '
 	test_tick &&
 	echo "1st file" >first &&
@@ -28,7 +39,7 @@ test_expect_success 'creating initial files and commits' '
 
 	echo "1st line 2nd file" >secondfile &&
 	echo "2nd line 2nd file" >>secondfile &&
-	git commit -a -m "modify 2nd file" &&
+	git -c "i18n.commitEncoding=cp1251" commit -a -m "$(commit_msg cp1251)" &&
 	head5=$(git rev-parse --verify HEAD)
 '
 # git log --pretty=oneline # to see those SHA1 involved
@@ -44,6 +55,20 @@ check_changes () {
 	done | test_cmp .cat_expect -
 }
 
+test_expect_failure 'reset --hard message' '
+	hex=$(git log -1 --format="%h") &&
+	git reset --hard > .actual &&
+	echo HEAD is now at $hex $(commit_msg) > .expected &&
+	test_cmp .expected .actual
+'
+
+test_expect_success 'reset --hard message (cp1251 logoutencoding)' '
+	hex=$(git log -1 --format="%h") &&
+	git -c "i18n.logOutputEncoding=cp1251" reset --hard > .actual &&
+	echo HEAD is now at $hex $(commit_msg cp1251) > .expected &&
+	test_cmp .expected .actual
+'
+
 >.diff_expect
 >.cached_expect
 cat >.cat_expect <<EOF
@@ -304,7 +329,7 @@ test_expect_success 'redoing the last two commits should succeed' '
 
 	echo "1st line 2nd file" >secondfile &&
 	echo "2nd line 2nd file" >>secondfile &&
-	git commit -a -m "modify 2nd file" &&
+	git -c "i18n.commitEncoding=cp1251" commit -a -m "$(commit_msg cp1251)" &&
 	check_changes $head5
 '
 
-- 
1.8.3.1.15.g5c23c1e

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

* [PATCH v6 5/5] pretty: --format output should honor logOutputEncoding
  2013-06-20  9:26                       ` [PATCH v5 0/5] Reroll patches against v1.8.3.1 Alexey Shumkin
                                           ` (5 preceding siblings ...)
  2013-06-25  8:55                         ` [PATCH v6 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
@ 2013-06-25  8:55                         ` Alexey Shumkin
  6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-25  8:55 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

One can set an alias
	$ git config [--global] alias.lg "log --graph --pretty=format:'%Cred%h%Creset
	-%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset'
	--abbrev-commit --date=local"

to see the log as a pretty tree (like *gitk* but in a terminal).

However, log messages written in an encoding i18n.commitEncoding which differs
from terminal encoding are shown corrupted even when i18n.logOutputEncoding
and terminal encoding are the same (e.g. log messages committed on a Cygwin box
with Windows-1251 encoding seen on a Linux box with a UTF-8 encoding and vice versa).

To simplify an example we can say the following two commands are expected
to give the same output to a terminal:

	$ git log --oneline --no-color
	$ git log --pretty=format:'%h %s'

However, the former pays attention to i18n.logOutputEncoding
configuration, while the latter does not when it formats "%s".

The same corruption is true for
	$ git diff --submodule=log
and
	$ git rev-list --pretty=format:%s HEAD
and
	$ git reset --hard

This patch makes pretty --format honor logOutputEncoding when it formats
log message.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 builtin/reset.c                  |  6 ++++--
 builtin/rev-list.c               |  1 +
 builtin/shortlog.c               |  1 +
 log-tree.c                       |  1 +
 submodule.c                      |  1 +
 t/t4041-diff-submodule-option.sh | 10 +++++-----
 t/t4205-log-pretty-formats.sh    | 34 +++++++++++++++++-----------------
 t/t6006-rev-list-format.sh       |  8 ++++----
 t/t7102-reset.sh                 |  2 +-
 9 files changed, 35 insertions(+), 29 deletions(-)

diff --git a/builtin/reset.c b/builtin/reset.c
index 6032131..a6cacc6 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -92,11 +92,12 @@ static int reset_index(const unsigned char *sha1, int reset_type, int quiet)
 
 static void print_new_head_line(struct commit *commit)
 {
-	const char *hex, *body;
+	const char *hex, *body, *msg;
 
 	hex = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
 	printf(_("HEAD is now at %s"), hex);
-	body = strstr(commit->buffer, "\n\n");
+	msg = logmsg_reencode(commit, NULL, get_log_output_encoding());
+	body = strstr(msg, "\n\n");
 	if (body) {
 		const char *eol;
 		size_t len;
@@ -107,6 +108,7 @@ static void print_new_head_line(struct commit *commit)
 	}
 	else
 		printf("\n");
+	logmsg_free(msg, commit);
 }
 
 static void update_index_from_diff(struct diff_queue_struct *q,
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 67701be..a5ec30d 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -111,6 +111,7 @@ static void show_commit(struct commit *commit, void *data)
 		ctx.date_mode = revs->date_mode;
 		ctx.date_mode_explicit = revs->date_mode_explicit;
 		ctx.fmt = revs->commit_format;
+		ctx.output_encoding = get_log_output_encoding();
 		pretty_print_commit(&ctx, commit, &buf);
 		if (revs->graph) {
 			if (buf.len) {
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 1fd6f8a..1434f8f 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -137,6 +137,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
 		ctx.subject = "";
 		ctx.after_subject = "";
 		ctx.date_mode = DATE_NORMAL;
+		ctx.output_encoding = get_log_output_encoding();
 		pretty_print_commit(&ctx, commit, &ufbuf);
 		buffer = ufbuf.buf;
 	} else if (*buffer) {
diff --git a/log-tree.c b/log-tree.c
index 1946e9c..5277d3e 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -616,6 +616,7 @@ void show_log(struct rev_info *opt)
 	ctx.fmt = opt->commit_format;
 	ctx.mailmap = opt->mailmap;
 	ctx.color = opt->diffopt.use_color;
+	ctx.output_encoding = get_log_output_encoding();
 	pretty_print_commit(&ctx, commit, &msgbuf);
 
 	if (opt->add_signoff)
diff --git a/submodule.c b/submodule.c
index 1821a5b..78734e1 100644
--- a/submodule.c
+++ b/submodule.c
@@ -226,6 +226,7 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
 	while ((commit = get_revision(rev))) {
 		struct pretty_print_context ctx = {0};
 		ctx.date_mode = rev->date_mode;
+		ctx.output_encoding = get_log_output_encoding();
 		strbuf_setlen(&sb, 0);
 		strbuf_addstr(&sb, line_prefix);
 		if (commit->object.flags & SYMMETRIC_LEFT) {
diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 67afb86..9ba4b8e 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -94,7 +94,7 @@ test_expect_success 'diff.submodule does not affect plumbing' '
 commit_file sm1 &&
 head2=$(add_file sm1 foo3)
 
-test_expect_failure 'modified submodule(forward)' '
+test_expect_success 'modified submodule(forward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
@@ -103,7 +103,7 @@ test_expect_failure 'modified submodule(forward)' '
 	test_cmp expected actual
 '
 
-test_expect_failure 'modified submodule(forward)' '
+test_expect_success 'modified submodule(forward)' '
 	git diff --submodule=log >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
@@ -112,7 +112,7 @@ test_expect_failure 'modified submodule(forward)' '
 	test_cmp expected actual
 '
 
-test_expect_failure 'modified submodule(forward) --submodule' '
+test_expect_success 'modified submodule(forward) --submodule' '
 	git diff --submodule >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
@@ -143,7 +143,7 @@ head3=$(
 	git rev-parse --short --verify HEAD
 )
 
-test_expect_failure 'modified submodule(backward)' '
+test_expect_success 'modified submodule(backward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head2..$head3 (rewind):
@@ -154,7 +154,7 @@ test_expect_failure 'modified submodule(backward)' '
 '
 
 head4=$(add_file sm1 foo4 foo5)
-test_expect_failure 'modified submodule(backward and forward)' '
+test_expect_success 'modified submodule(backward and forward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head2...$head4:
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index a45bb55..5a14124 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -69,7 +69,7 @@ test_expect_success 'alias user-defined tformat with %s (cp1251 encoding)' '
 	test_cmp expected-s actual-s
 '
 
-test_expect_failure 'alias user-defined tformat with %s (utf-8 encoding)' '
+test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' '
 	git log --oneline >expected-s &&
 	git log --pretty="tformat:%h %s" >actual-s &&
 	test_cmp expected-s actual-s
@@ -108,19 +108,19 @@ test_expect_success 'alias loop' '
 	test_must_fail git log --pretty=test-foo
 '
 
-test_expect_failure 'NUL separation' '
+test_expect_success 'NUL separation' '
 	printf "add bar\0$(commit_msg)" >expected &&
 	git log -z --pretty="format:%s" >actual &&
 	test_cmp expected actual
 '
 
-test_expect_failure 'NUL termination' '
+test_expect_success 'NUL termination' '
 	printf "add bar\0$(commit_msg)\0" >expected &&
 	git log -z --pretty="tformat:%s" >actual &&
 	test_cmp expected actual
 '
 
-test_expect_failure 'NUL separation with --stat' '
+test_expect_success 'NUL separation with --stat' '
 	stat0_part=$(git diff --stat HEAD^ HEAD) &&
 	stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
 	printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected &&
@@ -145,7 +145,7 @@ test_expect_success 'setup more commits' '
 	head4=$(git rev-parse --verify --short HEAD~3)
 '
 
-test_expect_failure 'left alignment formatting' "
+test_expect_success 'left alignment formatting' "
 	git log --pretty='format:%<(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -158,7 +158,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'left alignment formatting at the nth column' "
+test_expect_success 'left alignment formatting at the nth column' "
 	git log --pretty='format:%h %<|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -171,7 +171,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'left alignment formatting with no padding' "
+test_expect_success 'left alignment formatting with no padding' "
 	git log --pretty='format:%<(1)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -184,7 +184,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'left alignment formatting with trunc' "
+test_expect_success 'left alignment formatting with trunc' "
 	git log --pretty='format:%<(10,trunc)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -197,7 +197,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'left alignment formatting with ltrunc' "
+test_expect_success 'left alignment formatting with ltrunc' "
 	git log --pretty='format:%<(10,ltrunc)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -210,7 +210,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'left alignment formatting with mtrunc' "
+test_expect_success 'left alignment formatting with mtrunc' "
 	git log --pretty='format:%<(10,mtrunc)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -223,7 +223,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'right alignment formatting' "
+test_expect_success 'right alignment formatting' "
 	git log --pretty='format:%>(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -236,7 +236,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'right alignment formatting at the nth column' "
+test_expect_success 'right alignment formatting at the nth column' "
 	git log --pretty='format:%h %>|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -249,7 +249,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'right alignment formatting with no padding' "
+test_expect_success 'right alignment formatting with no padding' "
 	git log --pretty='format:%>(1)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -262,7 +262,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'center alignment formatting' "
+test_expect_success 'center alignment formatting' "
 	git log --pretty='format:%><(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -275,7 +275,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'center alignment formatting at the nth column' "
+test_expect_success 'center alignment formatting at the nth column' "
 	git log --pretty='format:%h %><|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -288,7 +288,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'center alignment formatting with no padding' "
+test_expect_success 'center alignment formatting with no padding' "
 	git log --pretty='format:%><(1)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -301,7 +301,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'left/right alignment formatting with stealing' "
+test_expect_success 'left/right alignment formatting with stealing' "
 	git commit --amend -m short --author 'long long long <long@me.com>' &&
 	git log --pretty='format:%<(10,trunc)%s%>>(10,ltrunc)% an' >actual &&
 	# complete the incomplete line at the end
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index ce62214..6356046 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -141,7 +141,7 @@ commit $head1
 cp1251
 EOF
 
-test_format failure subject %s <<EOF
+test_format subject %s <<EOF
 commit $head2
 $changed
 commit $head1
@@ -153,7 +153,7 @@ commit $head2
 commit $head1
 EOF
 
-test_format failure raw-body %B <<EOF
+test_format raw-body %B <<EOF
 commit $head2
 $changed
 
@@ -247,7 +247,7 @@ commit $head1
 cp1251
 EOF
 
-test_format failure complex-subject %s <<EOF
+test_format complex-subject %s <<EOF
 commit $head3
 Test printing of complex bodies
 commit $head2
@@ -256,7 +256,7 @@ commit $head1
 $added
 EOF
 
-test_format failure complex-body %b <<EOF
+test_format complex-body %b <<EOF
 commit $head3
 This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 19a4cf4..ea96e43 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -55,7 +55,7 @@ check_changes () {
 	done | test_cmp .cat_expect -
 }
 
-test_expect_failure 'reset --hard message' '
+test_expect_success 'reset --hard message' '
 	hex=$(git log -1 --format="%h") &&
 	git reset --hard > .actual &&
 	echo HEAD is now at $hex $(commit_msg) > .expected &&
-- 
1.8.3.1.15.g5c23c1e

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

* Re: [PATCH v6 0/5] Reroll patches against v1.8.3.1
  2013-06-25  8:55                         ` [PATCH v6 " Alexey Shumkin
@ 2013-06-25 19:28                           ` Junio C Hamano
  2013-06-26  7:37                             ` Alexey Shumkin
  2013-06-26 10:19                           ` [PATCH v7 " Alexey Shumkin
                                             ` (5 subsequent siblings)
  6 siblings, 1 reply; 104+ messages in thread
From: Junio C Hamano @ 2013-06-25 19:28 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git

Alexey Shumkin <Alex.Crezoff@gmail.com> writes:

> 4. [PATCH v6 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
> 	iso8859-5 encoding reverted back to cp1251 encoding (as it was in v4 series)

Thanks for a reroll, but why this change?

The reason I asked you to avoid 8859-5 is because our test do not
use that encoding and I do not want to add new dependency to people
when they run test.  cp1251 shares exactly the same issue, doesn't
it?  So in that sense, this change does not make anything better.

That is why I asked you if the breakage you are trying to
demonstrate about non-ASCII non-UTF8 encoding was specific to
Cyrillic/Russian.  I do not recall seeing your answer, but what is
the right thing to do depend on it.

 - If the answer is yes, then we would need to add dependency either
   way, and 8859-5 is just as fine as cp1251.

 - If the breakage is not specific to Cyrillic, it should be
   reproducible using 8859-1 (latin-1), and our tests already depend
   on 8859-1, so we wouldn't be adding new dependencies on people.

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

* Re: [PATCH v6 0/5] Reroll patches against v1.8.3.1
  2013-06-25 19:28                           ` Junio C Hamano
@ 2013-06-26  7:37                             ` Alexey Shumkin
  2013-06-26 14:24                               ` Junio C Hamano
  0 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-26  7:37 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Tue, Jun 25, 2013 at 12:28:02PM -0700, Junio C Hamano wrote:
> Alexey Shumkin <Alex.Crezoff@gmail.com> writes:
> 
> > 4. [PATCH v6 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
> > 	iso8859-5 encoding reverted back to cp1251 encoding (as it was in v4 series)
> 
> Thanks for a reroll, but why this change?
> 
> The reason I asked you to avoid 8859-5 is because our test do not
> use that encoding and I do not want to add new dependency to people
> when they run test.  cp1251 shares exactly the same issue, doesn't
> it?  So in that sense, this change does not make anything better.
> 
> That is why I asked you if the breakage you are trying to
> demonstrate about non-ASCII non-UTF8 encoding was specific to
> Cyrillic/Russian.  I do not recall seeing your answer, but what is
> the right thing to do depend on it.
> 
>  - If the answer is yes, then we would need to add dependency either
>    way, and 8859-5 is just as fine as cp1251.
> 
>  - If the breakage is not specific to Cyrillic, it should be
>    reproducible using 8859-1 (latin-1), and our tests already depend
>    on 8859-1, so we wouldn't be adding new dependencies on people.
> 

I suppose you've missed my answer somehow. It was:
---8<---
> Alexey Shumkin <Alex.Crezoff@gmail.com> writes:
> 
> > @@ -19,7 +23,8 @@ add_file () {
> >  			echo "$name" >"$name" &&
> >  			git add "$name" &&
> >  			test_tick &&
> > -			git commit -m "Add $name" || exit
> > +			msg_added_iso88595=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t iso88595) &&
> > +			git -c 'i18n.commitEncoding=iso88595' commit -m "$msg_added_iso88595"
> 
> Hmph.  Do we know 8859-5 is available or do these need to be
> protected with prereq?
Opps, this encoding is absent even in my Cygwin box :)
Actually, previuosly, there was a Windows-1251 encoding,
you said we'd prefer to limit different encodings used in tests,
And I've made an attempt to avoid this but I'm way off the mark.

> 
> Can these tests be done with 8859-1 i.e. something we already depend
> on, by changing that $added message to latin-1, or is there something
> very Russian specific breakage we want to test here?
Well, actually, most popular Russian 8-bit codepages are Windows-1251 (aka cp1251) and KOI8-R.
Cygwin (as a "Linux box on Windows") uses cp1251.
Iconv cannot even convert Russian messages from cp1251(or UTF-8) to latin1.
It fails.
  $ echo "коммит" | LANG= iconv -t latin1 -f UTF-8 
  iconv: illegal input sequence at position 0
("коммит" is a "commit" in Russian)

> 
> If the former, please redo this entire patch (not just t4041) with
> 8859-1.
> 
> If there is some Russian specific breakage you cannot demonstrate
> with 8859-1, then please explain it in the log message.
Well, it's not a "Russian specific". It's "codepage conversion" specific,
but I cannot use latin1 codepage because I do not know any language that
uses iso8859-1/latin1 codepage (as German, Spanish, for example) to
write a commit message in it.
If someone can do the same with latin1, I'd be happy.
> 
> > diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
> > index d32e65e..36e4cc0 100755
> > --- a/t/t6006-rev-list-format.sh
> > +++ b/t/t6006-rev-list-format.sh
> > ...
> > -# usage: test_format name format_string <expected_output
> > +# usage: test_format [failure] name format_string <expected_output
> >  test_format () {
> > +	local must_fail=0
> 
> This breaks tests for non-bash users.  "local" is not even in POSIX.
---8<---

But today I've taken a look to Cygwin's locales more closely and found
out that I've used incorrect encoding name (`iso88595` instead of "canonic"
`iso-8859-5` that Cygwin has and "understands")

Nevertheless, as I've already said that is not a Russian locale specific
issue.
The problem in tests for me now is a language (that uses iso-8859-1
encoding) I do not speak or even write ;)

-- 
Alexey Shumkin

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

* [PATCH v7 0/5] Reroll patches against v1.8.3.1
  2013-06-25  8:55                         ` [PATCH v6 " Alexey Shumkin
  2013-06-25 19:28                           ` Junio C Hamano
@ 2013-06-26 10:19                           ` Alexey Shumkin
  2013-06-26 16:19                             ` Junio C Hamano
                                               ` (6 more replies)
  2013-06-26 10:19                           ` [PATCH v7 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
                                             ` (4 subsequent siblings)
  6 siblings, 7 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-26 10:19 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

v7 of this patch series includes the following changes against v6:
1. [PATCH v7 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
	untouched
2. [PATCH v7 2/5] t7102 (reset): don't hardcode SHA-1 in expected outputs
	untouched
3. [PATCH v7 3/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
	untouched
4. [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
    cp1251 encoding changed to iso-8859-1 encoding already used in tests
    Test commit messages contain words ("changed" and "added") in German
    (which is covered by iso-8859-1 encoding)
    They are translated from English (verified in Russian) with Google Translate
5. [PATCH v7 5/5] pretty: --format output should honor logOutputEncoding
    builtin/reset.c:
        "const char ..., *msg;" declaration replaced with "char *msg;"
        to avoid compiler warning on the line "logmsg_free(msg, commit);"

P.S.
It's all started here [http://thread.gmane.org/gmane.comp.version-control.git/177634]

Alexey Shumkin (5):
  t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
  t7102 (reset): don't hardcode SHA-1 in expected outputs
  t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
  pretty: Add failing tests: --format output should honor
    logOutputEncoding
  pretty: --format output should honor logOutputEncoding

 builtin/reset.c                  |   5 +-
 builtin/rev-list.c               |   1 +
 builtin/shortlog.c               |   1 +
 log-tree.c                       |   1 +
 submodule.c                      |   1 +
 t/t4041-diff-submodule-option.sh |  25 +++--
 t/t4205-log-pretty-formats.sh    | 179 ++++++++++++++++++++-------------
 t/t6006-rev-list-format.sh       | 207 ++++++++++++++++++++++++---------------
 t/t7102-reset.sh                 |  37 ++++++-
 9 files changed, 293 insertions(+), 164 deletions(-)

-- 
1.8.3.1.15.g5c23c1e

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

* [PATCH v7 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
  2013-06-25  8:55                         ` [PATCH v6 " Alexey Shumkin
  2013-06-25 19:28                           ` Junio C Hamano
  2013-06-26 10:19                           ` [PATCH v7 " Alexey Shumkin
@ 2013-06-26 10:19                           ` Alexey Shumkin
  2013-06-26 10:19                           ` [PATCH v7 2/5] t7102 (reset): " Alexey Shumkin
                                             ` (3 subsequent siblings)
  6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-26 10:19 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 7061 bytes --]

The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 t/t6006-rev-list-format.sh | 140 +++++++++++++++++++++++++--------------------
 1 file changed, 77 insertions(+), 63 deletions(-)

diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 0393c9f..cc1008d 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -7,8 +7,19 @@ test_description='git rev-list --pretty=format test'
 
 test_tick
 test_expect_success 'setup' '
-touch foo && git add foo && git commit -m "added foo" &&
-  echo changed >foo && git commit -a -m "changed foo"
+	: >foo &&
+	git add foo &&
+	git commit -m "added foo" &&
+	head1=$(git rev-parse --verify HEAD) &&
+	head1_short=$(git rev-parse --verify --short $head1) &&
+	tree1=$(git rev-parse --verify HEAD:) &&
+	tree1_short=$(git rev-parse --verify --short $tree1) &&
+	echo changed >foo &&
+	git commit -a -m "changed foo" &&
+	head2=$(git rev-parse --verify HEAD) &&
+	head2_short=$(git rev-parse --verify --short $head2) &&
+	tree2=$(git rev-parse --verify HEAD:) &&
+	tree2_short=$(git rev-parse --verify --short $tree2)
 '
 
 # usage: test_format name format_string <expected_output
@@ -32,49 +43,49 @@ has_no_color () {
 	test_cmp expect "$1"
 }
 
-test_format percent %%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format percent %%h <<EOF
+commit $head2
 %h
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 %h
 EOF
 
-test_format hash %H%n%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-131a310eb913d107dd3c09a65d1651175898735d
-131a310
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
+test_format hash %H%n%h <<EOF
+commit $head2
+$head2
+$head2_short
+commit $head1
+$head1
+$head1_short
 EOF
 
-test_format tree %T%n%t <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-fe722612f26da5064c32ca3843aa154bdb0b08a0
-fe72261
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-4d5fcadc293a348e88f777dc0920f11e7d71441c
-4d5fcad
+test_format tree %T%n%t <<EOF
+commit $head2
+$tree2
+$tree2_short
+commit $head1
+$tree1
+$tree1_short
 EOF
 
-test_format parents %P%n%p <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format parents %P%n%p <<EOF
+commit $head2
+$head1
+$head1_short
+commit $head1
 
 
 EOF
 
 # we don't test relative here
-test_format author %an%n%ae%n%ad%n%aD%n%at <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format author %an%n%ae%n%ad%n%aD%n%at <<EOF
+commit $head2
 A U Thor
 author@example.com
 Thu Apr 7 15:13:13 2005 -0700
 Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 A U Thor
 author@example.com
 Thu Apr 7 15:13:13 2005 -0700
@@ -82,14 +93,14 @@ Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
 EOF
 
-test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<EOF
+commit $head2
 C O Mitter
 committer@example.com
 Thu Apr 7 15:13:13 2005 -0700
 Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 C O Mitter
 committer@example.com
 Thu Apr 7 15:13:13 2005 -0700
@@ -97,43 +108,43 @@ Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
 EOF
 
-test_format encoding %e <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format encoding %e <<EOF
+commit $head2
+commit $head1
 EOF
 
-test_format subject %s <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format subject %s <<EOF
+commit $head2
 changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 added foo
 EOF
 
-test_format body %b <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format body %b <<EOF
+commit $head2
+commit $head1
 EOF
 
-test_format raw-body %B <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format raw-body %B <<EOF
+commit $head2
 changed foo
 
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 added foo
 
 EOF
 
-test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<EOF
+commit $head2
 ^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 ^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
 EOF
 
-test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<EOF
+commit $head2
 ^[[1;31;43mfoo^[[m
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 ^[[1;31;43mfoo^[[m
 EOF
 
@@ -186,39 +197,42 @@ This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
 include an iso8859 character: ¡bueno!
 EOF
+
 test_expect_success 'setup complex body' '
-git config i18n.commitencoding iso8859-1 &&
-  echo change2 >foo && git commit -a -F commit-msg
+	git config i18n.commitencoding iso8859-1 &&
+	echo change2 >foo && git commit -a -F commit-msg &&
+	head3=$(git rev-parse --verify HEAD) &&
+	head3_short=$(git rev-parse --short $head3)
 '
 
-test_format complex-encoding %e <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
+test_format complex-encoding %e <<EOF
+commit $head3
 iso8859-1
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head2
+commit $head1
 EOF
 
-test_format complex-subject %s <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
+test_format complex-subject %s <<EOF
+commit $head3
 Test printing of complex bodies
-commit 131a310eb913d107dd3c09a65d1651175898735d
+commit $head2
 changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 added foo
 EOF
 
-test_format complex-body %b <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
+test_format complex-body %b <<EOF
+commit $head3
 This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
 include an iso8859 character: ¡bueno!
 
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head2
+commit $head1
 EOF
 
 test_expect_success '%x00 shows NUL' '
-	echo  >expect commit 1ed88da4a5b5ed8c449114ac131efc62178734c3 &&
+	echo  >expect commit $head3 &&
 	echo >>expect fooQbar &&
 	git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
 	nul_to_q <actual.nul >actual &&
-- 
1.8.3.1.15.g5c23c1e

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

* [PATCH v7 2/5] t7102 (reset): don't hardcode SHA-1 in expected outputs
  2013-06-25  8:55                         ` [PATCH v6 " Alexey Shumkin
                                             ` (2 preceding siblings ...)
  2013-06-26 10:19                           ` [PATCH v7 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
@ 2013-06-26 10:19                           ` Alexey Shumkin
  2013-06-26 10:19                           ` [PATCH v7 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
                                             ` (2 subsequent siblings)
  6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-26 10:19 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 t/t7102-reset.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index df82ec9..05dfb27 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -192,7 +192,8 @@ test_expect_success \
 	'changing files and redo the last commit should succeed' '
 	echo "3rd line 2nd file" >>secondfile &&
 	git commit -a -C ORIG_HEAD &&
-	check_changes 3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d &&
+	head4=$(git rev-parse --verify HEAD) &&
+	check_changes $head4 &&
 	test "$(git rev-parse ORIG_HEAD)" = \
 			$head5
 '
@@ -211,7 +212,7 @@ test_expect_success \
 	git reset --hard HEAD~2 &&
 	check_changes ddaefe00f1da16864591c61fdc7adb5d7cd6b74e &&
 	test "$(git rev-parse ORIG_HEAD)" = \
-			3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d
+			$head4
 '
 
 >.diff_expect
@@ -326,10 +327,11 @@ test_expect_success '--hard reset to HEAD should clear a failed merge' '
 	git checkout branch2 &&
 	echo "3rd line in branch2" >>secondfile &&
 	git commit -a -m "change in branch2" &&
+	head3=$(git rev-parse --verify HEAD) &&
 
 	test_must_fail git pull . branch1 &&
 	git reset --hard &&
-	check_changes 77abb337073fb4369a7ad69ff6f5ec0e4d6b54bb
+	check_changes $head3
 '
 
 >.diff_expect
-- 
1.8.3.1.15.g5c23c1e

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

* [PATCH v7 3/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
  2013-06-25  8:55                         ` [PATCH v6 " Alexey Shumkin
                                             ` (3 preceding siblings ...)
  2013-06-26 10:19                           ` [PATCH v7 2/5] t7102 (reset): " Alexey Shumkin
@ 2013-06-26 10:19                           ` Alexey Shumkin
  2013-06-26 10:19                           ` [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
  2013-06-26 10:19                           ` [PATCH v7 5/5] pretty: " Alexey Shumkin
  6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-26 10:19 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 t/t4205-log-pretty-formats.sh | 48 +++++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 22 deletions(-)

diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 26fbfde..73ba5e8 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -101,7 +101,11 @@ test_expect_failure 'NUL termination with --stat' '
 
 test_expect_success 'setup more commits' '
 	test_commit "message one" one one message-one &&
-	test_commit "message two" two two message-two
+	test_commit "message two" two two message-two &&
+	head1=$(git rev-parse --verify --short HEAD~0) &&
+	head2=$(git rev-parse --verify --short HEAD~1) &&
+	head3=$(git rev-parse --verify --short HEAD~2) &&
+	head4=$(git rev-parse --verify --short HEAD~3)
 '
 
 test_expect_success 'left alignment formatting' '
@@ -117,18 +121,18 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'left alignment formatting at the nth column' '
-	git log --pretty="format:%h %<|(40)%s" >actual &&
+test_expect_success 'left alignment formatting at the nth column' "
+	git log --pretty='format:%h %<|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
-fa33ab1 message two                    Z
-7cd6c63 message one                    Z
-1711bf9 add bar                        Z
-af20c06 initial                        Z
+$head1 message two                    Z
+$head2 message one                    Z
+$head3 add bar                        Z
+$head4 initial                        Z
 EOF
 	test_cmp expected actual
-'
+"
 
 test_expect_success 'left alignment formatting with no padding' '
 	git log --pretty="format:%<(1)%s" >actual &&
@@ -195,18 +199,18 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'right alignment formatting at the nth column' '
-	git log --pretty="format:%h %>|(40)%s" >actual &&
+test_expect_success 'right alignment formatting at the nth column' "
+	git log --pretty='format:%h %>|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
-fa33ab1                      message two
-7cd6c63                      message one
-1711bf9                          add bar
-af20c06                          initial
+$head1                      message two
+$head2                      message one
+$head3                          add bar
+$head4                          initial
 EOF
 	test_cmp expected actual
-'
+"
 
 test_expect_success 'right alignment formatting with no padding' '
 	git log --pretty="format:%>(1)%s" >actual &&
@@ -234,18 +238,18 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'center alignment formatting at the nth column' '
-	git log --pretty="format:%h %><|(40)%s" >actual &&
+test_expect_success 'center alignment formatting at the nth column' "
+	git log --pretty='format:%h %><|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
-fa33ab1           message two          Z
-7cd6c63           message one          Z
-1711bf9             add bar            Z
-af20c06             initial            Z
+$head1           message two          Z
+$head2           message one          Z
+$head3             add bar            Z
+$head4             initial            Z
 EOF
 	test_cmp expected actual
-'
+"
 
 test_expect_success 'center alignment formatting with no padding' '
 	git log --pretty="format:%><(1)%s" >actual &&
-- 
1.8.3.1.15.g5c23c1e

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

* [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
  2013-06-25  8:55                         ` [PATCH v6 " Alexey Shumkin
                                             ` (4 preceding siblings ...)
  2013-06-26 10:19                           ` [PATCH v7 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
@ 2013-06-26 10:19                           ` Alexey Shumkin
  2013-07-01  7:00                             ` Johannes Sixt
  2013-06-26 10:19                           ` [PATCH v7 5/5] pretty: " Alexey Shumkin
  6 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-26 10:19 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 22510 bytes --]

One can set an alias
	$ git config alias.lg "log --graph --pretty=format:'%Cred%h%Creset
	-%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset'
	--abbrev-commit --date=local"

to see the log as a pretty tree (like *gitk* but in a terminal).

However, log messages written in an encoding i18n.commitEncoding which differs
from terminal encoding are shown corrupted even when i18n.logOutputEncoding
and terminal encoding are the same (e.g. log messages committed on a Cygwin box
with Windows-1251 encoding seen on a Linux box with a UTF-8 encoding and vice versa).

To simplify an example we can say the following two commands are expected
to give the same output to a terminal:

	$ git log --oneline --no-color
	$ git log --pretty=format:'%h %s'

However, the former pays attention to i18n.logOutputEncoding
configuration, while the latter does not when it formats "%s".

The same corruption is true for
	$ git diff --submodule=log
and
	$ git rev-list --pretty=format:%s HEAD
and
	$ git reset --hard

This patch adds failing tests for the next patch that fixes them.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 t/t4041-diff-submodule-option.sh |  35 +++++----
 t/t4205-log-pretty-formats.sh    | 149 ++++++++++++++++++++++++---------------
 t/t6006-rev-list-format.sh       |  83 +++++++++++++++-------
 t/t7102-reset.sh                 |  29 +++++++-
 4 files changed, 199 insertions(+), 97 deletions(-)

diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 32d4a60..2a7877d 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 #
 # Copyright (c) 2009 Jens Lehmann, based on t7401 by Ping Yin
+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
 #
 
 test_description='Support for verbose submodule differences in git diff
@@ -10,6 +11,9 @@ This test tries to verify the sanity of the --submodule option of git diff.
 
 . ./test-lib.sh
 
+# String "added" in German (translated with Google Translate), encoded in UTF-8,
+# used in sample commit log messages in add_file() function below.
+added=$(printf "hinzugef\303\274gt")
 add_file () {
 	(
 		cd "$1" &&
@@ -19,7 +23,8 @@ add_file () {
 			echo "$name" >"$name" &&
 			git add "$name" &&
 			test_tick &&
-			git commit -m "Add $name" || exit
+			msg_added_iso88591=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t iso-8859-1) &&
+			git -c 'i18n.commitEncoding=iso-8859-1' commit -m "$msg_added_iso88591"
 		done >/dev/null &&
 		git rev-parse --short --verify HEAD
 	)
@@ -89,29 +94,29 @@ test_expect_success 'diff.submodule does not affect plumbing' '
 commit_file sm1 &&
 head2=$(add_file sm1 foo3)
 
-test_expect_success 'modified submodule(forward)' '
+test_expect_failure 'modified submodule(forward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
-	  > Add foo3
+	  > Add foo3 ($added foo3)
 	EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'modified submodule(forward)' '
+test_expect_failure 'modified submodule(forward)' '
 	git diff --submodule=log >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
-	  > Add foo3
+	  > Add foo3 ($added foo3)
 	EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'modified submodule(forward) --submodule' '
+test_expect_failure 'modified submodule(forward) --submodule' '
 	git diff --submodule >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
-	  > Add foo3
+	  > Add foo3 ($added foo3)
 	EOF
 	test_cmp expected actual
 '
@@ -138,25 +143,25 @@ head3=$(
 	git rev-parse --short --verify HEAD
 )
 
-test_expect_success 'modified submodule(backward)' '
+test_expect_failure 'modified submodule(backward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head2..$head3 (rewind):
-	  < Add foo3
-	  < Add foo2
+	  < Add foo3 ($added foo3)
+	  < Add foo2 ($added foo2)
 	EOF
 	test_cmp expected actual
 '
 
 head4=$(add_file sm1 foo4 foo5)
-test_expect_success 'modified submodule(backward and forward)' '
+test_expect_failure 'modified submodule(backward and forward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head2...$head4:
-	  > Add foo5
-	  > Add foo4
-	  < Add foo3
-	  < Add foo2
+	  > Add foo5 ($added foo5)
+	  > Add foo4 ($added foo4)
+	  < Add foo3 ($added foo3)
+	  < Add foo2 ($added foo2)
 	EOF
 	test_cmp expected actual
 '
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 73ba5e8..6b62da2 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -1,20 +1,43 @@
 #!/bin/sh
 #
 # Copyright (c) 2010, Will Palmer
+# Copyright (c) 2011, Alexey Shumkin (+ non-UTF-8 commit encoding tests)
 #
 
 test_description='Test pretty formats'
 . ./test-lib.sh
 
+commit_msg() {
+	# String "initial. initial" partly in German (translated with Google Translate),
+	# encoded in UTF-8, used as a commit log message below.
+	msg=$(printf "initial. anf\303\244nglich")
+	if test -n "$1"
+	then
+		msg=$(echo $msg | iconv -f utf-8 -t $1)
+	fi
+	if test -n "$2" -a -n "$3"
+	then
+		# cut string, replace cut part with two dots
+		# $2 - chars count from the beginning of the string
+		# $3 - "trailing" chars
+		# LC_ALL is set to make `sed` interpret "." as a UTF-8 char not a byte
+		# as it does with C locale
+		msg=$(echo $msg | LC_ALL=en_US.UTF-8 sed -e "s/^\(.\{$2\}\)$3/\1../")
+	fi
+	echo $msg
+}
+
 test_expect_success 'set up basic repos' '
 	>foo &&
 	>bar &&
 	git add foo &&
 	test_tick &&
-	git commit -m initial &&
+	git config i18n.commitEncoding iso-8859-1 &&
+	git commit -m "$(commit_msg iso-8859-1)" &&
 	git add bar &&
 	test_tick &&
-	git commit -m "add bar"
+	git commit -m "add bar" &&
+	git config --unset i18n.commitEncoding
 '
 
 test_expect_success 'alias builtin format' '
@@ -38,6 +61,20 @@ test_expect_success 'alias user-defined format' '
 	test_cmp expected actual
 '
 
+test_expect_success 'alias user-defined tformat with %s (iso-8859-1 encoding)' '
+	git config i18n.logOutputEncoding iso-8859-1 &&
+	git log --oneline >expected-s &&
+	git log --pretty="tformat:%h %s" >actual-s &&
+	git config --unset i18n.logOutputEncoding &&
+	test_cmp expected-s actual-s
+'
+
+test_expect_failure 'alias user-defined tformat with %s (utf-8 encoding)' '
+	git log --oneline >expected-s &&
+	git log --pretty="tformat:%h %s" >actual-s &&
+	test_cmp expected-s actual-s
+'
+
 test_expect_success 'alias user-defined tformat' '
 	git log --pretty="tformat:%h" >expected &&
 	git config pretty.test-alias "tformat:%h" &&
@@ -71,22 +108,22 @@ test_expect_success 'alias loop' '
 	test_must_fail git log --pretty=test-foo
 '
 
-test_expect_success 'NUL separation' '
-	printf "add bar\0initial" >expected &&
+test_expect_failure 'NUL separation' '
+	printf "add bar\0$(commit_msg)" >expected &&
 	git log -z --pretty="format:%s" >actual &&
 	test_cmp expected actual
 '
 
-test_expect_success 'NUL termination' '
-	printf "add bar\0initial\0" >expected &&
+test_expect_failure 'NUL termination' '
+	printf "add bar\0$(commit_msg)\0" >expected &&
 	git log -z --pretty="tformat:%s" >actual &&
 	test_cmp expected actual
 '
 
-test_expect_success 'NUL separation with --stat' '
+test_expect_failure 'NUL separation with --stat' '
 	stat0_part=$(git diff --stat HEAD^ HEAD) &&
 	stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
-	printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n" >expected &&
+	printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected &&
 	git log -z --stat --pretty="format:%s" >actual &&
 	test_i18ncmp expected actual
 '
@@ -94,7 +131,7 @@ test_expect_success 'NUL separation with --stat' '
 test_expect_failure 'NUL termination with --stat' '
 	stat0_part=$(git diff --stat HEAD^ HEAD) &&
 	stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
-	printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n\0" >expected &&
+	printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n0" >expected &&
 	git log -z --stat --pretty="tformat:%s" >actual &&
 	test_i18ncmp expected actual
 '
@@ -108,20 +145,20 @@ test_expect_success 'setup more commits' '
 	head4=$(git rev-parse --verify --short HEAD~3)
 '
 
-test_expect_success 'left alignment formatting' '
-	git log --pretty="format:%<(40)%s" >actual &&
+test_expect_failure 'left alignment formatting' "
+	git log --pretty='format:%<(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
 message two                            Z
 message one                            Z
 add bar                                Z
-initial                                Z
+$(commit_msg)                    Z
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'left alignment formatting at the nth column' "
+test_expect_failure 'left alignment formatting at the nth column' "
 	git log --pretty='format:%h %<|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -129,77 +166,77 @@ test_expect_success 'left alignment formatting at the nth column' "
 $head1 message two                    Z
 $head2 message one                    Z
 $head3 add bar                        Z
-$head4 initial                        Z
+$head4 $(commit_msg)            Z
 EOF
 	test_cmp expected actual
 "
 
-test_expect_success 'left alignment formatting with no padding' '
-	git log --pretty="format:%<(1)%s" >actual &&
+test_expect_failure 'left alignment formatting with no padding' "
+	git log --pretty='format:%<(1)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	cat <<\EOF >expected &&
 message two
 message one
 add bar
-initial
+$(commit_msg)
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'left alignment formatting with trunc' '
-	git log --pretty="format:%<(10,trunc)%s" >actual &&
+test_expect_failure 'left alignment formatting with trunc' "
+	git log --pretty='format:%<(10,trunc)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
 message ..
 message ..
 add bar  Z
-initial  Z
+$(commit_msg "" "8" ".\+$")
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'left alignment formatting with ltrunc' '
-	git log --pretty="format:%<(10,ltrunc)%s" >actual &&
+test_expect_failure 'left alignment formatting with ltrunc' "
+	git log --pretty='format:%<(10,ltrunc)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
 ..sage two
 ..sage one
 add bar  Z
-initial  Z
+$(commit_msg "" "0" ".\{11\}")
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'left alignment formatting with mtrunc' '
-	git log --pretty="format:%<(10,mtrunc)%s" >actual &&
+test_expect_failure 'left alignment formatting with mtrunc' "
+	git log --pretty='format:%<(10,mtrunc)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
 mess.. two
 mess.. one
 add bar  Z
-initial  Z
+$(commit_msg "" "4" ".\{11\}")
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'right alignment formatting' '
-	git log --pretty="format:%>(40)%s" >actual &&
+test_expect_failure 'right alignment formatting' "
+	git log --pretty='format:%>(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
 Z                            message two
 Z                            message one
 Z                                add bar
-Z                                initial
+Z                    $(commit_msg)
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'right alignment formatting at the nth column' "
+test_expect_failure 'right alignment formatting at the nth column' "
 	git log --pretty='format:%h %>|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -207,38 +244,38 @@ test_expect_success 'right alignment formatting at the nth column' "
 $head1                      message two
 $head2                      message one
 $head3                          add bar
-$head4                          initial
+$head4              $(commit_msg)
 EOF
 	test_cmp expected actual
 "
 
-test_expect_success 'right alignment formatting with no padding' '
-	git log --pretty="format:%>(1)%s" >actual &&
+test_expect_failure 'right alignment formatting with no padding' "
+	git log --pretty='format:%>(1)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	cat <<\EOF >expected &&
 message two
 message one
 add bar
-initial
+$(commit_msg)
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'center alignment formatting' '
-	git log --pretty="format:%><(40)%s" >actual &&
+test_expect_failure 'center alignment formatting' "
+	git log --pretty='format:%><(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
 Z             message two              Z
 Z             message one              Z
 Z               add bar                Z
-Z               initial                Z
+Z         $(commit_msg)          Z
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'center alignment formatting at the nth column' "
+test_expect_failure 'center alignment formatting at the nth column' "
 	git log --pretty='format:%h %><|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -246,36 +283,36 @@ test_expect_success 'center alignment formatting at the nth column' "
 $head1           message two          Z
 $head2           message one          Z
 $head3             add bar            Z
-$head4             initial            Z
+$head4       $(commit_msg)      Z
 EOF
 	test_cmp expected actual
 "
 
-test_expect_success 'center alignment formatting with no padding' '
-	git log --pretty="format:%><(1)%s" >actual &&
+test_expect_failure 'center alignment formatting with no padding' "
+	git log --pretty='format:%><(1)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	cat <<\EOF >expected &&
 message two
 message one
 add bar
-initial
+$(commit_msg)
 EOF
 	test_cmp expected actual
-'
+"
 
-test_expect_success 'left/right alignment formatting with stealing' '
-	git commit --amend -m short --author "long long long <long@me.com>" &&
-	git log --pretty="format:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
+test_expect_failure 'left/right alignment formatting with stealing' "
+	git commit --amend -m short --author 'long long long <long@me.com>' &&
+	git log --pretty='format:%<(10,trunc)%s%>>(10,ltrunc)% an' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	cat <<\EOF >expected &&
 short long  long long
 message ..   A U Thor
 add bar      A U Thor
-initial      A U Thor
+$(commit_msg "" "8" ".\+$")   A U Thor
 EOF
 	test_cmp expected actual
-'
+"
 
 test_done
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index cc1008d..c66a07f 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -1,34 +1,60 @@
 #!/bin/sh
 
+# Copyright (c) 2009 Jens Lehmann
+# Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
+
 test_description='git rev-list --pretty=format test'
 
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-terminal.sh
 
 test_tick
+# String "added" in German (translated with Google Translate), encoded in UTF-8,
+# used as a commit log message below.
+added=$(printf "added (hinzugef\303\274gt) foo")
+added_iso88591=$(echo "$added" | iconv -f utf-8 -t iso-8859-1)
+# same but "changed"
+changed=$(printf "changed (ge\303\244ndert) foo")
+changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t iso-8859-1)
+
 test_expect_success 'setup' '
 	: >foo &&
 	git add foo &&
-	git commit -m "added foo" &&
+	git config i18n.commitEncoding iso-8859-1 &&
+	git commit -m "$added_iso88591" &&
 	head1=$(git rev-parse --verify HEAD) &&
 	head1_short=$(git rev-parse --verify --short $head1) &&
 	tree1=$(git rev-parse --verify HEAD:) &&
 	tree1_short=$(git rev-parse --verify --short $tree1) &&
-	echo changed >foo &&
-	git commit -a -m "changed foo" &&
+	echo "$changed" > foo &&
+	git commit -a -m "$changed_iso88591" &&
 	head2=$(git rev-parse --verify HEAD) &&
 	head2_short=$(git rev-parse --verify --short $head2) &&
 	tree2=$(git rev-parse --verify HEAD:) &&
 	tree2_short=$(git rev-parse --verify --short $tree2)
+	git config --unset i18n.commitEncoding
 '
 
-# usage: test_format name format_string <expected_output
+# usage: test_format [failure] name format_string <expected_output
 test_format () {
+	must_fail=0
+	# if parameters count is more than 2 then test must fail
+	if test $# -gt 2
+	then
+		must_fail=1
+		# remove first parameter which is flag for test failure
+		shift
+	fi
 	cat >expect.$1
-	test_expect_success "format $1" "
-		git rev-list --pretty=format:'$2' master >output.$1 &&
-		test_cmp expect.$1 output.$1
-	"
+	name="format $1"
+	command="git rev-list --pretty=format:'$2' master >output.$1 &&
+		test_cmp expect.$1 output.$1"
+	if test $must_fail -eq 1
+	then
+		test_expect_failure "$name" "$command"
+	else
+		test_expect_success "$name" "$command"
+	fi
 }
 
 # Feed to --format to provide predictable colored sequences.
@@ -110,14 +136,16 @@ EOF
 
 test_format encoding %e <<EOF
 commit $head2
+iso-8859-1
 commit $head1
+iso-8859-1
 EOF
 
-test_format subject %s <<EOF
+test_format failure subject %s <<EOF
 commit $head2
-changed foo
+$changed
 commit $head1
-added foo
+$added
 EOF
 
 test_format body %b <<EOF
@@ -125,12 +153,12 @@ commit $head2
 commit $head1
 EOF
 
-test_format raw-body %B <<EOF
+test_format failure raw-body %B <<EOF
 commit $head2
-changed foo
+$changed
 
 commit $head1
-added foo
+$added
 
 EOF
 
@@ -190,42 +218,49 @@ test_expect_success '%C(auto) respects --color=auto (stdout not tty)' '
 	)
 '
 
-cat >commit-msg <<'EOF'
+iconv -f utf-8 -t iso8859-1 > commit-msg <<EOF
 Test printing of complex bodies
 
 This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
-include an iso8859 character: ¡bueno!
+include an iso8859 character: ¡bueno!
 EOF
 
 test_expect_success 'setup complex body' '
 	git config i18n.commitencoding iso8859-1 &&
 	echo change2 >foo && git commit -a -F commit-msg &&
 	head3=$(git rev-parse --verify HEAD) &&
-	head3_short=$(git rev-parse --short $head3)
+	head3_short=$(git rev-parse --short $head3) &&
+	# unset commit encoding config
+	# otherwise %e does not print encoding value
+	# and following test fails
+	git config --unset i18n.commitEncoding
+
 '
 
 test_format complex-encoding %e <<EOF
 commit $head3
 iso8859-1
 commit $head2
+iso-8859-1
 commit $head1
+iso-8859-1
 EOF
 
-test_format complex-subject %s <<EOF
+test_format failure complex-subject %s <<EOF
 commit $head3
 Test printing of complex bodies
 commit $head2
-changed foo
+$changed
 commit $head1
-added foo
+$added
 EOF
 
-test_format complex-body %b <<EOF
+test_format failure complex-body %b <<EOF
 commit $head3
 This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
-include an iso8859 character: ¡bueno!
+include an iso8859 character: ¡bueno!
 
 commit $head2
 commit $head1
@@ -279,12 +314,12 @@ test_expect_success 'add LF before non-empty (2)' '
 
 test_expect_success 'add SP before non-empty (1)' '
 	git show -s --pretty=format:"%s% bThanks" HEAD^^ >actual &&
-	test $(wc -w <actual) = 2
+	test $(wc -w <actual) = 3
 '
 
 test_expect_success 'add SP before non-empty (2)' '
 	git show -s --pretty=format:"%s% sThanks" HEAD^^ >actual &&
-	test $(wc -w <actual) = 4
+	test $(wc -w <actual) = 6
 '
 
 test_expect_success '--abbrev' '
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 05dfb27..72e364e 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -9,6 +9,17 @@ Documented tests for git reset'
 
 . ./test-lib.sh
 
+commit_msg() {
+	# String "modify 2nd file (changed)" partly in German(translated with Google Translate),
+	# encoded in UTF-8, used as a commit log message below.
+	msg=$(printf "modify 2nd file (ge\303\244ndert)")
+	if test -n "$1"
+	then
+		msg=$(echo $msg | iconv -f utf-8 -t $1)
+	fi
+	echo $msg
+}
+
 test_expect_success 'creating initial files and commits' '
 	test_tick &&
 	echo "1st file" >first &&
@@ -28,7 +39,7 @@ test_expect_success 'creating initial files and commits' '
 
 	echo "1st line 2nd file" >secondfile &&
 	echo "2nd line 2nd file" >>secondfile &&
-	git commit -a -m "modify 2nd file" &&
+	git -c "i18n.commitEncoding=iso-8859-1" commit -a -m "$(commit_msg iso-8859-1)" &&
 	head5=$(git rev-parse --verify HEAD)
 '
 # git log --pretty=oneline # to see those SHA1 involved
@@ -44,6 +55,20 @@ check_changes () {
 	done | test_cmp .cat_expect -
 }
 
+test_expect_failure 'reset --hard message' '
+	hex=$(git log -1 --format="%h") &&
+	git reset --hard > .actual &&
+	echo HEAD is now at $hex $(commit_msg) > .expected &&
+	test_cmp .expected .actual
+'
+
+test_expect_success 'reset --hard message (iso-8859-1 logoutencoding)' '
+	hex=$(git log -1 --format="%h") &&
+	git -c "i18n.logOutputEncoding=iso-8859-1" reset --hard > .actual &&
+	echo HEAD is now at $hex $(commit_msg iso-8859-1) > .expected &&
+	test_cmp .expected .actual
+'
+
 >.diff_expect
 >.cached_expect
 cat >.cat_expect <<EOF
@@ -304,7 +329,7 @@ test_expect_success 'redoing the last two commits should succeed' '
 
 	echo "1st line 2nd file" >secondfile &&
 	echo "2nd line 2nd file" >>secondfile &&
-	git commit -a -m "modify 2nd file" &&
+	git -c "i18n.commitEncoding=iso-8859-1" commit -a -m "$(commit_msg iso-8859-1)" &&
 	check_changes $head5
 '
 
-- 
1.8.3.1.15.g5c23c1e

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

* [PATCH v7 5/5] pretty: --format output should honor logOutputEncoding
  2013-06-25  8:55                         ` [PATCH v6 " Alexey Shumkin
                                             ` (5 preceding siblings ...)
  2013-06-26 10:19                           ` [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
@ 2013-06-26 10:19                           ` Alexey Shumkin
  6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-06-26 10:19 UTC (permalink / raw)
  To: git; +Cc: Alexey Shumkin, Junio C Hamano

One can set an alias
	$ git config [--global] alias.lg "log --graph --pretty=format:'%Cred%h%Creset
	-%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset'
	--abbrev-commit --date=local"

to see the log as a pretty tree (like *gitk* but in a terminal).

However, log messages written in an encoding i18n.commitEncoding which differs
from terminal encoding are shown corrupted even when i18n.logOutputEncoding
and terminal encoding are the same (e.g. log messages committed on a Cygwin box
with Windows-1251 encoding seen on a Linux box with a UTF-8 encoding and vice versa).

To simplify an example we can say the following two commands are expected
to give the same output to a terminal:

	$ git log --oneline --no-color
	$ git log --pretty=format:'%h %s'

However, the former pays attention to i18n.logOutputEncoding
configuration, while the latter does not when it formats "%s".

The same corruption is true for
	$ git diff --submodule=log
and
	$ git rev-list --pretty=format:%s HEAD
and
	$ git reset --hard

This patch makes pretty --format honor logOutputEncoding when it formats
log message.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 builtin/reset.c                  |  5 ++++-
 builtin/rev-list.c               |  1 +
 builtin/shortlog.c               |  1 +
 log-tree.c                       |  1 +
 submodule.c                      |  1 +
 t/t4041-diff-submodule-option.sh | 10 +++++-----
 t/t4205-log-pretty-formats.sh    | 34 +++++++++++++++++-----------------
 t/t6006-rev-list-format.sh       |  8 ++++----
 t/t7102-reset.sh                 |  2 +-
 9 files changed, 35 insertions(+), 28 deletions(-)

diff --git a/builtin/reset.c b/builtin/reset.c
index 6032131..afa6e02 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -93,10 +93,12 @@ static int reset_index(const unsigned char *sha1, int reset_type, int quiet)
 static void print_new_head_line(struct commit *commit)
 {
 	const char *hex, *body;
+	char *msg;
 
 	hex = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
 	printf(_("HEAD is now at %s"), hex);
-	body = strstr(commit->buffer, "\n\n");
+	msg = logmsg_reencode(commit, NULL, get_log_output_encoding());
+	body = strstr(msg, "\n\n");
 	if (body) {
 		const char *eol;
 		size_t len;
@@ -107,6 +109,7 @@ static void print_new_head_line(struct commit *commit)
 	}
 	else
 		printf("\n");
+	logmsg_free(msg, commit);
 }
 
 static void update_index_from_diff(struct diff_queue_struct *q,
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 67701be..a5ec30d 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -111,6 +111,7 @@ static void show_commit(struct commit *commit, void *data)
 		ctx.date_mode = revs->date_mode;
 		ctx.date_mode_explicit = revs->date_mode_explicit;
 		ctx.fmt = revs->commit_format;
+		ctx.output_encoding = get_log_output_encoding();
 		pretty_print_commit(&ctx, commit, &buf);
 		if (revs->graph) {
 			if (buf.len) {
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 1fd6f8a..1434f8f 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -137,6 +137,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
 		ctx.subject = "";
 		ctx.after_subject = "";
 		ctx.date_mode = DATE_NORMAL;
+		ctx.output_encoding = get_log_output_encoding();
 		pretty_print_commit(&ctx, commit, &ufbuf);
 		buffer = ufbuf.buf;
 	} else if (*buffer) {
diff --git a/log-tree.c b/log-tree.c
index 1946e9c..5277d3e 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -616,6 +616,7 @@ void show_log(struct rev_info *opt)
 	ctx.fmt = opt->commit_format;
 	ctx.mailmap = opt->mailmap;
 	ctx.color = opt->diffopt.use_color;
+	ctx.output_encoding = get_log_output_encoding();
 	pretty_print_commit(&ctx, commit, &msgbuf);
 
 	if (opt->add_signoff)
diff --git a/submodule.c b/submodule.c
index 1821a5b..78734e1 100644
--- a/submodule.c
+++ b/submodule.c
@@ -226,6 +226,7 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
 	while ((commit = get_revision(rev))) {
 		struct pretty_print_context ctx = {0};
 		ctx.date_mode = rev->date_mode;
+		ctx.output_encoding = get_log_output_encoding();
 		strbuf_setlen(&sb, 0);
 		strbuf_addstr(&sb, line_prefix);
 		if (commit->object.flags & SYMMETRIC_LEFT) {
diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 2a7877d..0a4f496 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -94,7 +94,7 @@ test_expect_success 'diff.submodule does not affect plumbing' '
 commit_file sm1 &&
 head2=$(add_file sm1 foo3)
 
-test_expect_failure 'modified submodule(forward)' '
+test_expect_success 'modified submodule(forward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
@@ -103,7 +103,7 @@ test_expect_failure 'modified submodule(forward)' '
 	test_cmp expected actual
 '
 
-test_expect_failure 'modified submodule(forward)' '
+test_expect_success 'modified submodule(forward)' '
 	git diff --submodule=log >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
@@ -112,7 +112,7 @@ test_expect_failure 'modified submodule(forward)' '
 	test_cmp expected actual
 '
 
-test_expect_failure 'modified submodule(forward) --submodule' '
+test_expect_success 'modified submodule(forward) --submodule' '
 	git diff --submodule >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
@@ -143,7 +143,7 @@ head3=$(
 	git rev-parse --short --verify HEAD
 )
 
-test_expect_failure 'modified submodule(backward)' '
+test_expect_success 'modified submodule(backward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head2..$head3 (rewind):
@@ -154,7 +154,7 @@ test_expect_failure 'modified submodule(backward)' '
 '
 
 head4=$(add_file sm1 foo4 foo5)
-test_expect_failure 'modified submodule(backward and forward)' '
+test_expect_success 'modified submodule(backward and forward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head2...$head4:
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 6b62da2..2fc9674 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -69,7 +69,7 @@ test_expect_success 'alias user-defined tformat with %s (iso-8859-1 encoding)' '
 	test_cmp expected-s actual-s
 '
 
-test_expect_failure 'alias user-defined tformat with %s (utf-8 encoding)' '
+test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' '
 	git log --oneline >expected-s &&
 	git log --pretty="tformat:%h %s" >actual-s &&
 	test_cmp expected-s actual-s
@@ -108,19 +108,19 @@ test_expect_success 'alias loop' '
 	test_must_fail git log --pretty=test-foo
 '
 
-test_expect_failure 'NUL separation' '
+test_expect_success 'NUL separation' '
 	printf "add bar\0$(commit_msg)" >expected &&
 	git log -z --pretty="format:%s" >actual &&
 	test_cmp expected actual
 '
 
-test_expect_failure 'NUL termination' '
+test_expect_success 'NUL termination' '
 	printf "add bar\0$(commit_msg)\0" >expected &&
 	git log -z --pretty="tformat:%s" >actual &&
 	test_cmp expected actual
 '
 
-test_expect_failure 'NUL separation with --stat' '
+test_expect_success 'NUL separation with --stat' '
 	stat0_part=$(git diff --stat HEAD^ HEAD) &&
 	stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
 	printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected &&
@@ -145,7 +145,7 @@ test_expect_success 'setup more commits' '
 	head4=$(git rev-parse --verify --short HEAD~3)
 '
 
-test_expect_failure 'left alignment formatting' "
+test_expect_success 'left alignment formatting' "
 	git log --pretty='format:%<(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -158,7 +158,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'left alignment formatting at the nth column' "
+test_expect_success 'left alignment formatting at the nth column' "
 	git log --pretty='format:%h %<|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -171,7 +171,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'left alignment formatting with no padding' "
+test_expect_success 'left alignment formatting with no padding' "
 	git log --pretty='format:%<(1)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -184,7 +184,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'left alignment formatting with trunc' "
+test_expect_success 'left alignment formatting with trunc' "
 	git log --pretty='format:%<(10,trunc)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -197,7 +197,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'left alignment formatting with ltrunc' "
+test_expect_success 'left alignment formatting with ltrunc' "
 	git log --pretty='format:%<(10,ltrunc)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -210,7 +210,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'left alignment formatting with mtrunc' "
+test_expect_success 'left alignment formatting with mtrunc' "
 	git log --pretty='format:%<(10,mtrunc)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -223,7 +223,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'right alignment formatting' "
+test_expect_success 'right alignment formatting' "
 	git log --pretty='format:%>(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -236,7 +236,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'right alignment formatting at the nth column' "
+test_expect_success 'right alignment formatting at the nth column' "
 	git log --pretty='format:%h %>|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -249,7 +249,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'right alignment formatting with no padding' "
+test_expect_success 'right alignment formatting with no padding' "
 	git log --pretty='format:%>(1)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -262,7 +262,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'center alignment formatting' "
+test_expect_success 'center alignment formatting' "
 	git log --pretty='format:%><(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -275,7 +275,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'center alignment formatting at the nth column' "
+test_expect_success 'center alignment formatting at the nth column' "
 	git log --pretty='format:%h %><|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -288,7 +288,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'center alignment formatting with no padding' "
+test_expect_success 'center alignment formatting with no padding' "
 	git log --pretty='format:%><(1)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -301,7 +301,7 @@ EOF
 	test_cmp expected actual
 "
 
-test_expect_failure 'left/right alignment formatting with stealing' "
+test_expect_success 'left/right alignment formatting with stealing' "
 	git commit --amend -m short --author 'long long long <long@me.com>' &&
 	git log --pretty='format:%<(10,trunc)%s%>>(10,ltrunc)% an' >actual &&
 	# complete the incomplete line at the end
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index c66a07f..380c85b 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -141,7 +141,7 @@ commit $head1
 iso-8859-1
 EOF
 
-test_format failure subject %s <<EOF
+test_format subject %s <<EOF
 commit $head2
 $changed
 commit $head1
@@ -153,7 +153,7 @@ commit $head2
 commit $head1
 EOF
 
-test_format failure raw-body %B <<EOF
+test_format raw-body %B <<EOF
 commit $head2
 $changed
 
@@ -247,7 +247,7 @@ commit $head1
 iso-8859-1
 EOF
 
-test_format failure complex-subject %s <<EOF
+test_format complex-subject %s <<EOF
 commit $head3
 Test printing of complex bodies
 commit $head2
@@ -256,7 +256,7 @@ commit $head1
 $added
 EOF
 
-test_format failure complex-body %b <<EOF
+test_format complex-body %b <<EOF
 commit $head3
 This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 72e364e..27b1e93 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -55,7 +55,7 @@ check_changes () {
 	done | test_cmp .cat_expect -
 }
 
-test_expect_failure 'reset --hard message' '
+test_expect_success 'reset --hard message' '
 	hex=$(git log -1 --format="%h") &&
 	git reset --hard > .actual &&
 	echo HEAD is now at $hex $(commit_msg) > .expected &&
-- 
1.8.3.1.15.g5c23c1e

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

* Re: [PATCH v6 0/5] Reroll patches against v1.8.3.1
  2013-06-26  7:37                             ` Alexey Shumkin
@ 2013-06-26 14:24                               ` Junio C Hamano
  0 siblings, 0 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-06-26 14:24 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git

Alexey Shumkin <alex.crezoff@gmail.com> writes:

> On Tue, Jun 25, 2013 at 12:28:02PM -0700, Junio C Hamano wrote:
> ...
> If someone can do the same with latin1, I'd be happy.
> ...
> But today I've taken a look to Cygwin's locales more closely and found
> out that I've used incorrect encoding name (`iso88595` instead of "canonic"
> `iso-8859-5` that Cygwin has and "understands")
>
> Nevertheless, as I've already said that is not a Russian locale specific
> issue.
> The problem in tests for me now is a language (that uses iso-8859-1
> encoding) I do not speak or even write ;)

Many of the people on thee list don't, either, and that is perfectly
OK.

For the purpose of the test, "áëîõù" should be sufficient. In a
sense, using such an artificial string would make it even clearer
than a real message that what we are testing, no?

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

* Re: [PATCH v7 0/5] Reroll patches against v1.8.3.1
  2013-06-26 10:19                           ` [PATCH v7 " Alexey Shumkin
@ 2013-06-26 16:19                             ` Junio C Hamano
  2013-07-01 23:18                             ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 Alexey Shumkin
                                               ` (5 subsequent siblings)
  6 siblings, 0 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-06-26 16:19 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git

Alexey Shumkin <Alex.Crezoff@gmail.com> writes:

> v7 of this patch series includes the following changes against v6:
> 1. [PATCH v7 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
> 	untouched
> 2. [PATCH v7 2/5] t7102 (reset): don't hardcode SHA-1 in expected outputs
> 	untouched
> 3. [PATCH v7 3/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
> 	untouched
> 4. [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
>     cp1251 encoding changed to iso-8859-1 encoding already used in tests
>     Test commit messages contain words ("changed" and "added") in German
>     (which is covered by iso-8859-1 encoding)
>     They are translated from English (verified in Russian) with Google Translate
> 5. [PATCH v7 5/5] pretty: --format output should honor logOutputEncoding
>     builtin/reset.c:
>         "const char ..., *msg;" declaration replaced with "char *msg;"
>         to avoid compiler warning on the line "logmsg_free(msg, commit);"
>
> P.S.
> It's all started here [http://thread.gmane.org/gmane.comp.version-control.git/177634]

Thanks for a quick reroll and reference to previous threads in the
cover letter.

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

* Re: [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
  2013-06-26 10:19                           ` [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
@ 2013-07-01  7:00                             ` Johannes Sixt
  2013-07-01 22:50                               ` Alexey Shumkin
  0 siblings, 1 reply; 104+ messages in thread
From: Johannes Sixt @ 2013-07-01  7:00 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git, Junio C Hamano

Am 6/26/2013 12:19, schrieb Alexey Shumkin:
> One can set an alias
> 	$ git config alias.lg "log --graph --pretty=format:'%Cred%h%Creset
> 	-%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset'
> 	--abbrev-commit --date=local"
> 
> to see the log as a pretty tree (like *gitk* but in a terminal).
> 
> However, log messages written in an encoding i18n.commitEncoding which differs
> from terminal encoding are shown corrupted even when i18n.logOutputEncoding
> and terminal encoding are the same (e.g. log messages committed on a Cygwin box
> with Windows-1251 encoding seen on a Linux box with a UTF-8 encoding and vice versa).
> 
> To simplify an example we can say the following two commands are expected
> to give the same output to a terminal:
> 
> 	$ git log --oneline --no-color
> 	$ git log --pretty=format:'%h %s'
> 
> However, the former pays attention to i18n.logOutputEncoding
> configuration, while the latter does not when it formats "%s".
> 
> The same corruption is true for
> 	$ git diff --submodule=log
> and
> 	$ git rev-list --pretty=format:%s HEAD
> and
> 	$ git reset --hard
> 
> This patch adds failing tests for the next patch that fixes them.
> 
> Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>

> diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
> index 73ba5e8..6b62da2 100755
> --- a/t/t4205-log-pretty-formats.sh
> +++ b/t/t4205-log-pretty-formats.sh
...
> +commit_msg() {
> +	# String "initial. initial" partly in German (translated with Google Translate),
> +	# encoded in UTF-8, used as a commit log message below.
> +	msg=$(printf "initial. anf\303\244nglich")
> +	if test -n "$1"
> +	then
> +		msg=$(echo $msg | iconv -f utf-8 -t $1)
> +	fi
> +	if test -n "$2" -a -n "$3"
> +	then
> +		# cut string, replace cut part with two dots
> +		# $2 - chars count from the beginning of the string
> +		# $3 - "trailing" chars
> +		# LC_ALL is set to make `sed` interpret "." as a UTF-8 char not a byte
> +		# as it does with C locale
> +		msg=$(echo $msg | LC_ALL=en_US.UTF-8 sed -e "s/^\(.\{$2\}\)$3/\1../")

This does not work as expected on Windows because sed ignores the .UTF-8
part of the locale specifier. (We don't even have en_US; we have de, but
with de.UTF-8 this doesn't work, either.)

I don't have an idea, yet, how to work it around.

> +	fi
> +	echo $msg
> +}

> -test_expect_success 'left alignment formatting with mtrunc' '
> -	git log --pretty="format:%<(10,mtrunc)%s" >actual &&
> +test_expect_failure 'left alignment formatting with mtrunc' "
> +	git log --pretty='format:%<(10,mtrunc)%s' >actual &&
>  	# complete the incomplete line at the end
>  	echo >>actual &&
>  	qz_to_tab_space <<\EOF >expected &&
>  mess.. two
>  mess.. one
>  add bar  Z
> -initial  Z
> +$(commit_msg "" "4" ".\{11\}")
>  EOF
>  	test_cmp expected actual
> -'
> +"

This is the failing test case.

BTW, if you re-roll, there would be fewer changes needed if you kept the
test code single-quoted, but changed <<\EOF to <<EOF where needed.

> diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
> index cc1008d..c66a07f 100755
> --- a/t/t6006-rev-list-format.sh
> +++ b/t/t6006-rev-list-format.sh
...
>  test_expect_success 'setup' '
>  	: >foo &&
>  	git add foo &&
> -	git commit -m "added foo" &&
> +	git config i18n.commitEncoding iso-8859-1 &&

Perhaps
	test_config i18n.commitEncoding iso-8859-1 &&

Also, it is "iso-8869-1" here, but we see "iso8859-1" already used later.
It's probably wise to use that same encoding name everywhere because we
can be very sure that the latter is already understood on all supported
platforms.

> +	git commit -m "$added_iso88591" &&
>  	head1=$(git rev-parse --verify HEAD) &&
>  	head1_short=$(git rev-parse --verify --short $head1) &&
>  	tree1=$(git rev-parse --verify HEAD:) &&
>  	tree1_short=$(git rev-parse --verify --short $tree1) &&
> -	echo changed >foo &&
> -	git commit -a -m "changed foo" &&
> +	echo "$changed" > foo &&
> +	git commit -a -m "$changed_iso88591" &&
>  	head2=$(git rev-parse --verify HEAD) &&
>  	head2_short=$(git rev-parse --verify --short $head2) &&
>  	tree2=$(git rev-parse --verify HEAD:) &&
>  	tree2_short=$(git rev-parse --verify --short $tree2)
> +	git config --unset i18n.commitEncoding
>  '
>  
> -# usage: test_format name format_string <expected_output
> +# usage: test_format [failure] name format_string <expected_output
>  test_format () {
> +	must_fail=0
> +	# if parameters count is more than 2 then test must fail
> +	if test $# -gt 2
> +	then
> +		must_fail=1
> +		# remove first parameter which is flag for test failure
> +		shift
> +	fi
>  	cat >expect.$1
> -	test_expect_success "format $1" "
> -		git rev-list --pretty=format:'$2' master >output.$1 &&
> -		test_cmp expect.$1 output.$1
> -	"
> +	name="format $1"
> +	command="git rev-list --pretty=format:'$2' master >output.$1 &&
> +		test_cmp expect.$1 output.$1"
> +	if test $must_fail -eq 1
> +	then
> +		test_expect_failure "$name" "$command"
> +	else
> +		test_expect_success "$name" "$command"
> +	fi
>  }

This function would be much shorter with the optional "failure" token as
$3 (untested):

test_format () {
	cat >expect.$1
	test_expect_${3:-success} "format $1" "
		git rev-list --pretty=format:'$2' master >output.$1 &&
		test_cmp expect.$1 output.$1
	"
}

>  test_expect_success 'setup complex body' '
>  	git config i18n.commitencoding iso8859-1 &&
>  	echo change2 >foo && git commit -a -F commit-msg &&
>  	head3=$(git rev-parse --verify HEAD) &&
> -	head3_short=$(git rev-parse --short $head3)
> +	head3_short=$(git rev-parse --short $head3) &&
> +	# unset commit encoding config
> +	# otherwise %e does not print encoding value
> +	# and following test fails

I don't understand this comment. The test vector below already shows that
an encoding is printed. Why would this suddenly be different with the
updated tests?

Assuming that this change doesn't sweep a deeper problem under the rug,
it's better to use test_config a few lines earlier.

> +	git config --unset i18n.commitEncoding
> +
>  '
>  
>  test_format complex-encoding %e <<EOF
>  commit $head3
>  iso8859-1

This is the encoding that I mean.

>  commit $head2
> +iso-8859-1
>  commit $head1
> +iso-8859-1
>  EOF

> diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
> index 05dfb27..72e364e 100755
> --- a/t/t7102-reset.sh
> +++ b/t/t7102-reset.sh
> @@ -9,6 +9,17 @@ Documented tests for git reset'
>  
>  . ./test-lib.sh
>  
> +commit_msg() {
> +	# String "modify 2nd file (changed)" partly in German(translated with Google Translate),
> +	# encoded in UTF-8, used as a commit log message below.
> +	msg=$(printf "modify 2nd file (ge\303\244ndert)")
> +	if test -n "$1"
> +	then
> +		msg=$(echo $msg | iconv -f utf-8 -t $1)
> +	fi
> +	echo $msg
> +}

If you wanted to, you could write this as

commit_msg () {
	# String "modify 2nd file (changed)" partly in German
	#(translated with Google Translate),
	# encoded in UTF-8, used as a commit log message below.
	printf "modify 2nd file (ge\303\244ndert)" |
	if test -n "$1"
	then
		iconv -f utf-8 -t $1
	else
		cat
	fi
}

but I'm not sure whether it's a lot better.

-- Hannes

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

* Re: [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
  2013-07-01  7:00                             ` Johannes Sixt
@ 2013-07-01 22:50                               ` Alexey Shumkin
  2013-07-02  7:22                                 ` Johannes Sixt
  0 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-01 22:50 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git, Junio C Hamano

On Mon, Jul 01, 2013 at 09:00:55AM +0200, Johannes Sixt wrote:
> Am 6/26/2013 12:19, schrieb Alexey Shumkin:
> > One can set an alias
> > 	$ git config alias.lg "log --graph --pretty=format:'%Cred%h%Creset
> > 	-%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset'
> > 	--abbrev-commit --date=local"
> > 
> > to see the log as a pretty tree (like *gitk* but in a terminal).
> > 
> > However, log messages written in an encoding i18n.commitEncoding which differs
> > from terminal encoding are shown corrupted even when i18n.logOutputEncoding
> > and terminal encoding are the same (e.g. log messages committed on a Cygwin box
> > with Windows-1251 encoding seen on a Linux box with a UTF-8 encoding and vice versa).
> > 
> > To simplify an example we can say the following two commands are expected
> > to give the same output to a terminal:
> > 
> > 	$ git log --oneline --no-color
> > 	$ git log --pretty=format:'%h %s'
> > 
> > However, the former pays attention to i18n.logOutputEncoding
> > configuration, while the latter does not when it formats "%s".
> > 
> > The same corruption is true for
> > 	$ git diff --submodule=log
> > and
> > 	$ git rev-list --pretty=format:%s HEAD
> > and
> > 	$ git reset --hard
> > 
> > This patch adds failing tests for the next patch that fixes them.
> > 
> > Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
> 
> > diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
> > index 73ba5e8..6b62da2 100755
> > --- a/t/t4205-log-pretty-formats.sh
> > +++ b/t/t4205-log-pretty-formats.sh
> ...
> > +commit_msg() {
> > +	# String "initial. initial" partly in German (translated with Google Translate),
> > +	# encoded in UTF-8, used as a commit log message below.
> > +	msg=$(printf "initial. anf\303\244nglich")
> > +	if test -n "$1"
> > +	then
> > +		msg=$(echo $msg | iconv -f utf-8 -t $1)
> > +	fi
> > +	if test -n "$2" -a -n "$3"
> > +	then
> > +		# cut string, replace cut part with two dots
> > +		# $2 - chars count from the beginning of the string
> > +		# $3 - "trailing" chars
> > +		# LC_ALL is set to make `sed` interpret "." as a UTF-8 char not a byte
> > +		# as it does with C locale
> > +		msg=$(echo $msg | LC_ALL=en_US.UTF-8 sed -e "s/^\(.\{$2\}\)$3/\1../")
> 
> This does not work as expected on Windows because sed ignores the .UTF-8
> part of the locale specifier. (We don't even have en_US; we have de, but
> with de.UTF-8 this doesn't work, either.)
> 
> I don't have an idea, yet, how to work it around.
> 
Hmm. I have Cygwin v1.7 (on Windows 7 and Windows 2003 Server R2)
with many locales installed (and with en_US.UTF-8 locale, too)
Today I could not find a way to run tests with "no en_US.UTF-8 locale installed" simulation
to test your failure
> > +	fi
> > +	echo $msg
> > +}
> 
> > -test_expect_success 'left alignment formatting with mtrunc' '
> > -	git log --pretty="format:%<(10,mtrunc)%s" >actual &&
> > +test_expect_failure 'left alignment formatting with mtrunc' "
> > +	git log --pretty='format:%<(10,mtrunc)%s' >actual &&
> >  	# complete the incomplete line at the end
> >  	echo >>actual &&
> >  	qz_to_tab_space <<\EOF >expected &&
> >  mess.. two
> >  mess.. one
> >  add bar  Z
> > -initial  Z
> > +$(commit_msg "" "4" ".\{11\}")
> >  EOF
> >  	test_cmp expected actual
> > -'
> > +"
> 
> This is the failing test case.
Hmm, for me all these tests pass on both Linux and Cygwin (mentioned
above) boxes
> 
> BTW, if you re-roll, there would be fewer changes needed if you kept the
> test code single-quoted, but changed <<\EOF to <<EOF where needed.
Yep, thanks for your correction

> 
> > diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
> > index cc1008d..c66a07f 100755
> > --- a/t/t6006-rev-list-format.sh
> > +++ b/t/t6006-rev-list-format.sh
> ...
> >  test_expect_success 'setup' '
> >  	: >foo &&
> >  	git add foo &&
> > -	git commit -m "added foo" &&
> > +	git config i18n.commitEncoding iso-8859-1 &&
> 
> Perhaps
> 	test_config i18n.commitEncoding iso-8859-1 &&
> 
> Also, it is "iso-8869-1" here, but we see "iso8859-1" already used later.
> It's probably wise to use that same encoding name everywhere because we
> can be very sure that the latter is already understood on all supported
> platforms.
You're right (I've looked at explanation in
3994e8a98dc7bbf67e61d23c8125f44383499a1f; I've thought ISO-8859-1 is a
common name).
> 
> > +	git commit -m "$added_iso88591" &&
> >  	head1=$(git rev-parse --verify HEAD) &&
> >  	head1_short=$(git rev-parse --verify --short $head1) &&
> >  	tree1=$(git rev-parse --verify HEAD:) &&
> >  	tree1_short=$(git rev-parse --verify --short $tree1) &&
> > -	echo changed >foo &&
> > -	git commit -a -m "changed foo" &&
> > +	echo "$changed" > foo &&
> > +	git commit -a -m "$changed_iso88591" &&
> >  	head2=$(git rev-parse --verify HEAD) &&
> >  	head2_short=$(git rev-parse --verify --short $head2) &&
> >  	tree2=$(git rev-parse --verify HEAD:) &&
> >  	tree2_short=$(git rev-parse --verify --short $tree2)
> > +	git config --unset i18n.commitEncoding
> >  '
> >  
> > -# usage: test_format name format_string <expected_output
> > +# usage: test_format [failure] name format_string <expected_output
> >  test_format () {
> > +	must_fail=0
> > +	# if parameters count is more than 2 then test must fail
> > +	if test $# -gt 2
> > +	then
> > +		must_fail=1
> > +		# remove first parameter which is flag for test failure
> > +		shift
> > +	fi
> >  	cat >expect.$1
> > -	test_expect_success "format $1" "
> > -		git rev-list --pretty=format:'$2' master >output.$1 &&
> > -		test_cmp expect.$1 output.$1
> > -	"
> > +	name="format $1"
> > +	command="git rev-list --pretty=format:'$2' master >output.$1 &&
> > +		test_cmp expect.$1 output.$1"
> > +	if test $must_fail -eq 1
> > +	then
> > +		test_expect_failure "$name" "$command"
> > +	else
> > +		test_expect_success "$name" "$command"
> > +	fi
> >  }
> 
> This function would be much shorter with the optional "failure" token as
> $3 (untested):
> 
> test_format () {
> 	cat >expect.$1
> 	test_expect_${3:-success} "format $1" "
> 		git rev-list --pretty=format:'$2' master >output.$1 &&
> 		test_cmp expect.$1 output.$1
> 	"
Thank you for your suggesstion
> }
> 
> >  test_expect_success 'setup complex body' '
> >  	git config i18n.commitencoding iso8859-1 &&
> >  	echo change2 >foo && git commit -a -F commit-msg &&
> >  	head3=$(git rev-parse --verify HEAD) &&
> > -	head3_short=$(git rev-parse --short $head3)
> > +	head3_short=$(git rev-parse --short $head3) &&
> > +	# unset commit encoding config
> > +	# otherwise %e does not print encoding value
> > +	# and following test fails
> 
> I don't understand this comment. The test vector below already shows that
> an encoding is printed. Why would this suddenly be different with the
> updated tests?
I've changed tests. I've reverted back these ones, and added
new ones with no i18n.commitEncoding set
> 
> Assuming that this change doesn't sweep a deeper problem under the rug,
> it's better to use test_config a few lines earlier.
> 
> > +	git config --unset i18n.commitEncoding
> > +
> >  '
> >  
> >  test_format complex-encoding %e <<EOF
> >  commit $head3
> >  iso8859-1
> 
> This is the encoding that I mean.
These encodings "have appeared" because we've changed 'setup':
we make commits with i18n.commitEncoding set
> 
> >  commit $head2
> > +iso-8859-1
> >  commit $head1
> > +iso-8859-1
> >  EOF
> 
> > diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
> > index 05dfb27..72e364e 100755
> > --- a/t/t7102-reset.sh
> > +++ b/t/t7102-reset.sh
> > @@ -9,6 +9,17 @@ Documented tests for git reset'
> >  
> >  . ./test-lib.sh
> >  
> > +commit_msg() {
> > +	# String "modify 2nd file (changed)" partly in German(translated with Google Translate),
> > +	# encoded in UTF-8, used as a commit log message below.
> > +	msg=$(printf "modify 2nd file (ge\303\244ndert)")
> > +	if test -n "$1"
> > +	then
> > +		msg=$(echo $msg | iconv -f utf-8 -t $1)
> > +	fi
> > +	echo $msg
> > +}
> 
> If you wanted to, you could write this as
> 
> commit_msg () {
> 	# String "modify 2nd file (changed)" partly in German
> 	#(translated with Google Translate),
> 	# encoded in UTF-8, used as a commit log message below.
> 	printf "modify 2nd file (ge\303\244ndert)" |
> 	if test -n "$1"
> 	then
> 		iconv -f utf-8 -t $1
> 	else
> 		cat
> 	fi
> }
> 
> but I'm not sure whether it's a lot better.
It looks more readable. Thank you
> 
> -- Hannes

-- 
Alexey Shumkin

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

* [PATCH v8 0/5] Reroll patches against Git v1.8.3.2
  2013-06-26 10:19                           ` [PATCH v7 " Alexey Shumkin
  2013-06-26 16:19                             ` Junio C Hamano
@ 2013-07-01 23:18                             ` Alexey Shumkin
  2013-07-02 19:41                               ` Junio C Hamano
                                                 ` (6 more replies)
  2013-07-01 23:19                             ` [PATCH v8 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
                                               ` (4 subsequent siblings)
  6 siblings, 7 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-01 23:18 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Sixt, Alexey Shumkin, git

v8 of this patch series includes the following changes against v7:
1. [PATCH v8 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
        untouched
2. [PATCH v8 2/5] t7102 (reset): don't hardcode SHA-1 in expected outputs
        untouched
3. [PATCH v8 3/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
        untouched
4. [PATCH v8 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
    Includes suggestions of Johannes Sixt:
    iso-8859-1 encoding replaced with its more "ancient" synonym "iso8859-1" already used in tests
    t/t6006-rev-list-format.sh:
       `test_format` function become simplier and more readable 
       `complex body` & `complex subject` tests are reverted back (to its "initial" state)
       2 tests added to test encoding conversions with i18n.commitEncoding unset
    t/t7102-reset.sh:
       `commit_msg` function become more readable

5. [PATCH v8 5/5] pretty: --format output should honor logOutputEncoding 
    untouched

P.S.
It's all started here [http://thread.gmane.org/gmane.comp.version-control.git/177634]

Alexey Shumkin (5):
  t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
  t7102 (reset): don't hardcode SHA-1 in expected outputs
  t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
  pretty: Add failing tests: --format output should honor
    logOutputEncoding
  pretty: --format output should honor logOutputEncoding

 builtin/reset.c                  |   5 +-
 builtin/rev-list.c               |   1 +
 builtin/shortlog.c               |   1 +
 log-tree.c                       |   1 +
 submodule.c                      |   1 +
 t/t4041-diff-submodule-option.sh |  25 +++--
 t/t4205-log-pretty-formats.sh    | 126 ++++++++++++++++--------
 t/t6006-rev-list-format.sh       | 204 +++++++++++++++++++++++++--------------
 t/t7102-reset.sh                 |  39 +++++++-
 9 files changed, 270 insertions(+), 133 deletions(-)

-- 
1.8.3.1.16.gce2c52e

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

* [PATCH v8 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
  2013-06-26 10:19                           ` [PATCH v7 " Alexey Shumkin
  2013-06-26 16:19                             ` Junio C Hamano
  2013-07-01 23:18                             ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 Alexey Shumkin
@ 2013-07-01 23:19                             ` Alexey Shumkin
  2013-07-01 23:19                             ` [PATCH v8 2/5] t7102 (reset): " Alexey Shumkin
                                               ` (3 subsequent siblings)
  6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-01 23:19 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Sixt, Alexey Shumkin, git

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 7061 bytes --]

The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 t/t6006-rev-list-format.sh | 140 +++++++++++++++++++++++++--------------------
 1 file changed, 77 insertions(+), 63 deletions(-)

diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 0393c9f..cc1008d 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -7,8 +7,19 @@ test_description='git rev-list --pretty=format test'
 
 test_tick
 test_expect_success 'setup' '
-touch foo && git add foo && git commit -m "added foo" &&
-  echo changed >foo && git commit -a -m "changed foo"
+	: >foo &&
+	git add foo &&
+	git commit -m "added foo" &&
+	head1=$(git rev-parse --verify HEAD) &&
+	head1_short=$(git rev-parse --verify --short $head1) &&
+	tree1=$(git rev-parse --verify HEAD:) &&
+	tree1_short=$(git rev-parse --verify --short $tree1) &&
+	echo changed >foo &&
+	git commit -a -m "changed foo" &&
+	head2=$(git rev-parse --verify HEAD) &&
+	head2_short=$(git rev-parse --verify --short $head2) &&
+	tree2=$(git rev-parse --verify HEAD:) &&
+	tree2_short=$(git rev-parse --verify --short $tree2)
 '
 
 # usage: test_format name format_string <expected_output
@@ -32,49 +43,49 @@ has_no_color () {
 	test_cmp expect "$1"
 }
 
-test_format percent %%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format percent %%h <<EOF
+commit $head2
 %h
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 %h
 EOF
 
-test_format hash %H%n%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-131a310eb913d107dd3c09a65d1651175898735d
-131a310
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
+test_format hash %H%n%h <<EOF
+commit $head2
+$head2
+$head2_short
+commit $head1
+$head1
+$head1_short
 EOF
 
-test_format tree %T%n%t <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-fe722612f26da5064c32ca3843aa154bdb0b08a0
-fe72261
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-4d5fcadc293a348e88f777dc0920f11e7d71441c
-4d5fcad
+test_format tree %T%n%t <<EOF
+commit $head2
+$tree2
+$tree2_short
+commit $head1
+$tree1
+$tree1_short
 EOF
 
-test_format parents %P%n%p <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format parents %P%n%p <<EOF
+commit $head2
+$head1
+$head1_short
+commit $head1
 
 
 EOF
 
 # we don't test relative here
-test_format author %an%n%ae%n%ad%n%aD%n%at <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format author %an%n%ae%n%ad%n%aD%n%at <<EOF
+commit $head2
 A U Thor
 author@example.com
 Thu Apr 7 15:13:13 2005 -0700
 Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 A U Thor
 author@example.com
 Thu Apr 7 15:13:13 2005 -0700
@@ -82,14 +93,14 @@ Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
 EOF
 
-test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<EOF
+commit $head2
 C O Mitter
 committer@example.com
 Thu Apr 7 15:13:13 2005 -0700
 Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 C O Mitter
 committer@example.com
 Thu Apr 7 15:13:13 2005 -0700
@@ -97,43 +108,43 @@ Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
 EOF
 
-test_format encoding %e <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format encoding %e <<EOF
+commit $head2
+commit $head1
 EOF
 
-test_format subject %s <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format subject %s <<EOF
+commit $head2
 changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 added foo
 EOF
 
-test_format body %b <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format body %b <<EOF
+commit $head2
+commit $head1
 EOF
 
-test_format raw-body %B <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format raw-body %B <<EOF
+commit $head2
 changed foo
 
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 added foo
 
 EOF
 
-test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<EOF
+commit $head2
 ^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 ^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
 EOF
 
-test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<EOF
+commit $head2
 ^[[1;31;43mfoo^[[m
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 ^[[1;31;43mfoo^[[m
 EOF
 
@@ -186,39 +197,42 @@ This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
 include an iso8859 character: ¡bueno!
 EOF
+
 test_expect_success 'setup complex body' '
-git config i18n.commitencoding iso8859-1 &&
-  echo change2 >foo && git commit -a -F commit-msg
+	git config i18n.commitencoding iso8859-1 &&
+	echo change2 >foo && git commit -a -F commit-msg &&
+	head3=$(git rev-parse --verify HEAD) &&
+	head3_short=$(git rev-parse --short $head3)
 '
 
-test_format complex-encoding %e <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
+test_format complex-encoding %e <<EOF
+commit $head3
 iso8859-1
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head2
+commit $head1
 EOF
 
-test_format complex-subject %s <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
+test_format complex-subject %s <<EOF
+commit $head3
 Test printing of complex bodies
-commit 131a310eb913d107dd3c09a65d1651175898735d
+commit $head2
 changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 added foo
 EOF
 
-test_format complex-body %b <<'EOF'
-commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
+test_format complex-body %b <<EOF
+commit $head3
 This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
 include an iso8859 character: ¡bueno!
 
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head2
+commit $head1
 EOF
 
 test_expect_success '%x00 shows NUL' '
-	echo  >expect commit 1ed88da4a5b5ed8c449114ac131efc62178734c3 &&
+	echo  >expect commit $head3 &&
 	echo >>expect fooQbar &&
 	git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
 	nul_to_q <actual.nul >actual &&
-- 
1.8.3.1.16.gce2c52e

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

* [PATCH v8 2/5] t7102 (reset): don't hardcode SHA-1 in expected outputs
  2013-06-26 10:19                           ` [PATCH v7 " Alexey Shumkin
                                               ` (2 preceding siblings ...)
  2013-07-01 23:19                             ` [PATCH v8 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
@ 2013-07-01 23:19                             ` Alexey Shumkin
  2013-07-01 23:19                             ` [PATCH v8 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
                                               ` (2 subsequent siblings)
  6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-01 23:19 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Sixt, Alexey Shumkin, git

The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 t/t7102-reset.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index df82ec9..05dfb27 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -192,7 +192,8 @@ test_expect_success \
 	'changing files and redo the last commit should succeed' '
 	echo "3rd line 2nd file" >>secondfile &&
 	git commit -a -C ORIG_HEAD &&
-	check_changes 3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d &&
+	head4=$(git rev-parse --verify HEAD) &&
+	check_changes $head4 &&
 	test "$(git rev-parse ORIG_HEAD)" = \
 			$head5
 '
@@ -211,7 +212,7 @@ test_expect_success \
 	git reset --hard HEAD~2 &&
 	check_changes ddaefe00f1da16864591c61fdc7adb5d7cd6b74e &&
 	test "$(git rev-parse ORIG_HEAD)" = \
-			3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d
+			$head4
 '
 
 >.diff_expect
@@ -326,10 +327,11 @@ test_expect_success '--hard reset to HEAD should clear a failed merge' '
 	git checkout branch2 &&
 	echo "3rd line in branch2" >>secondfile &&
 	git commit -a -m "change in branch2" &&
+	head3=$(git rev-parse --verify HEAD) &&
 
 	test_must_fail git pull . branch1 &&
 	git reset --hard &&
-	check_changes 77abb337073fb4369a7ad69ff6f5ec0e4d6b54bb
+	check_changes $head3
 '
 
 >.diff_expect
-- 
1.8.3.1.16.gce2c52e

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

* [PATCH v8 3/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
  2013-06-26 10:19                           ` [PATCH v7 " Alexey Shumkin
                                               ` (3 preceding siblings ...)
  2013-07-01 23:19                             ` [PATCH v8 2/5] t7102 (reset): " Alexey Shumkin
@ 2013-07-01 23:19                             ` Alexey Shumkin
  2013-07-01 23:19                             ` [PATCH v8 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
  2013-07-01 23:19                             ` [PATCH v8 5/5] pretty: " Alexey Shumkin
  6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-01 23:19 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Sixt, Alexey Shumkin, git

The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 t/t4205-log-pretty-formats.sh | 48 +++++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 22 deletions(-)

diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 26fbfde..73ba5e8 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -101,7 +101,11 @@ test_expect_failure 'NUL termination with --stat' '
 
 test_expect_success 'setup more commits' '
 	test_commit "message one" one one message-one &&
-	test_commit "message two" two two message-two
+	test_commit "message two" two two message-two &&
+	head1=$(git rev-parse --verify --short HEAD~0) &&
+	head2=$(git rev-parse --verify --short HEAD~1) &&
+	head3=$(git rev-parse --verify --short HEAD~2) &&
+	head4=$(git rev-parse --verify --short HEAD~3)
 '
 
 test_expect_success 'left alignment formatting' '
@@ -117,18 +121,18 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'left alignment formatting at the nth column' '
-	git log --pretty="format:%h %<|(40)%s" >actual &&
+test_expect_success 'left alignment formatting at the nth column' "
+	git log --pretty='format:%h %<|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
-fa33ab1 message two                    Z
-7cd6c63 message one                    Z
-1711bf9 add bar                        Z
-af20c06 initial                        Z
+$head1 message two                    Z
+$head2 message one                    Z
+$head3 add bar                        Z
+$head4 initial                        Z
 EOF
 	test_cmp expected actual
-'
+"
 
 test_expect_success 'left alignment formatting with no padding' '
 	git log --pretty="format:%<(1)%s" >actual &&
@@ -195,18 +199,18 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'right alignment formatting at the nth column' '
-	git log --pretty="format:%h %>|(40)%s" >actual &&
+test_expect_success 'right alignment formatting at the nth column' "
+	git log --pretty='format:%h %>|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
-fa33ab1                      message two
-7cd6c63                      message one
-1711bf9                          add bar
-af20c06                          initial
+$head1                      message two
+$head2                      message one
+$head3                          add bar
+$head4                          initial
 EOF
 	test_cmp expected actual
-'
+"
 
 test_expect_success 'right alignment formatting with no padding' '
 	git log --pretty="format:%>(1)%s" >actual &&
@@ -234,18 +238,18 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'center alignment formatting at the nth column' '
-	git log --pretty="format:%h %><|(40)%s" >actual &&
+test_expect_success 'center alignment formatting at the nth column' "
+	git log --pretty='format:%h %><|(40)%s' >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
 	qz_to_tab_space <<\EOF >expected &&
-fa33ab1           message two          Z
-7cd6c63           message one          Z
-1711bf9             add bar            Z
-af20c06             initial            Z
+$head1           message two          Z
+$head2           message one          Z
+$head3             add bar            Z
+$head4             initial            Z
 EOF
 	test_cmp expected actual
-'
+"
 
 test_expect_success 'center alignment formatting with no padding' '
 	git log --pretty="format:%><(1)%s" >actual &&
-- 
1.8.3.1.16.gce2c52e

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

* [PATCH v8 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
  2013-06-26 10:19                           ` [PATCH v7 " Alexey Shumkin
                                               ` (4 preceding siblings ...)
  2013-07-01 23:19                             ` [PATCH v8 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
@ 2013-07-01 23:19                             ` Alexey Shumkin
  2013-07-02  6:46                               ` Johannes Sixt
  2013-07-01 23:19                             ` [PATCH v8 5/5] pretty: " Alexey Shumkin
  6 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-01 23:19 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Sixt, Alexey Shumkin, git

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 21895 bytes --]

One can set an alias
	$ git config alias.lg "log --graph --pretty=format:'%Cred%h%Creset
	-%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset'
	--abbrev-commit --date=local"

to see the log as a pretty tree (like *gitk* but in a terminal).

However, log messages written in an encoding i18n.commitEncoding which differs
from terminal encoding are shown corrupted even when i18n.logOutputEncoding
and terminal encoding are the same (e.g. log messages committed on a Cygwin box
with Windows-1251 encoding seen on a Linux box with a UTF-8 encoding and vice versa).

To simplify an example we can say the following two commands are expected
to give the same output to a terminal:

	$ git log --oneline --no-color
	$ git log --pretty=format:'%h %s'

However, the former pays attention to i18n.logOutputEncoding
configuration, while the latter does not when it formats "%s".

The same corruption is true for
	$ git diff --submodule=log
and
	$ git rev-list --pretty=format:%s HEAD
and
	$ git reset --hard

This patch adds failing tests for the next patch that fixes them.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 t/t4041-diff-submodule-option.sh |  35 ++++++----
 t/t4205-log-pretty-formats.sh    | 146 ++++++++++++++++++++++++---------------
 t/t6006-rev-list-format.sh       |  74 +++++++++++++++-----
 t/t7102-reset.sh                 |  31 ++++++++-
 4 files changed, 198 insertions(+), 88 deletions(-)

diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 32d4a60..d300d0c 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 #
 # Copyright (c) 2009 Jens Lehmann, based on t7401 by Ping Yin
+# Copyright (c) 2013 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
 #
 
 test_description='Support for verbose submodule differences in git diff
@@ -10,6 +11,9 @@ This test tries to verify the sanity of the --submodule option of git diff.
 
 . ./test-lib.sh
 
+# String "added" in German (translated with Google Translate), encoded in UTF-8,
+# used in sample commit log messages in add_file() function below.
+added=$(printf "hinzugef\303\274gt")
 add_file () {
 	(
 		cd "$1" &&
@@ -19,7 +23,8 @@ add_file () {
 			echo "$name" >"$name" &&
 			git add "$name" &&
 			test_tick &&
-			git commit -m "Add $name" || exit
+			msg_added_iso88591=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t iso8859-1) &&
+			git -c 'i18n.commitEncoding=iso8859-1' commit -m "$msg_added_iso88591"
 		done >/dev/null &&
 		git rev-parse --short --verify HEAD
 	)
@@ -89,29 +94,29 @@ test_expect_success 'diff.submodule does not affect plumbing' '
 commit_file sm1 &&
 head2=$(add_file sm1 foo3)
 
-test_expect_success 'modified submodule(forward)' '
+test_expect_failure 'modified submodule(forward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
-	  > Add foo3
+	  > Add foo3 ($added foo3)
 	EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'modified submodule(forward)' '
+test_expect_failure 'modified submodule(forward)' '
 	git diff --submodule=log >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
-	  > Add foo3
+	  > Add foo3 ($added foo3)
 	EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'modified submodule(forward) --submodule' '
+test_expect_failure 'modified submodule(forward) --submodule' '
 	git diff --submodule >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
-	  > Add foo3
+	  > Add foo3 ($added foo3)
 	EOF
 	test_cmp expected actual
 '
@@ -138,25 +143,25 @@ head3=$(
 	git rev-parse --short --verify HEAD
 )
 
-test_expect_success 'modified submodule(backward)' '
+test_expect_failure 'modified submodule(backward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head2..$head3 (rewind):
-	  < Add foo3
-	  < Add foo2
+	  < Add foo3 ($added foo3)
+	  < Add foo2 ($added foo2)
 	EOF
 	test_cmp expected actual
 '
 
 head4=$(add_file sm1 foo4 foo5)
-test_expect_success 'modified submodule(backward and forward)' '
+test_expect_failure 'modified submodule(backward and forward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head2...$head4:
-	  > Add foo5
-	  > Add foo4
-	  < Add foo3
-	  < Add foo2
+	  > Add foo5 ($added foo5)
+	  > Add foo4 ($added foo4)
+	  < Add foo3 ($added foo3)
+	  < Add foo2 ($added foo2)
 	EOF
 	test_cmp expected actual
 '
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 73ba5e8..a23da67 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -1,20 +1,44 @@
 #!/bin/sh
 #
 # Copyright (c) 2010, Will Palmer
+# Copyright (c) 2013, Alexey Shumkin (+ non-UTF-8 commit encoding tests)
 #
 
 test_description='Test pretty formats'
 . ./test-lib.sh
 
+commit_msg() {
+	# String "initial. initial" partly in German
+   # (translated with Google Translate),
+	# encoded in UTF-8, used as a commit log message below.
+	msg=$(printf "initial. anf\303\244nglich")
+	if test -n "$1"
+	then
+		msg=$(echo $msg | iconv -f utf-8 -t $1)
+	fi
+	if test -n "$2" -a -n "$3"
+	then
+		# cut string, replace cut part with two dots
+		# $2 - chars count from the beginning of the string
+		# $3 - "trailing" chars
+		# LC_ALL is set to make `sed` interpret "." as a UTF-8 char not a byte
+		# as it does with C locale
+		msg=$(echo $msg | LC_ALL=en_US.UTF-8 sed -e "s/^\(.\{$2\}\)$3/\1../")
+	fi
+	echo $msg
+}
+
 test_expect_success 'set up basic repos' '
 	>foo &&
 	>bar &&
 	git add foo &&
 	test_tick &&
-	git commit -m initial &&
+	git config i18n.commitEncoding iso8859-1 &&
+	git commit -m "$(commit_msg iso8859-1)" &&
 	git add bar &&
 	test_tick &&
-	git commit -m "add bar"
+	git commit -m "add bar" &&
+	git config --unset i18n.commitEncoding
 '
 
 test_expect_success 'alias builtin format' '
@@ -38,6 +62,20 @@ test_expect_success 'alias user-defined format' '
 	test_cmp expected actual
 '
 
+test_expect_success 'alias user-defined tformat with %s (iso8859-1 encoding)' '
+	git config i18n.logOutputEncoding iso8859-1 &&
+	git log --oneline >expected-s &&
+	git log --pretty="tformat:%h %s" >actual-s &&
+	git config --unset i18n.logOutputEncoding &&
+	test_cmp expected-s actual-s
+'
+
+test_expect_failure 'alias user-defined tformat with %s (utf-8 encoding)' '
+	git log --oneline >expected-s &&
+	git log --pretty="tformat:%h %s" >actual-s &&
+	test_cmp expected-s actual-s
+'
+
 test_expect_success 'alias user-defined tformat' '
 	git log --pretty="tformat:%h" >expected &&
 	git config pretty.test-alias "tformat:%h" &&
@@ -71,22 +109,22 @@ test_expect_success 'alias loop' '
 	test_must_fail git log --pretty=test-foo
 '
 
-test_expect_success 'NUL separation' '
-	printf "add bar\0initial" >expected &&
+test_expect_failure 'NUL separation' '
+	printf "add bar\0$(commit_msg)" >expected &&
 	git log -z --pretty="format:%s" >actual &&
 	test_cmp expected actual
 '
 
-test_expect_success 'NUL termination' '
-	printf "add bar\0initial\0" >expected &&
+test_expect_failure 'NUL termination' '
+	printf "add bar\0$(commit_msg)\0" >expected &&
 	git log -z --pretty="tformat:%s" >actual &&
 	test_cmp expected actual
 '
 
-test_expect_success 'NUL separation with --stat' '
+test_expect_failure 'NUL separation with --stat' '
 	stat0_part=$(git diff --stat HEAD^ HEAD) &&
 	stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
-	printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n" >expected &&
+	printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected &&
 	git log -z --stat --pretty="format:%s" >actual &&
 	test_i18ncmp expected actual
 '
@@ -94,7 +132,7 @@ test_expect_success 'NUL separation with --stat' '
 test_expect_failure 'NUL termination with --stat' '
 	stat0_part=$(git diff --stat HEAD^ HEAD) &&
 	stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
-	printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n\0" >expected &&
+	printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n0" >expected &&
 	git log -z --stat --pretty="tformat:%s" >actual &&
 	test_i18ncmp expected actual
 '
@@ -108,172 +146,172 @@ test_expect_success 'setup more commits' '
 	head4=$(git rev-parse --verify --short HEAD~3)
 '
 
-test_expect_success 'left alignment formatting' '
+test_expect_failure 'left alignment formatting' '
 	git log --pretty="format:%<(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 message two                            Z
 message one                            Z
 add bar                                Z
-initial                                Z
+$(commit_msg)                    Z
 EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'left alignment formatting at the nth column' "
-	git log --pretty='format:%h %<|(40)%s' >actual &&
+test_expect_failure 'left alignment formatting at the nth column' '
+	git log --pretty="format:%h %<|(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 $head1 message two                    Z
 $head2 message one                    Z
 $head3 add bar                        Z
-$head4 initial                        Z
+$head4 $(commit_msg)            Z
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'left alignment formatting with no padding' '
+test_expect_failure 'left alignment formatting with no padding' '
 	git log --pretty="format:%<(1)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	cat <<\EOF >expected &&
+	cat <<EOF >expected &&
 message two
 message one
 add bar
-initial
+$(commit_msg)
 EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'left alignment formatting with trunc' '
+test_expect_failure 'left alignment formatting with trunc' '
 	git log --pretty="format:%<(10,trunc)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 message ..
 message ..
 add bar  Z
-initial  Z
+$(commit_msg "" "8" ".\+$")
 EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'left alignment formatting with ltrunc' '
+test_expect_failure 'left alignment formatting with ltrunc' '
 	git log --pretty="format:%<(10,ltrunc)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 ..sage two
 ..sage one
 add bar  Z
-initial  Z
+$(commit_msg "" "0" ".\{11\}")
 EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'left alignment formatting with mtrunc' '
+test_expect_failure 'left alignment formatting with mtrunc' '
 	git log --pretty="format:%<(10,mtrunc)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 mess.. two
 mess.. one
 add bar  Z
-initial  Z
+$(commit_msg "" "4" ".\{11\}")
 EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'right alignment formatting' '
+test_expect_failure 'right alignment formatting' '
 	git log --pretty="format:%>(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 Z                            message two
 Z                            message one
 Z                                add bar
-Z                                initial
+Z                    $(commit_msg)
 EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'right alignment formatting at the nth column' "
-	git log --pretty='format:%h %>|(40)%s' >actual &&
+test_expect_failure 'right alignment formatting at the nth column' '
+	git log --pretty="format:%h %>|(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 $head1                      message two
 $head2                      message one
 $head3                          add bar
-$head4                          initial
+$head4              $(commit_msg)
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'right alignment formatting with no padding' '
+test_expect_failure 'right alignment formatting with no padding' '
 	git log --pretty="format:%>(1)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	cat <<\EOF >expected &&
+	cat <<EOF >expected &&
 message two
 message one
 add bar
-initial
+$(commit_msg)
 EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'center alignment formatting' '
+test_expect_failure 'center alignment formatting' '
 	git log --pretty="format:%><(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 Z             message two              Z
 Z             message one              Z
 Z               add bar                Z
-Z               initial                Z
+Z         $(commit_msg)          Z
 EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'center alignment formatting at the nth column' "
-	git log --pretty='format:%h %><|(40)%s' >actual &&
+test_expect_failure 'center alignment formatting at the nth column' '
+	git log --pretty="format:%h %><|(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 $head1           message two          Z
 $head2           message one          Z
 $head3             add bar            Z
-$head4             initial            Z
+$head4       $(commit_msg)      Z
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'center alignment formatting with no padding' '
+test_expect_failure 'center alignment formatting with no padding' '
 	git log --pretty="format:%><(1)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	cat <<\EOF >expected &&
+	cat <<EOF >expected &&
 message two
 message one
 add bar
-initial
+$(commit_msg)
 EOF
 	test_cmp expected actual
 '
 
-test_expect_success 'left/right alignment formatting with stealing' '
+test_expect_failure 'left/right alignment formatting with stealing' '
 	git commit --amend -m short --author "long long long <long@me.com>" &&
 	git log --pretty="format:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	cat <<\EOF >expected &&
+	cat <<EOF >expected &&
 short long  long long
 message ..   A U Thor
 add bar      A U Thor
-initial      A U Thor
+$(commit_msg "" "8" ".\+$")   A U Thor
 EOF
 	test_cmp expected actual
 '
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index cc1008d..e4b50ed 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -1,31 +1,44 @@
 #!/bin/sh
 
+# Copyright (c) 2009 Jens Lehmann
+# Copyright (c) 2013 Alexey Shumkin (+ non-UTF-8 commit encoding tests)
+
 test_description='git rev-list --pretty=format test'
 
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-terminal.sh
 
 test_tick
+# String "added" in German (translated with Google Translate), encoded in UTF-8,
+# used as a commit log message below.
+added=$(printf "added (hinzugef\303\274gt) foo")
+added_iso88591=$(echo "$added" | iconv -f utf-8 -t iso8859-1)
+# same but "changed"
+changed=$(printf "changed (ge\303\244ndert) foo")
+changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t iso8859-1)
+
 test_expect_success 'setup' '
 	: >foo &&
 	git add foo &&
-	git commit -m "added foo" &&
+	git config i18n.commitEncoding iso8859-1 &&
+	git commit -m "$added_iso88591" &&
 	head1=$(git rev-parse --verify HEAD) &&
 	head1_short=$(git rev-parse --verify --short $head1) &&
 	tree1=$(git rev-parse --verify HEAD:) &&
 	tree1_short=$(git rev-parse --verify --short $tree1) &&
-	echo changed >foo &&
-	git commit -a -m "changed foo" &&
+	echo "$changed" > foo &&
+	git commit -a -m "$changed_iso88591" &&
 	head2=$(git rev-parse --verify HEAD) &&
 	head2_short=$(git rev-parse --verify --short $head2) &&
 	tree2=$(git rev-parse --verify HEAD:) &&
 	tree2_short=$(git rev-parse --verify --short $tree2)
+	git config --unset i18n.commitEncoding
 '
 
-# usage: test_format name format_string <expected_output
+# usage: test_format name format_string [failure] <expected_output
 test_format () {
 	cat >expect.$1
-	test_expect_success "format $1" "
+	test_expect_${3:-success} "format $1" "
 		git rev-list --pretty=format:'$2' master >output.$1 &&
 		test_cmp expect.$1 output.$1
 	"
@@ -110,14 +123,16 @@ EOF
 
 test_format encoding %e <<EOF
 commit $head2
+iso8859-1
 commit $head1
+iso8859-1
 EOF
 
-test_format subject %s <<EOF
+test_format subject %s failure <<EOF
 commit $head2
-changed foo
+$changed
 commit $head1
-added foo
+$added
 EOF
 
 test_format body %b <<EOF
@@ -125,12 +140,12 @@ commit $head2
 commit $head1
 EOF
 
-test_format raw-body %B <<EOF
+test_format raw-body %B failure <<EOF
 commit $head2
-changed foo
+$changed
 
 commit $head1
-added foo
+$added
 
 EOF
 
@@ -190,12 +205,12 @@ test_expect_success '%C(auto) respects --color=auto (stdout not tty)' '
 	)
 '
 
-cat >commit-msg <<'EOF'
+iconv -f utf-8 -t iso8859-1 > commit-msg <<EOF
 Test printing of complex bodies
 
 This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
-include an iso8859 character: ¡bueno!
+include an iso8859 character: ¡bueno!
 EOF
 
 test_expect_success 'setup complex body' '
@@ -209,16 +224,18 @@ test_format complex-encoding %e <<EOF
 commit $head3
 iso8859-1
 commit $head2
+iso8859-1
 commit $head1
+iso8859-1
 EOF
 
 test_format complex-subject %s <<EOF
 commit $head3
 Test printing of complex bodies
 commit $head2
-changed foo
+$changed_iso88591
 commit $head1
-added foo
+$added_iso88591
 EOF
 
 test_format complex-body %b <<EOF
@@ -231,6 +248,29 @@ commit $head2
 commit $head1
 EOF
 
+# Git uses i18n.commitEncoding if no i18n.logOutputEncoding set
+# so unset i18n.commitEncoding to test encoding conversion
+git config --unset i18n.commitEncoding
+
+test_format complex-subject-commitencoding-unset %s failure <<EOF
+commit $head3
+Test printing of complex bodies
+commit $head2
+$changed
+commit $head1
+$added
+EOF
+
+test_format complex-body-commitencoding-unset %b failure <<EOF
+commit $head3
+This commit message is much longer than the others,
+and it will be encoded in iso8859-1. We should therefore
+include an iso8859 character: ¡bueno!
+
+commit $head2
+commit $head1
+EOF
+
 test_expect_success '%x00 shows NUL' '
 	echo  >expect commit $head3 &&
 	echo >>expect fooQbar &&
@@ -279,12 +319,12 @@ test_expect_success 'add LF before non-empty (2)' '
 
 test_expect_success 'add SP before non-empty (1)' '
 	git show -s --pretty=format:"%s% bThanks" HEAD^^ >actual &&
-	test $(wc -w <actual) = 2
+	test $(wc -w <actual) = 3
 '
 
 test_expect_success 'add SP before non-empty (2)' '
 	git show -s --pretty=format:"%s% sThanks" HEAD^^ >actual &&
-	test $(wc -w <actual) = 4
+	test $(wc -w <actual) = 6
 '
 
 test_expect_success '--abbrev' '
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 05dfb27..6a92703 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -9,6 +9,19 @@ Documented tests for git reset'
 
 . ./test-lib.sh
 
+commit_msg() {
+	# String "modify 2nd file (changed)" partly in German
+	# (translated with Google Translate),
+	# encoded in UTF-8, used as a commit log message below.
+	printf "modify 2nd file (ge\303\244ndert)" |
+	if test -n "$1"
+	then
+		iconv -f utf-8 -t $1
+	else
+		cat
+	fi
+}
+
 test_expect_success 'creating initial files and commits' '
 	test_tick &&
 	echo "1st file" >first &&
@@ -28,7 +41,7 @@ test_expect_success 'creating initial files and commits' '
 
 	echo "1st line 2nd file" >secondfile &&
 	echo "2nd line 2nd file" >>secondfile &&
-	git commit -a -m "modify 2nd file" &&
+	git -c "i18n.commitEncoding=iso8859-1" commit -a -m "$(commit_msg iso8859-1)" &&
 	head5=$(git rev-parse --verify HEAD)
 '
 # git log --pretty=oneline # to see those SHA1 involved
@@ -44,6 +57,20 @@ check_changes () {
 	done | test_cmp .cat_expect -
 }
 
+test_expect_failure 'reset --hard message' '
+	hex=$(git log -1 --format="%h") &&
+	git reset --hard > .actual &&
+	echo HEAD is now at $hex $(commit_msg) > .expected &&
+	test_cmp .expected .actual
+'
+
+test_expect_success 'reset --hard message (iso8859-1 logoutputencoding)' '
+	hex=$(git log -1 --format="%h") &&
+	git -c "i18n.logOutputEncoding=iso8859-1" reset --hard > .actual &&
+	echo HEAD is now at $hex $(commit_msg iso8859-1) > .expected &&
+	test_cmp .expected .actual
+'
+
 >.diff_expect
 >.cached_expect
 cat >.cat_expect <<EOF
@@ -304,7 +331,7 @@ test_expect_success 'redoing the last two commits should succeed' '
 
 	echo "1st line 2nd file" >secondfile &&
 	echo "2nd line 2nd file" >>secondfile &&
-	git commit -a -m "modify 2nd file" &&
+	git -c "i18n.commitEncoding=iso8859-1" commit -a -m "$(commit_msg iso8859-1)" &&
 	check_changes $head5
 '
 
-- 
1.8.3.1.16.gce2c52e

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

* [PATCH v8 5/5] pretty: --format output should honor logOutputEncoding
  2013-06-26 10:19                           ` [PATCH v7 " Alexey Shumkin
                                               ` (5 preceding siblings ...)
  2013-07-01 23:19                             ` [PATCH v8 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
@ 2013-07-01 23:19                             ` Alexey Shumkin
  6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-01 23:19 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Sixt, Alexey Shumkin, git

One can set an alias
	$ git config [--global] alias.lg "log --graph --pretty=format:'%Cred%h%Creset
	-%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset'
	--abbrev-commit --date=local"

to see the log as a pretty tree (like *gitk* but in a terminal).

However, log messages written in an encoding i18n.commitEncoding which differs
from terminal encoding are shown corrupted even when i18n.logOutputEncoding
and terminal encoding are the same (e.g. log messages committed on a Cygwin box
with Windows-1251 encoding seen on a Linux box with a UTF-8 encoding and vice versa).

To simplify an example we can say the following two commands are expected
to give the same output to a terminal:

	$ git log --oneline --no-color
	$ git log --pretty=format:'%h %s'

However, the former pays attention to i18n.logOutputEncoding
configuration, while the latter does not when it formats "%s".

The same corruption is true for
	$ git diff --submodule=log
and
	$ git rev-list --pretty=format:%s HEAD
and
	$ git reset --hard

This patch makes pretty --format honor logOutputEncoding when it formats
log message.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 builtin/reset.c                  |  5 ++++-
 builtin/rev-list.c               |  1 +
 builtin/shortlog.c               |  1 +
 log-tree.c                       |  1 +
 submodule.c                      |  1 +
 t/t4041-diff-submodule-option.sh | 10 +++++-----
 t/t4205-log-pretty-formats.sh    | 34 +++++++++++++++++-----------------
 t/t6006-rev-list-format.sh       |  8 ++++----
 t/t7102-reset.sh                 |  2 +-
 9 files changed, 35 insertions(+), 28 deletions(-)

diff --git a/builtin/reset.c b/builtin/reset.c
index 6032131..afa6e02 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -93,10 +93,12 @@ static int reset_index(const unsigned char *sha1, int reset_type, int quiet)
 static void print_new_head_line(struct commit *commit)
 {
 	const char *hex, *body;
+	char *msg;
 
 	hex = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
 	printf(_("HEAD is now at %s"), hex);
-	body = strstr(commit->buffer, "\n\n");
+	msg = logmsg_reencode(commit, NULL, get_log_output_encoding());
+	body = strstr(msg, "\n\n");
 	if (body) {
 		const char *eol;
 		size_t len;
@@ -107,6 +109,7 @@ static void print_new_head_line(struct commit *commit)
 	}
 	else
 		printf("\n");
+	logmsg_free(msg, commit);
 }
 
 static void update_index_from_diff(struct diff_queue_struct *q,
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 67701be..a5ec30d 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -111,6 +111,7 @@ static void show_commit(struct commit *commit, void *data)
 		ctx.date_mode = revs->date_mode;
 		ctx.date_mode_explicit = revs->date_mode_explicit;
 		ctx.fmt = revs->commit_format;
+		ctx.output_encoding = get_log_output_encoding();
 		pretty_print_commit(&ctx, commit, &buf);
 		if (revs->graph) {
 			if (buf.len) {
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 1fd6f8a..1434f8f 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -137,6 +137,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
 		ctx.subject = "";
 		ctx.after_subject = "";
 		ctx.date_mode = DATE_NORMAL;
+		ctx.output_encoding = get_log_output_encoding();
 		pretty_print_commit(&ctx, commit, &ufbuf);
 		buffer = ufbuf.buf;
 	} else if (*buffer) {
diff --git a/log-tree.c b/log-tree.c
index 1946e9c..5277d3e 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -616,6 +616,7 @@ void show_log(struct rev_info *opt)
 	ctx.fmt = opt->commit_format;
 	ctx.mailmap = opt->mailmap;
 	ctx.color = opt->diffopt.use_color;
+	ctx.output_encoding = get_log_output_encoding();
 	pretty_print_commit(&ctx, commit, &msgbuf);
 
 	if (opt->add_signoff)
diff --git a/submodule.c b/submodule.c
index 1821a5b..78734e1 100644
--- a/submodule.c
+++ b/submodule.c
@@ -226,6 +226,7 @@ static void print_submodule_summary(struct rev_info *rev, FILE *f,
 	while ((commit = get_revision(rev))) {
 		struct pretty_print_context ctx = {0};
 		ctx.date_mode = rev->date_mode;
+		ctx.output_encoding = get_log_output_encoding();
 		strbuf_setlen(&sb, 0);
 		strbuf_addstr(&sb, line_prefix);
 		if (commit->object.flags & SYMMETRIC_LEFT) {
diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index d300d0c..04348ea 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -94,7 +94,7 @@ test_expect_success 'diff.submodule does not affect plumbing' '
 commit_file sm1 &&
 head2=$(add_file sm1 foo3)
 
-test_expect_failure 'modified submodule(forward)' '
+test_expect_success 'modified submodule(forward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
@@ -103,7 +103,7 @@ test_expect_failure 'modified submodule(forward)' '
 	test_cmp expected actual
 '
 
-test_expect_failure 'modified submodule(forward)' '
+test_expect_success 'modified submodule(forward)' '
 	git diff --submodule=log >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
@@ -112,7 +112,7 @@ test_expect_failure 'modified submodule(forward)' '
 	test_cmp expected actual
 '
 
-test_expect_failure 'modified submodule(forward) --submodule' '
+test_expect_success 'modified submodule(forward) --submodule' '
 	git diff --submodule >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head1..$head2:
@@ -143,7 +143,7 @@ head3=$(
 	git rev-parse --short --verify HEAD
 )
 
-test_expect_failure 'modified submodule(backward)' '
+test_expect_success 'modified submodule(backward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head2..$head3 (rewind):
@@ -154,7 +154,7 @@ test_expect_failure 'modified submodule(backward)' '
 '
 
 head4=$(add_file sm1 foo4 foo5)
-test_expect_failure 'modified submodule(backward and forward)' '
+test_expect_success 'modified submodule(backward and forward)' '
 	git diff-index -p --submodule=log HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 $head2...$head4:
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index a23da67..5e13000 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -70,7 +70,7 @@ test_expect_success 'alias user-defined tformat with %s (iso8859-1 encoding)' '
 	test_cmp expected-s actual-s
 '
 
-test_expect_failure 'alias user-defined tformat with %s (utf-8 encoding)' '
+test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' '
 	git log --oneline >expected-s &&
 	git log --pretty="tformat:%h %s" >actual-s &&
 	test_cmp expected-s actual-s
@@ -109,19 +109,19 @@ test_expect_success 'alias loop' '
 	test_must_fail git log --pretty=test-foo
 '
 
-test_expect_failure 'NUL separation' '
+test_expect_success 'NUL separation' '
 	printf "add bar\0$(commit_msg)" >expected &&
 	git log -z --pretty="format:%s" >actual &&
 	test_cmp expected actual
 '
 
-test_expect_failure 'NUL termination' '
+test_expect_success 'NUL termination' '
 	printf "add bar\0$(commit_msg)\0" >expected &&
 	git log -z --pretty="tformat:%s" >actual &&
 	test_cmp expected actual
 '
 
-test_expect_failure 'NUL separation with --stat' '
+test_expect_success 'NUL separation with --stat' '
 	stat0_part=$(git diff --stat HEAD^ HEAD) &&
 	stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
 	printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected &&
@@ -146,7 +146,7 @@ test_expect_success 'setup more commits' '
 	head4=$(git rev-parse --verify --short HEAD~3)
 '
 
-test_expect_failure 'left alignment formatting' '
+test_expect_success 'left alignment formatting' '
 	git log --pretty="format:%<(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -159,7 +159,7 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_failure 'left alignment formatting at the nth column' '
+test_expect_success 'left alignment formatting at the nth column' '
 	git log --pretty="format:%h %<|(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -172,7 +172,7 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_failure 'left alignment formatting with no padding' '
+test_expect_success 'left alignment formatting with no padding' '
 	git log --pretty="format:%<(1)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -185,7 +185,7 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_failure 'left alignment formatting with trunc' '
+test_expect_success 'left alignment formatting with trunc' '
 	git log --pretty="format:%<(10,trunc)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -198,7 +198,7 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_failure 'left alignment formatting with ltrunc' '
+test_expect_success 'left alignment formatting with ltrunc' '
 	git log --pretty="format:%<(10,ltrunc)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -211,7 +211,7 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_failure 'left alignment formatting with mtrunc' '
+test_expect_success 'left alignment formatting with mtrunc' '
 	git log --pretty="format:%<(10,mtrunc)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -224,7 +224,7 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_failure 'right alignment formatting' '
+test_expect_success 'right alignment formatting' '
 	git log --pretty="format:%>(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -237,7 +237,7 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_failure 'right alignment formatting at the nth column' '
+test_expect_success 'right alignment formatting at the nth column' '
 	git log --pretty="format:%h %>|(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -250,7 +250,7 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_failure 'right alignment formatting with no padding' '
+test_expect_success 'right alignment formatting with no padding' '
 	git log --pretty="format:%>(1)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -263,7 +263,7 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_failure 'center alignment formatting' '
+test_expect_success 'center alignment formatting' '
 	git log --pretty="format:%><(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -276,7 +276,7 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_failure 'center alignment formatting at the nth column' '
+test_expect_success 'center alignment formatting at the nth column' '
 	git log --pretty="format:%h %><|(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -289,7 +289,7 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_failure 'center alignment formatting with no padding' '
+test_expect_success 'center alignment formatting with no padding' '
 	git log --pretty="format:%><(1)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
@@ -302,7 +302,7 @@ EOF
 	test_cmp expected actual
 '
 
-test_expect_failure 'left/right alignment formatting with stealing' '
+test_expect_success 'left/right alignment formatting with stealing' '
 	git commit --amend -m short --author "long long long <long@me.com>" &&
 	git log --pretty="format:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
 	# complete the incomplete line at the end
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index e4b50ed..18d7909 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -128,7 +128,7 @@ commit $head1
 iso8859-1
 EOF
 
-test_format subject %s failure <<EOF
+test_format subject %s <<EOF
 commit $head2
 $changed
 commit $head1
@@ -140,7 +140,7 @@ commit $head2
 commit $head1
 EOF
 
-test_format raw-body %B failure <<EOF
+test_format raw-body %B <<EOF
 commit $head2
 $changed
 
@@ -252,7 +252,7 @@ EOF
 # so unset i18n.commitEncoding to test encoding conversion
 git config --unset i18n.commitEncoding
 
-test_format complex-subject-commitencoding-unset %s failure <<EOF
+test_format complex-subject-commitencoding-unset %s <<EOF
 commit $head3
 Test printing of complex bodies
 commit $head2
@@ -261,7 +261,7 @@ commit $head1
 $added
 EOF
 
-test_format complex-body-commitencoding-unset %b failure <<EOF
+test_format complex-body-commitencoding-unset %b <<EOF
 commit $head3
 This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 6a92703..73a1bdb 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -57,7 +57,7 @@ check_changes () {
 	done | test_cmp .cat_expect -
 }
 
-test_expect_failure 'reset --hard message' '
+test_expect_success 'reset --hard message' '
 	hex=$(git log -1 --format="%h") &&
 	git reset --hard > .actual &&
 	echo HEAD is now at $hex $(commit_msg) > .expected &&
-- 
1.8.3.1.16.gce2c52e

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

* Re: [PATCH v8 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
  2013-07-01 23:19                             ` [PATCH v8 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
@ 2013-07-02  6:46                               ` Johannes Sixt
  0 siblings, 0 replies; 104+ messages in thread
From: Johannes Sixt @ 2013-07-02  6:46 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: Junio C Hamano, git

Am 7/2/2013 1:19, schrieb Alexey Shumkin:
> +commit_msg() {
> +	# String "initial. initial" partly in German
> +   # (translated with Google Translate),
> +	# encoded in UTF-8, used as a commit log message below.
> +	msg=$(printf "initial. anf\303\244nglich")
> +	if test -n "$1"
> +	then
> +		msg=$(echo $msg | iconv -f utf-8 -t $1)
> +	fi
> +	if test -n "$2" -a -n "$3"
> +	then
> +		# cut string, replace cut part with two dots
> +		# $2 - chars count from the beginning of the string
> +		# $3 - "trailing" chars
> +		# LC_ALL is set to make `sed` interpret "." as a UTF-8 char not a byte
> +		# as it does with C locale
> +		msg=$(echo $msg | LC_ALL=en_US.UTF-8 sed -e "s/^\(.\{$2\}\)$3/\1../")
> +	fi
> +	echo $msg
> +}

Ignoring failure reports is not very helpful. Anyway, here is how I would
adjust this patch. (There are trivial conflicts when 5/5 is applied on
top.) Notice the comment I added in test case 'left alignment formatting
with ltrunc'.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>

To be squashed into v8 4/5:

diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index a23da67..ef3a226 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -7,25 +7,13 @@
 test_description='Test pretty formats'
 . ./test-lib.sh
 
-commit_msg() {
-	# String "initial. initial" partly in German
-   # (translated with Google Translate),
-	# encoded in UTF-8, used as a commit log message below.
-	msg=$(printf "initial. anf\303\244nglich")
-	if test -n "$1"
-	then
-		msg=$(echo $msg | iconv -f utf-8 -t $1)
-	fi
-	if test -n "$2" -a -n "$3"
-	then
-		# cut string, replace cut part with two dots
-		# $2 - chars count from the beginning of the string
-		# $3 - "trailing" chars
-		# LC_ALL is set to make `sed` interpret "." as a UTF-8 char not a byte
-		# as it does with C locale
-		msg=$(echo $msg | LC_ALL=en_US.UTF-8 sed -e "s/^\(.\{$2\}\)$3/\1../")
-	fi
-	echo $msg
+# String "initial. initial" partly in German encoded in UTF-8
+initial_msg=$(printf "initial. anf\303\244nglich")
+
+# extract part of the initial commit message
+# $1 - a RE with \( \) brackets that specify which part to keep
+extract_msg() {
+	echo "$initial_msg" | sed -e "s/$1/\1/"
 }
 
 test_expect_success 'set up basic repos' '
@@ -33,12 +21,11 @@ test_expect_success 'set up basic repos' '
 	>bar &&
 	git add foo &&
 	test_tick &&
-	git config i18n.commitEncoding iso8859-1 &&
-	git commit -m "$(commit_msg iso8859-1)" &&
+	test_config i18n.commitEncoding iso8859-1 &&
+	git commit -m "$(echo "$initial_msg" | iconv -f utf-8 -t iso8859-1)" &&
 	git add bar &&
 	test_tick &&
-	git commit -m "add bar" &&
-	git config --unset i18n.commitEncoding
+	git commit -m "add bar"
 '
 
 test_expect_success 'alias builtin format' '
@@ -63,10 +50,9 @@ test_expect_success 'alias user-defined format' '
 '
 
 test_expect_success 'alias user-defined tformat with %s (iso8859-1 encoding)' '
-	git config i18n.logOutputEncoding iso8859-1 &&
+	test_config i18n.logOutputEncoding iso8859-1 &&
 	git log --oneline >expected-s &&
 	git log --pretty="tformat:%h %s" >actual-s &&
-	git config --unset i18n.logOutputEncoding &&
 	test_cmp expected-s actual-s
 '
 
@@ -110,13 +96,13 @@ test_expect_success 'alias loop' '
 '
 
 test_expect_failure 'NUL separation' '
-	printf "add bar\0$(commit_msg)" >expected &&
+	printf "add bar\0$initial_msg" >expected &&
 	git log -z --pretty="format:%s" >actual &&
 	test_cmp expected actual
 '
 
 test_expect_failure 'NUL termination' '
-	printf "add bar\0$(commit_msg)\0" >expected &&
+	printf "add bar\0$initial_msg\0" >expected &&
 	git log -z --pretty="tformat:%s" >actual &&
 	test_cmp expected actual
 '
@@ -124,7 +110,7 @@ test_expect_failure 'NUL termination' '
 test_expect_failure 'NUL separation with --stat' '
 	stat0_part=$(git diff --stat HEAD^ HEAD) &&
 	stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
-	printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected &&
+	printf "add bar\n$stat0_part\n\0$initial_msg\n$stat1_part\n" >expected &&
 	git log -z --stat --pretty="format:%s" >actual &&
 	test_i18ncmp expected actual
 '
@@ -132,7 +118,7 @@ test_expect_failure 'NUL separation with --stat' '
 test_expect_failure 'NUL termination with --stat' '
 	stat0_part=$(git diff --stat HEAD^ HEAD) &&
 	stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
-	printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n0" >expected &&
+	printf "add bar\n$stat0_part\n\0$initial_msg\n$stat1_part\n0" >expected &&
 	git log -z --stat --pretty="tformat:%s" >actual &&
 	test_i18ncmp expected actual
 '
@@ -154,7 +140,7 @@ test_expect_failure 'left alignment formatting' '
 message two                            Z
 message one                            Z
 add bar                                Z
-$(commit_msg)                    Z
+$initial_msg                    Z
 EOF
 	test_cmp expected actual
 '
@@ -167,7 +153,7 @@ test_expect_failure 'left alignment formatting at the nth column' '
 $head1 message two                    Z
 $head2 message one                    Z
 $head3 add bar                        Z
-$head4 $(commit_msg)            Z
+$head4 $initial_msg            Z
 EOF
 	test_cmp expected actual
 '
@@ -180,7 +166,7 @@ test_expect_failure 'left alignment formatting with no padding' '
 message two
 message one
 add bar
-$(commit_msg)
+$initial_msg
 EOF
 	test_cmp expected actual
 '
@@ -193,7 +179,7 @@ test_expect_failure 'left alignment formatting with trunc' '
 message ..
 message ..
 add bar  Z
-$(commit_msg "" "8" ".\+$")
+$(extract_msg "^\(........\).*")..
 EOF
 	test_cmp expected actual
 '
@@ -206,8 +192,10 @@ test_expect_failure 'left alignment formatting with ltrunc' '
 ..sage two
 ..sage one
 add bar  Z
-$(commit_msg "" "0" ".\{11\}")
+..$(extract_msg ".*\(.........\)$")
 EOF
+	# the RE above covers 9 bytes because there is one UTF-8 character
+	# where two bytes occupy only one character position
 	test_cmp expected actual
 '
 
@@ -219,7 +207,7 @@ test_expect_failure 'left alignment formatting with mtrunc' '
 mess.. two
 mess.. one
 add bar  Z
-$(commit_msg "" "4" ".\{11\}")
+$(extract_msg "^\(....\).*")..$(extract_msg ".*\(....\)$")
 EOF
 	test_cmp expected actual
 '
@@ -232,7 +220,7 @@ test_expect_failure 'right alignment formatting' '
 Z                            message two
 Z                            message one
 Z                                add bar
-Z                    $(commit_msg)
+Z                    $initial_msg
 EOF
 	test_cmp expected actual
 '
@@ -245,7 +233,7 @@ test_expect_failure 'right alignment formatting at the nth column' '
 $head1                      message two
 $head2                      message one
 $head3                          add bar
-$head4              $(commit_msg)
+$head4              $initial_msg
 EOF
 	test_cmp expected actual
 '
@@ -258,7 +246,7 @@ test_expect_failure 'right alignment formatting with no padding' '
 message two
 message one
 add bar
-$(commit_msg)
+$initial_msg
 EOF
 	test_cmp expected actual
 '
@@ -271,7 +259,7 @@ test_expect_failure 'center alignment formatting' '
 Z             message two              Z
 Z             message one              Z
 Z               add bar                Z
-Z         $(commit_msg)          Z
+Z         $initial_msg          Z
 EOF
 	test_cmp expected actual
 '
@@ -284,7 +272,7 @@ test_expect_failure 'center alignment formatting at the nth column' '
 $head1           message two          Z
 $head2           message one          Z
 $head3             add bar            Z
-$head4       $(commit_msg)      Z
+$head4       $initial_msg      Z
 EOF
 	test_cmp expected actual
 '
@@ -297,7 +285,7 @@ test_expect_failure 'center alignment formatting with no padding' '
 message two
 message one
 add bar
-$(commit_msg)
+$initial_msg
 EOF
 	test_cmp expected actual
 '
@@ -311,7 +299,7 @@ test_expect_failure 'left/right alignment formatting with stealing' '
 short long  long long
 message ..   A U Thor
 add bar      A U Thor
-$(commit_msg "" "8" ".\+$")   A U Thor
+$(extract_msg "^\(........\).*")..   A U Thor
 EOF
 	test_cmp expected actual
 '

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

* Re: [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
  2013-07-01 22:50                               ` Alexey Shumkin
@ 2013-07-02  7:22                                 ` Johannes Sixt
  2013-07-03 20:20                                   ` Alexey Shumkin
  0 siblings, 1 reply; 104+ messages in thread
From: Johannes Sixt @ 2013-07-02  7:22 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git, Junio C Hamano

Am 7/2/2013 0:50, schrieb Alexey Shumkin:
> On Mon, Jul 01, 2013 at 09:00:55AM +0200, Johannes Sixt wrote:
>> Am 6/26/2013 12:19, schrieb Alexey Shumkin:
>>>  test_expect_success 'setup complex body' '
>>>  	git config i18n.commitencoding iso8859-1 &&
>>>  	echo change2 >foo && git commit -a -F commit-msg &&
>>>  	head3=$(git rev-parse --verify HEAD) &&
>>> -	head3_short=$(git rev-parse --short $head3)
>>> +	head3_short=$(git rev-parse --short $head3) &&
>>> +	# unset commit encoding config
>>> +	# otherwise %e does not print encoding value
>>> +	# and following test fails
>>
>> I don't understand this comment. The test vector below already shows that
>> an encoding is printed. Why would this suddenly be different with the
>> updated tests?
> I've changed tests. I've reverted back these ones, and added
> new ones with no i18n.commitEncoding set
>>
>> Assuming that this change doesn't sweep a deeper problem under the rug,
>> it's better to use test_config a few lines earlier.
>>
>>> +	git config --unset i18n.commitEncoding
>>> +
>>>  '
>>>  
>>>  test_format complex-encoding %e <<EOF
>>>  commit $head3
>>>  iso8859-1
>>
>> This is the encoding that I mean.
> These encodings "have appeared" because we've changed 'setup':
> we make commits with i18n.commitEncoding set

I understand why there are additional encoding entries in the expected
output, but we see one encoding entry already listed without this patch.
Why do you say "does not print encoding value" in the comment above?

>>
>>>  commit $head2
>>> +iso-8859-1
>>>  commit $head1
>>> +iso-8859-1
>>>  EOF

-- Hannes

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

* Re: [PATCH v8 0/5] Reroll patches against Git v1.8.3.2
  2013-07-01 23:18                             ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 Alexey Shumkin
@ 2013-07-02 19:41                               ` Junio C Hamano
  2013-07-03 20:03                                 ` Alexey Shumkin
  2013-07-04 12:45                               ` [PATCH v9 0/5] Incremental updates against 'next' branch Alexey Shumkin
                                                 ` (5 subsequent siblings)
  6 siblings, 1 reply; 104+ messages in thread
From: Junio C Hamano @ 2013-07-02 19:41 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: Johannes Sixt, git

Alexey Shumkin <Alex.Crezoff@gmail.com> writes:

> v8 of this patch series includes the following changes against v7:

Oops, isn't this already in 'next'?  In that case, please feed
incremental updates on top of the patches that are already queued as
improvements and fixes.

Thanks.

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

* Re: [PATCH v8 0/5] Reroll patches against Git v1.8.3.2
  2013-07-02 19:41                               ` Junio C Hamano
@ 2013-07-03 20:03                                 ` Alexey Shumkin
  2013-07-03 20:06                                   ` Junio C Hamano
  0 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-03 20:03 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Sixt, git

On Tue, Jul 02, 2013 at 12:41:03PM -0700, Junio C Hamano wrote:
> Alexey Shumkin <Alex.Crezoff@gmail.com> writes:
> 
> > v8 of this patch series includes the following changes against v7:
> 
> Oops, isn't this already in 'next'?  In that case, please feed
> incremental updates on top of the patches that are already queued as
> improvements and fixes.
Oops ;)
I'll send patches against 'next' then.
> 
> Thanks.

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

* Re: [PATCH v8 0/5] Reroll patches against Git v1.8.3.2
  2013-07-03 20:03                                 ` Alexey Shumkin
@ 2013-07-03 20:06                                   ` Junio C Hamano
  0 siblings, 0 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-07-03 20:06 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: Johannes Sixt, git

Alexey Shumkin <alex.crezoff@gmail.com> writes:

> On Tue, Jul 02, 2013 at 12:41:03PM -0700, Junio C Hamano wrote:
>> Alexey Shumkin <Alex.Crezoff@gmail.com> writes:
>> 
>> > v8 of this patch series includes the following changes against v7:
>> 
>> Oops, isn't this already in 'next'?  In that case, please feed
>> incremental updates on top of the patches that are already queued as
>> improvements and fixes.
> Oops ;)
> I'll send patches against 'next' then.

Thanks; please build on top of 7c375214 (t4205: replace .\+ with ..*
in sed commands, 2013-07-01).

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

* Re: [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding
  2013-07-02  7:22                                 ` Johannes Sixt
@ 2013-07-03 20:20                                   ` Alexey Shumkin
  0 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-03 20:20 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git, Junio C Hamano

On Tue, Jul 02, 2013 at 09:22:09AM +0200, Johannes Sixt wrote:
> Am 7/2/2013 0:50, schrieb Alexey Shumkin:
> > On Mon, Jul 01, 2013 at 09:00:55AM +0200, Johannes Sixt wrote:
> >> Am 6/26/2013 12:19, schrieb Alexey Shumkin:
> >>>  test_expect_success 'setup complex body' '
> >>>  	git config i18n.commitencoding iso8859-1 &&
> >>>  	echo change2 >foo && git commit -a -F commit-msg &&
> >>>  	head3=$(git rev-parse --verify HEAD) &&
> >>> -	head3_short=$(git rev-parse --short $head3)
> >>> +	head3_short=$(git rev-parse --short $head3) &&
> >>> +	# unset commit encoding config
> >>> +	# otherwise %e does not print encoding value
> >>> +	# and following test fails
> >>
> >> I don't understand this comment. The test vector below already shows that
> >> an encoding is printed. Why would this suddenly be different with the
> >> updated tests?
> > I've changed tests. I've reverted back these ones, and added
> > new ones with no i18n.commitEncoding set
> >>
> >> Assuming that this change doesn't sweep a deeper problem under the rug,
> >> it's better to use test_config a few lines earlier.
> >>
> >>> +	git config --unset i18n.commitEncoding
> >>> +
> >>>  '
> >>>  
> >>>  test_format complex-encoding %e <<EOF
> >>>  commit $head3
> >>>  iso8859-1
> >>
> >> This is the encoding that I mean.
> > These encodings "have appeared" because we've changed 'setup':
> > we make commits with i18n.commitEncoding set
> 
> I understand why there are additional encoding entries in the expected
> output, but we see one encoding entry already listed without this patch.
> Why do you say "does not print encoding value" in the comment above?
I don't even remember today. I guess (that comment initially was written
loooooong time time ago), that was a "legacy" comment.
Nevermind,
nowadays it's removed ;)
> 
> >>
> >>>  commit $head2
> >>> +iso-8859-1
> >>>  commit $head1
> >>> +iso-8859-1
> >>>  EOF
> 
> -- Hannes

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

* [PATCH v9 0/5] Incremental updates against 'next' branch
  2013-07-01 23:18                             ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 Alexey Shumkin
  2013-07-02 19:41                               ` Junio C Hamano
@ 2013-07-04 12:45                               ` Alexey Shumkin
  2013-07-05 12:01                                 ` [PATCH v10 " Alexey Shumkin
                                                   ` (5 more replies)
  2013-07-04 12:45                               ` [PATCH v9 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1 Alexey Shumkin
                                                 ` (4 subsequent siblings)
  6 siblings, 6 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-04 12:45 UTC (permalink / raw)
  To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano

This patch series is an incremental updates on top of (7c375214 t4205:
replace .\+ with ..* in sed commands, 2013-07-01) as far as v7 patches
were applied to the 'next' branch but there were more improvements made
in v8.

Alexey Shumkin (5):
  t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1
  t4205: revert back single quotes
  t4205, t6006, t7102: make functions more readable
  t6006: add two more tests for the case i18n.commitEncoding is not set
  t4205: avoid using `sed`

 t/t4041-diff-submodule-option.sh |   4 +-
 t/t4205-log-pretty-formats.sh    | 145 +++++++++++++++++++--------------------
 t/t6006-rev-list-format.sh       |  69 ++++++++++---------
 t/t7102-reset.sh                 |  22 +++---
 4 files changed, 121 insertions(+), 119 deletions(-)

-- 
1.8.3.1.15.g5c23c1e

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

* [PATCH v9 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1
  2013-07-01 23:18                             ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 Alexey Shumkin
  2013-07-02 19:41                               ` Junio C Hamano
  2013-07-04 12:45                               ` [PATCH v9 0/5] Incremental updates against 'next' branch Alexey Shumkin
@ 2013-07-04 12:45                               ` Alexey Shumkin
  2013-07-05  6:47                                 ` Junio C Hamano
  2013-07-04 12:45                               ` [PATCH v9 2/5] t4205: revert back single quotes Alexey Shumkin
                                                 ` (3 subsequent siblings)
  6 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-04 12:45 UTC (permalink / raw)
  To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano

This is actually a fixup of de6029a2d7734a93a9e27b9c4471862a47dd8123,
which was applied before final patch series was sent.

Also, see 3994e8a98dc7bbf67e61d23c8125f44383499a1f for the explanation
of such a replacement.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Reviewed-by: Johannes Sixt <j.sixt@viscovery.net>
---
 t/t4041-diff-submodule-option.sh |  4 ++--
 t/t4205-log-pretty-formats.sh    |  8 ++++----
 t/t6006-rev-list-format.sh       | 14 +++++++-------
 t/t7102-reset.sh                 | 10 +++++-----
 4 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 0a4f496..1751c83 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -23,8 +23,8 @@ add_file () {
 			echo "$name" >"$name" &&
 			git add "$name" &&
 			test_tick &&
-			msg_added_iso88591=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t iso-8859-1) &&
-			git -c 'i18n.commitEncoding=iso-8859-1' commit -m "$msg_added_iso88591"
+			msg_added_iso88591=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t iso8859-1) &&
+			git -c 'i18n.commitEncoding=iso8859-1' commit -m "$msg_added_iso88591"
 		done >/dev/null &&
 		git rev-parse --short --verify HEAD
 	)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 3cfb744..c283842 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -32,8 +32,8 @@ test_expect_success 'set up basic repos' '
 	>bar &&
 	git add foo &&
 	test_tick &&
-	git config i18n.commitEncoding iso-8859-1 &&
-	git commit -m "$(commit_msg iso-8859-1)" &&
+	git config i18n.commitEncoding iso8859-1 &&
+	git commit -m "$(commit_msg iso8859-1)" &&
 	git add bar &&
 	test_tick &&
 	git commit -m "add bar" &&
@@ -61,8 +61,8 @@ test_expect_success 'alias user-defined format' '
 	test_cmp expected actual
 '
 
-test_expect_success 'alias user-defined tformat with %s (iso-8859-1 encoding)' '
-	git config i18n.logOutputEncoding iso-8859-1 &&
+test_expect_success 'alias user-defined tformat with %s (iso8859-1 encoding)' '
+	git config i18n.logOutputEncoding iso8859-1 &&
 	git log --oneline >expected-s &&
 	git log --pretty="tformat:%h %s" >actual-s &&
 	git config --unset i18n.logOutputEncoding &&
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 380c85b..4751d22 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -12,15 +12,15 @@ test_tick
 # String "added" in German (translated with Google Translate), encoded in UTF-8,
 # used as a commit log message below.
 added=$(printf "added (hinzugef\303\274gt) foo")
-added_iso88591=$(echo "$added" | iconv -f utf-8 -t iso-8859-1)
+added_iso88591=$(echo "$added" | iconv -f utf-8 -t iso8859-1)
 # same but "changed"
 changed=$(printf "changed (ge\303\244ndert) foo")
-changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t iso-8859-1)
+changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t iso8859-1)
 
 test_expect_success 'setup' '
 	: >foo &&
 	git add foo &&
-	git config i18n.commitEncoding iso-8859-1 &&
+	git config i18n.commitEncoding iso8859-1 &&
 	git commit -m "$added_iso88591" &&
 	head1=$(git rev-parse --verify HEAD) &&
 	head1_short=$(git rev-parse --verify --short $head1) &&
@@ -136,9 +136,9 @@ EOF
 
 test_format encoding %e <<EOF
 commit $head2
-iso-8859-1
+iso8859-1
 commit $head1
-iso-8859-1
+iso8859-1
 EOF
 
 test_format subject %s <<EOF
@@ -242,9 +242,9 @@ test_format complex-encoding %e <<EOF
 commit $head3
 iso8859-1
 commit $head2
-iso-8859-1
+iso8859-1
 commit $head1
-iso-8859-1
+iso8859-1
 EOF
 
 test_format complex-subject %s <<EOF
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 9132dd9..2ef96e9 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -39,7 +39,7 @@ test_expect_success 'creating initial files and commits' '
 
 	echo "1st line 2nd file" >secondfile &&
 	echo "2nd line 2nd file" >>secondfile &&
-	git -c "i18n.commitEncoding=iso-8859-1" commit -a -m "$(commit_msg iso-8859-1)" &&
+	git -c "i18n.commitEncoding=iso8859-1" commit -a -m "$(commit_msg iso8859-1)" &&
 	head5=$(git rev-parse --verify HEAD)
 '
 # git log --pretty=oneline # to see those SHA1 involved
@@ -62,10 +62,10 @@ test_expect_success 'reset --hard message' '
 	test_cmp .expected .actual
 '
 
-test_expect_success 'reset --hard message (iso-8859-1 logoutencoding)' '
+test_expect_success 'reset --hard message (iso8859-1 logoutputencoding)' '
 	hex=$(git log -1 --format="%h") &&
-	git -c "i18n.logOutputEncoding=iso-8859-1" reset --hard > .actual &&
-	echo HEAD is now at $hex $(commit_msg iso-8859-1) > .expected &&
+	git -c "i18n.logOutputEncoding=iso8859-1" reset --hard > .actual &&
+	echo HEAD is now at $hex $(commit_msg iso8859-1) > .expected &&
 	test_cmp .expected .actual
 '
 
@@ -329,7 +329,7 @@ test_expect_success 'redoing the last two commits should succeed' '
 
 	echo "1st line 2nd file" >secondfile &&
 	echo "2nd line 2nd file" >>secondfile &&
-	git -c "i18n.commitEncoding=iso-8859-1" commit -a -m "$(commit_msg iso-8859-1)" &&
+	git -c "i18n.commitEncoding=iso8859-1" commit -a -m "$(commit_msg iso8859-1)" &&
 	check_changes $head5
 '
 
-- 
1.8.3.1.15.g5c23c1e

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

* [PATCH v9 2/5] t4205: revert back single quotes
  2013-07-01 23:18                             ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 Alexey Shumkin
                                                 ` (2 preceding siblings ...)
  2013-07-04 12:45                               ` [PATCH v9 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1 Alexey Shumkin
@ 2013-07-04 12:45                               ` Alexey Shumkin
  2013-07-05  7:07                                 ` Junio C Hamano
  2013-07-04 12:45                               ` [PATCH v9 3/5] t4205, t6006, t7102: make functions more readable Alexey Shumkin
                                                 ` (2 subsequent siblings)
  6 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-04 12:45 UTC (permalink / raw)
  To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano

In previuos commit de6029a2d7734a93a9e27b9c4471862a47dd8123 single
quotes were replaced with double quotes to make "$(commit_msg)"
expression in heredoc to work. The same effect can be achieved by using
"EOF" as a heredoc delimiter instead of "\EOF".

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Suggested-by: Johannes Sixt <j.sixt@viscovery.net>
---
 t/t4205-log-pretty-formats.sh | 106 +++++++++++++++++++++---------------------
 1 file changed, 53 insertions(+), 53 deletions(-)

diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index c283842..ef9770a 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -145,174 +145,174 @@ test_expect_success 'setup more commits' '
 	head4=$(git rev-parse --verify --short HEAD~3)
 '
 
-test_expect_success 'left alignment formatting' "
-	git log --pretty='format:%<(40)%s' >actual &&
+test_expect_success 'left alignment formatting' '
+	git log --pretty="format:%<(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 message two                            Z
 message one                            Z
 add bar                                Z
 $(commit_msg)                    Z
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'left alignment formatting at the nth column' "
-	git log --pretty='format:%h %<|(40)%s' >actual &&
+test_expect_success 'left alignment formatting at the nth column' '
+	git log --pretty="format:%h %<|(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 $head1 message two                    Z
 $head2 message one                    Z
 $head3 add bar                        Z
 $head4 $(commit_msg)            Z
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'left alignment formatting with no padding' "
-	git log --pretty='format:%<(1)%s' >actual &&
+test_expect_success 'left alignment formatting with no padding' '
+	git log --pretty="format:%<(1)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	cat <<\EOF >expected &&
+	cat <<EOF >expected &&
 message two
 message one
 add bar
 $(commit_msg)
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'left alignment formatting with trunc' "
-	git log --pretty='format:%<(10,trunc)%s' >actual &&
+test_expect_success 'left alignment formatting with trunc' '
+	git log --pretty="format:%<(10,trunc)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 message ..
 message ..
 add bar  Z
 $(commit_msg "" "8" "..*$")
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'left alignment formatting with ltrunc' "
-	git log --pretty='format:%<(10,ltrunc)%s' >actual &&
+test_expect_success 'left alignment formatting with ltrunc' '
+	git log --pretty="format:%<(10,ltrunc)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 ..sage two
 ..sage one
 add bar  Z
 $(commit_msg "" "0" ".\{11\}")
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'left alignment formatting with mtrunc' "
-	git log --pretty='format:%<(10,mtrunc)%s' >actual &&
+test_expect_success 'left alignment formatting with mtrunc' '
+	git log --pretty="format:%<(10,mtrunc)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 mess.. two
 mess.. one
 add bar  Z
 $(commit_msg "" "4" ".\{11\}")
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'right alignment formatting' "
-	git log --pretty='format:%>(40)%s' >actual &&
+test_expect_success 'right alignment formatting' '
+	git log --pretty="format:%>(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 Z                            message two
 Z                            message one
 Z                                add bar
 Z                    $(commit_msg)
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'right alignment formatting at the nth column' "
-	git log --pretty='format:%h %>|(40)%s' >actual &&
+test_expect_success 'right alignment formatting at the nth column' '
+	git log --pretty="format:%h %>|(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 $head1                      message two
 $head2                      message one
 $head3                          add bar
 $head4              $(commit_msg)
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'right alignment formatting with no padding' "
-	git log --pretty='format:%>(1)%s' >actual &&
+test_expect_success 'right alignment formatting with no padding' '
+	git log --pretty="format:%>(1)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	cat <<\EOF >expected &&
+	cat <<EOF >expected &&
 message two
 message one
 add bar
 $(commit_msg)
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'center alignment formatting' "
-	git log --pretty='format:%><(40)%s' >actual &&
+test_expect_success 'center alignment formatting' '
+	git log --pretty="format:%><(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 Z             message two              Z
 Z             message one              Z
 Z               add bar                Z
 Z         $(commit_msg)          Z
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'center alignment formatting at the nth column' "
-	git log --pretty='format:%h %><|(40)%s' >actual &&
+test_expect_success 'center alignment formatting at the nth column' '
+	git log --pretty="format:%h %><|(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 $head1           message two          Z
 $head2           message one          Z
 $head3             add bar            Z
 $head4       $(commit_msg)      Z
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'center alignment formatting with no padding' "
-	git log --pretty='format:%><(1)%s' >actual &&
+test_expect_success 'center alignment formatting with no padding' '
+	git log --pretty="format:%><(1)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	cat <<\EOF >expected &&
+	cat <<EOF >expected &&
 message two
 message one
 add bar
 $(commit_msg)
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'left/right alignment formatting with stealing' "
-	git commit --amend -m short --author 'long long long <long@me.com>' &&
-	git log --pretty='format:%<(10,trunc)%s%>>(10,ltrunc)% an' >actual &&
+test_expect_success 'left/right alignment formatting with stealing' '
+	git commit --amend -m short --author "long long long <long@me.com>" &&
+	git log --pretty="format:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	cat <<\EOF >expected &&
+	cat <<EOF >expected &&
 short long  long long
 message ..   A U Thor
 add bar      A U Thor
 $(commit_msg "" "8" "..*$")   A U Thor
 EOF
 	test_cmp expected actual
-"
+'
 
 test_done
-- 
1.8.3.1.15.g5c23c1e

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

* [PATCH v9 3/5] t4205, t6006, t7102: make functions more readable
  2013-07-01 23:18                             ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 Alexey Shumkin
                                                 ` (3 preceding siblings ...)
  2013-07-04 12:45                               ` [PATCH v9 2/5] t4205: revert back single quotes Alexey Shumkin
@ 2013-07-04 12:45                               ` Alexey Shumkin
  2013-07-05  6:45                                 ` Junio C Hamano
  2013-07-04 12:45                               ` [PATCH v9 4/5] t6006: add two more tests for the case i18n.commitEncoding is not set Alexey Shumkin
  2013-07-04 12:45                               ` [PATCH v9 5/5] t4205: avoid using `sed` Alexey Shumkin
  6 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-04 12:45 UTC (permalink / raw)
  To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano

Function 'test_format' is become hard to read after its change in
de6029a2d7734a93a9e27b9c4471862a47dd8123. So, make it more elegant.
Also, change 'commit_msg' function to make it more pretty.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Improved-by: Johannes Sixt <j.sixt@viscovery.net>
---
 t/t4205-log-pretty-formats.sh |  5 +++--
 t/t6006-rev-list-format.sh    | 23 +++++------------------
 t/t7102-reset.sh              | 12 +++++++-----
 3 files changed, 15 insertions(+), 25 deletions(-)

diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index ef9770a..bb87f02 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -7,8 +7,9 @@
 test_description='Test pretty formats'
 . ./test-lib.sh
 
-commit_msg () {
-	# String "initial. initial" partly in German (translated with Google Translate),
+commit_msg() {
+	# String "initial. initial" partly in German
+	# (translated with Google Translate),
 	# encoded in UTF-8, used as a commit log message below.
 	msg=$(printf "initial. anf\303\244nglich")
 	if test -n "$1"
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 4751d22..e069263 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -35,26 +35,13 @@ test_expect_success 'setup' '
 	git config --unset i18n.commitEncoding
 '
 
-# usage: test_format [failure] name format_string <expected_output
+# usage: test_format name format_string [failure] <expected_output
 test_format () {
-	must_fail=0
-	# if parameters count is more than 2 then test must fail
-	if test $# -gt 2
-	then
-		must_fail=1
-		# remove first parameter which is flag for test failure
-		shift
-	fi
 	cat >expect.$1
-	name="format $1"
-	command="git rev-list --pretty=format:'$2' master >output.$1 &&
-		test_cmp expect.$1 output.$1"
-	if test $must_fail -eq 1
-	then
-		test_expect_failure "$name" "$command"
-	else
-		test_expect_success "$name" "$command"
-	fi
+	test_expect_${3:-success} "format $1" "
+		git rev-list --pretty=format:'$2' master >output.$1 &&
+		test_cmp expect.$1 output.$1
+	"
 }
 
 # Feed to --format to provide predictable colored sequences.
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 2ef96e9..73a1bdb 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -9,15 +9,17 @@ Documented tests for git reset'
 
 . ./test-lib.sh
 
-commit_msg () {
-	# String "modify 2nd file (changed)" partly in German(translated with Google Translate),
+commit_msg() {
+	# String "modify 2nd file (changed)" partly in German
+	# (translated with Google Translate),
 	# encoded in UTF-8, used as a commit log message below.
-	msg=$(printf "modify 2nd file (ge\303\244ndert)")
+	printf "modify 2nd file (ge\303\244ndert)" |
 	if test -n "$1"
 	then
-		msg=$(echo $msg | iconv -f utf-8 -t $1)
+		iconv -f utf-8 -t $1
+	else
+		cat
 	fi
-	echo $msg
 }
 
 test_expect_success 'creating initial files and commits' '
-- 
1.8.3.1.15.g5c23c1e

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

* [PATCH v9 4/5] t6006: add two more tests for the case i18n.commitEncoding is not set
  2013-07-01 23:18                             ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 Alexey Shumkin
                                                 ` (4 preceding siblings ...)
  2013-07-04 12:45                               ` [PATCH v9 3/5] t4205, t6006, t7102: make functions more readable Alexey Shumkin
@ 2013-07-04 12:45                               ` Alexey Shumkin
  2013-07-05  6:52                                 ` Junio C Hamano
  2013-07-05  7:04                                 ` Junio C Hamano
  2013-07-04 12:45                               ` [PATCH v9 5/5] t4205: avoid using `sed` Alexey Shumkin
  6 siblings, 2 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-04 12:45 UTC (permalink / raw)
  To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano

In de6029a2d7734a93a9e27b9c4471862a47dd8123 'complex-subject' test was
changed. Revert it back, and add two more tests to test encoding
conversions with no i18n.commitEncoding set.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Reviewed-by: Johannes Sixt <j.sixt@viscovery.net>
---
 t/t6006-rev-list-format.sh | 32 +++++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)

diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index e069263..843134f 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -217,12 +217,7 @@ test_expect_success 'setup complex body' '
 	git config i18n.commitencoding iso8859-1 &&
 	echo change2 >foo && git commit -a -F commit-msg &&
 	head3=$(git rev-parse --verify HEAD) &&
-	head3_short=$(git rev-parse --short $head3) &&
-	# unset commit encoding config
-	# otherwise %e does not print encoding value
-	# and following test fails
-	git config --unset i18n.commitEncoding
-
+	head3_short=$(git rev-parse --short $head3)
 '
 
 test_format complex-encoding %e <<EOF
@@ -238,12 +233,35 @@ test_format complex-subject %s <<EOF
 commit $head3
 Test printing of complex bodies
 commit $head2
+$changed_iso88591
+commit $head1
+$added_iso88591
+EOF
+
+test_format complex-body %b <<EOF
+commit $head3
+This commit message is much longer than the others,
+and it will be encoded in iso8859-1. We should therefore
+include an iso8859 character: ¡bueno!
+
+commit $head2
+commit $head1
+EOF
+
+# Git uses i18n.commitEncoding if no i18n.logOutputEncoding set
+# so unset i18n.commitEncoding to test encoding conversion
+git config --unset i18n.commitEncoding
+
+test_format complex-subject-commitencoding-unset %s <<EOF
+commit $head3
+Test printing of complex bodies
+commit $head2
 $changed
 commit $head1
 $added
 EOF
 
-test_format complex-body %b <<EOF
+test_format complex-body-commitencoding-unset %b <<EOF
 commit $head3
 This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
-- 
1.8.3.1.15.g5c23c1e

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

* [PATCH v9 5/5] t4205: avoid using `sed`
  2013-07-01 23:18                             ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 Alexey Shumkin
                                                 ` (5 preceding siblings ...)
  2013-07-04 12:45                               ` [PATCH v9 4/5] t6006: add two more tests for the case i18n.commitEncoding is not set Alexey Shumkin
@ 2013-07-04 12:45                               ` Alexey Shumkin
  6 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-04 12:45 UTC (permalink / raw)
  To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano

For testing truncated log messages 'commit_msg' function uses `sed` to
cut a message. On various platforms `sed` behaves differently and
results of its work depend on locales installed. So, avoid using `sed`.
Use predefined expected outputs instead of calculated ones.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t4205-log-pretty-formats.sh | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index bb87f02..8504b13 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -7,25 +7,19 @@
 test_description='Test pretty formats'
 . ./test-lib.sh
 
+sample_utf8_part=$(printf "f\303\244ng")
+
 commit_msg() {
 	# String "initial. initial" partly in German
 	# (translated with Google Translate),
 	# encoded in UTF-8, used as a commit log message below.
-	msg=$(printf "initial. anf\303\244nglich")
+	msg="initial. an${sample_utf8_part}lich"
 	if test -n "$1"
 	then
-		msg=$(echo $msg | iconv -f utf-8 -t $1)
-	fi
-	if test -n "$2" -a -n "$3"
-	then
-		# cut string, replace cut part with two dots
-		# $2 - chars count from the beginning of the string
-		# $3 - "trailing" chars
-		# LC_ALL is set to make `sed` interpret "." as a UTF-8 char not a byte
-		# as it does with C locale
-		msg=$(echo $msg | LC_ALL=en_US.UTF-8 sed -e "s/^\(.\{$2\}\)$3/\1../")
+		echo $msg | iconv -f utf-8 -t $1
+	else
+		echo $msg
 	fi
-	echo $msg
 }
 
 test_expect_success 'set up basic repos' '
@@ -193,7 +187,7 @@ test_expect_success 'left alignment formatting with trunc' '
 message ..
 message ..
 add bar  Z
-$(commit_msg "" "8" "..*$")
+initial...
 EOF
 	test_cmp expected actual
 '
@@ -206,7 +200,7 @@ test_expect_success 'left alignment formatting with ltrunc' '
 ..sage two
 ..sage one
 add bar  Z
-$(commit_msg "" "0" ".\{11\}")
+..${sample_utf8_part}lich
 EOF
 	test_cmp expected actual
 '
@@ -219,7 +213,7 @@ test_expect_success 'left alignment formatting with mtrunc' '
 mess.. two
 mess.. one
 add bar  Z
-$(commit_msg "" "4" ".\{11\}")
+init..lich
 EOF
 	test_cmp expected actual
 '
@@ -311,7 +305,7 @@ test_expect_success 'left/right alignment formatting with stealing' '
 short long  long long
 message ..   A U Thor
 add bar      A U Thor
-$(commit_msg "" "8" "..*$")   A U Thor
+initial...   A U Thor
 EOF
 	test_cmp expected actual
 '
-- 
1.8.3.1.15.g5c23c1e

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

* Re: [PATCH v9 3/5] t4205, t6006, t7102: make functions more readable
  2013-07-04 12:45                               ` [PATCH v9 3/5] t4205, t6006, t7102: make functions more readable Alexey Shumkin
@ 2013-07-05  6:45                                 ` Junio C Hamano
  2013-07-05  8:13                                   ` Alexey Shumkin
  0 siblings, 1 reply; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05  6:45 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt

Alexey Shumkin <alex.crezoff@gmail.com> writes:

> Function 'test_format' is become hard to read after its change in
> de6029a2d7734a93a9e27b9c4471862a47dd8123. So, make it more elegant.
> Also, change 'commit_msg' function to make it more pretty.

I do not know where you pick up these "more elegant" and "more
pretty" from, but please refrain from using _only_ such vague and
subjective phrases to describe the change in the log message.
Saying "make it <<better>> by doing X" (with various subjective
adjectives to say "better") is fine, but make sure you have "doing
X" part in the explanation.

Perhaps like this.

    Function 'test_format' has become harder to read after its
    change in de6029a2 (pretty: Add failing tests: --format output
    should honor logOutputEncoding, 2013-06-26).  Simplify it by
    moving its "should we expect it to fail?" parameter to the end.

I cannot read why you think the updated commit_msg is "more pretty"
in the message or in the patch.

> -commit_msg () {
> -	# String "initial. initial" partly in German (translated with Google Translate),
> +commit_msg() {

Style.  Have SP on both sides of () in a shell function definition.

> +	# String "initial. initial" partly in German
> +	# (translated with Google Translate),
>  	# encoded in UTF-8, used as a commit log message below.
>  	msg=$(printf "initial. anf\303\244nglich")
>  	if test -n "$1"

This is not "more pretty" but "better commented".

> diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
> index 2ef96e9..73a1bdb 100755
> --- a/t/t7102-reset.sh
> +++ b/t/t7102-reset.sh
> @@ -9,15 +9,17 @@ Documented tests for git reset'
>  
>  . ./test-lib.sh
>  
> -commit_msg () {
> -	# String "modify 2nd file (changed)" partly in German(translated with Google Translate),
> +commit_msg() {
> +	# String "modify 2nd file (changed)" partly in German
> +	# (translated with Google Translate),
>  	# encoded in UTF-8, used as a commit log message below.
> -	msg=$(printf "modify 2nd file (ge\303\244ndert)")
> +	printf "modify 2nd file (ge\303\244ndert)" |
>  	if test -n "$1"
>  	then
> -		msg=$(echo $msg | iconv -f utf-8 -t $1)
> +		iconv -f utf-8 -t $1
> +	else
> +		cat
>  	fi
> -	echo $msg

Is it "more pretty"?  The "we have to have cat only because we want
to pipe into a conditional" look somewhat ugly.

	msg="modify 2nd file (ge\303\244ndert)"
        if test -n "$1"
	then
		printf "$msg" | iconv -f utf-8 -t "$1"
	else
		printf "$msg"
	fi

>  }
>  
>  test_expect_success 'creating initial files and commits' '

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

* Re: [PATCH v9 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1
  2013-07-04 12:45                               ` [PATCH v9 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1 Alexey Shumkin
@ 2013-07-05  6:47                                 ` Junio C Hamano
  2013-07-05  8:00                                   ` Alexey Shumkin
  0 siblings, 1 reply; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05  6:47 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt

Alexey Shumkin <alex.crezoff@gmail.com> writes:

> This is actually a fixup of de6029a2d7734a93a9e27b9c4471862a47dd8123,
> which was applied before final patch series was sent.
>
> Also, see 3994e8a98dc7bbf67e61d23c8125f44383499a1f for the explanation
> of such a replacement.

These are not very useful in a log message.  People who read the
history 6 months down the road would want to see why we want to use
iso8859-1 not iso-8859-1 explained.

	Both "iso8859-1" and "iso-8859-1" are understood as latin-1
	by modern platforms, but the latter is not understood by
	older platforms;update tests to use the former.

        This is in line with 3994e8a9 (t4201: use ISO8859-1 rather
	than ISO-8859-1, 2009-12-03), which did the same.

> Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
> Reviewed-by: Johannes Sixt <j.sixt@viscovery.net>

I do not recall this exact patch reviewed by J6t, but perhaps I
missed a message on the list?

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

* Re: [PATCH v9 4/5] t6006: add two more tests for the case i18n.commitEncoding is not set
  2013-07-04 12:45                               ` [PATCH v9 4/5] t6006: add two more tests for the case i18n.commitEncoding is not set Alexey Shumkin
@ 2013-07-05  6:52                                 ` Junio C Hamano
  2013-07-05  7:04                                 ` Junio C Hamano
  1 sibling, 0 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05  6:52 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt

Alexey Shumkin <alex.crezoff@gmail.com> writes:

> In de6029a2d7734a93a9e27b9c4471862a47dd8123 'complex-subject' test was
> changed. Revert it back,...

... "because changing it was bad for such and such reasons"?

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

* Re: [PATCH v9 4/5] t6006: add two more tests for the case i18n.commitEncoding is not set
  2013-07-04 12:45                               ` [PATCH v9 4/5] t6006: add two more tests for the case i18n.commitEncoding is not set Alexey Shumkin
  2013-07-05  6:52                                 ` Junio C Hamano
@ 2013-07-05  7:04                                 ` Junio C Hamano
  2013-07-05  7:46                                   ` Alexey Shumkin
  1 sibling, 1 reply; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05  7:04 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt

Alexey Shumkin <alex.crezoff@gmail.com> writes:

> +test_format complex-body %b <<EOF
> +commit $head3
> +This commit message is much longer than the others,
> +and it will be encoded in iso8859-1. We should therefore
> +include an iso8859 character: ¡bueno!

This is not such a good idea, as the resulting file will be in mixed
encoding (it already has a line with non-ascii that is in UTF-8),
and many editors would not like such a file.

Perhaps we should update test_format so that we can feed a quoted
input, e.g.

    +include an iso8859-1 character: <A1>bueno!

or something?

> +commit $head2
> +commit $head1
> +EOF
> +
> +# Git uses i18n.commitEncoding if no i18n.logOutputEncoding set
> +# so unset i18n.commitEncoding to test encoding conversion
> +git config --unset i18n.commitEncoding
> +
> +test_format complex-subject-commitencoding-unset %s <<EOF
> +commit $head3
> +Test printing of complex bodies
> +commit $head2
>  $changed
>  commit $head1
>  $added
>  EOF
>  
> -test_format complex-body %b <<EOF
> +test_format complex-body-commitencoding-unset %b <<EOF
>  commit $head3
>  This commit message is much longer than the others,
>  and it will be encoded in iso8859-1. We should therefore

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

* Re: [PATCH v9 2/5] t4205: revert back single quotes
  2013-07-04 12:45                               ` [PATCH v9 2/5] t4205: revert back single quotes Alexey Shumkin
@ 2013-07-05  7:07                                 ` Junio C Hamano
  0 siblings, 0 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05  7:07 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt

Alexey Shumkin <alex.crezoff@gmail.com> writes:

> In previuos commit de6029a2d7734a93a9e27b9c4471862a47dd8123 single
> quotes were replaced with double quotes to make "$(commit_msg)"
> expression in heredoc to work. The same effect can be achieved by using
> "EOF" as a heredoc delimiter instead of "\EOF".

OK.

> -test_expect_success 'left alignment formatting' "
> -	git log --pretty='format:%<(40)%s' >actual &&
> +test_expect_success 'left alignment formatting' '
> +	git log --pretty="format:%<(40)%s" >actual &&
>  	# complete the incomplete line at the end
>  	echo >>actual &&
> -	qz_to_tab_space <<\EOF >expected &&
> +	qz_to_tab_space <<EOF >expected &&
>  message two                            Z
>  message one                            Z
>  add bar                                Z
>  $(commit_msg)                    Z
>  EOF
>  	test_cmp expected actual
> -"
> +'

A subtle difference is that a call to commit_msg is made when the
test is actually run, not when the test script is prepared to be
passed (as a parameter) to test_expect_success helper.  I think the
result of applying this patch, i.e. running $(commit_msg) inside the
test, is easier to read and understand.

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

* Re: [PATCH v9 4/5] t6006: add two more tests for the case i18n.commitEncoding is not set
  2013-07-05  7:04                                 ` Junio C Hamano
@ 2013-07-05  7:46                                   ` Alexey Shumkin
  2013-07-05  8:09                                     ` Junio C Hamano
  0 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-05  7:46 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, John Keeping, Johannes Sixt

On Fri, Jul 05, 2013 at 12:04:34AM -0700, Junio C Hamano wrote:
> Alexey Shumkin <alex.crezoff@gmail.com> writes:
> 
> > +test_format complex-body %b <<EOF
> > +commit $head3
> > +This commit message is much longer than the others,
> > +and it will be encoded in iso8859-1. We should therefore
> > +include an iso8859 character: ¡bueno!
> 
> This is not such a good idea, as the resulting file will be in mixed
> encoding (it already has a line with non-ascii that is in UTF-8),
> and many editors would not like such a file.
I agree, there was issues when I edited that file
> 
> Perhaps we should update test_format so that we can feed a quoted
> input, e.g.
> 
>     +include an iso8859-1 character: <A1>bueno!
> 
> or something?
We could use this file whole in UTF-8 but just make a conversion of
expected output as it's done a few lines above with a commit message
(stored to a file 'commit-msg' before the test 'setup complex body').
    +iconv -f utf-8 -t iso8859-1 > commit-msg <<EOF
    +Test printing of complex bodies
We can even use content of that file (as far as it's kept untouched
between that tests)

> 
> > +commit $head2
> > +commit $head1
> > +EOF
> > +
> > +# Git uses i18n.commitEncoding if no i18n.logOutputEncoding set
> > +# so unset i18n.commitEncoding to test encoding conversion
> > +git config --unset i18n.commitEncoding
> > +
> > +test_format complex-subject-commitencoding-unset %s <<EOF
> > +commit $head3
> > +Test printing of complex bodies
> > +commit $head2
> >  $changed
> >  commit $head1
> >  $added
> >  EOF
> >  
> > -test_format complex-body %b <<EOF
> > +test_format complex-body-commitencoding-unset %b <<EOF
> >  commit $head3
> >  This commit message is much longer than the others,
> >  and it will be encoded in iso8859-1. We should therefore

-- 
Alexey Shumkin

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

* Re: [PATCH v9 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1
  2013-07-05  6:47                                 ` Junio C Hamano
@ 2013-07-05  8:00                                   ` Alexey Shumkin
  2013-07-05  8:11                                     ` Junio C Hamano
  0 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-05  8:00 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, John Keeping, Johannes Sixt

On Thu, Jul 04, 2013 at 11:47:04PM -0700, Junio C Hamano wrote:
> Alexey Shumkin <alex.crezoff@gmail.com> writes:
> 
> > This is actually a fixup of de6029a2d7734a93a9e27b9c4471862a47dd8123,
> > which was applied before final patch series was sent.
> >
> > Also, see 3994e8a98dc7bbf67e61d23c8125f44383499a1f for the explanation
> > of such a replacement.
> 
> These are not very useful in a log message.  People who read the
> history 6 months down the road would want to see why we want to use
> iso8859-1 not iso-8859-1 explained.
> 
> 	Both "iso8859-1" and "iso-8859-1" are understood as latin-1
> 	by modern platforms, but the latter is not understood by
> 	older platforms;update tests to use the former.
> 
>         This is in line with 3994e8a9 (t4201: use ISO8859-1 rather
> 	than ISO-8859-1, 2009-12-03), which did the same.
Yep, it whould be better, I thought to do like this but I didn't )
> 
> > Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
> > Reviewed-by: Johannes Sixt <j.sixt@viscovery.net>
> 
> I do not recall this exact patch reviewed by J6t, but perhaps I
> missed a message on the list?
I've reread 'SubmittingPatches' doc, and I can say I used "Reviewed-by"
incorrectly. Sorry for this. It must be "Suggested-by" there, I guess.


-- 
Alexey Shumkin

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

* Re: [PATCH v9 4/5] t6006: add two more tests for the case i18n.commitEncoding is not set
  2013-07-05  7:46                                   ` Alexey Shumkin
@ 2013-07-05  8:09                                     ` Junio C Hamano
  0 siblings, 0 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05  8:09 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt

Alexey Shumkin <alex.crezoff@gmail.com> writes:

>> Perhaps we should update test_format so that we can feed a quoted
>> input, e.g.
>> 
>>     +include an iso8859-1 character: <A1>bueno!
>> 
>> or something?
> We could use this file whole in UTF-8 but just make a conversion of
> expected output as it's done a few lines above with a commit message
> (stored to a file 'commit-msg' before the test 'setup complex body').
>     +iconv -f utf-8 -t iso8859-1 > commit-msg <<EOF
>     +Test printing of complex bodies

That is way better than my <A1>bueno!.

Thanks.

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

* Re: [PATCH v9 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1
  2013-07-05  8:00                                   ` Alexey Shumkin
@ 2013-07-05  8:11                                     ` Junio C Hamano
  2013-07-05  8:42                                       ` Alexey Shumkin
  0 siblings, 1 reply; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05  8:11 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt

Alexey Shumkin <alex.crezoff@gmail.com> writes:

>> 	Both "iso8859-1" and "iso-8859-1" are understood as latin-1
>> 	by modern platforms, but the latter is not understood by
>> 	older platforms;update tests to use the former.
>> 
>>         This is in line with 3994e8a9 (t4201: use ISO8859-1 rather
>> 	than ISO-8859-1, 2009-12-03), which did the same.
> Yep, it whould be better, I thought to do like this but I didn't )
>> 
>> > Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
>> > Reviewed-by: Johannes Sixt <j.sixt@viscovery.net>
>> 
>> I do not recall this exact patch reviewed by J6t, but perhaps I
>> missed a message on the list?
> I've reread 'SubmittingPatches' doc, and I can say I used "Reviewed-by"
> incorrectly. Sorry for this. It must be "Suggested-by" there, I guess.

OK, then I'll queue this patch (but not 2-4/5 yet) with log message
amended.

Thanks.

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

* Re: [PATCH v9 3/5] t4205, t6006, t7102: make functions more readable
  2013-07-05  6:45                                 ` Junio C Hamano
@ 2013-07-05  8:13                                   ` Alexey Shumkin
  2013-07-05  8:44                                     ` Junio C Hamano
  0 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-05  8:13 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, John Keeping, Johannes Sixt

On Thu, Jul 04, 2013 at 11:45:57PM -0700, Junio C Hamano wrote:
> Alexey Shumkin <alex.crezoff@gmail.com> writes:
> 
> > Function 'test_format' is become hard to read after its change in
> > de6029a2d7734a93a9e27b9c4471862a47dd8123. So, make it more elegant.
> > Also, change 'commit_msg' function to make it more pretty.
> 
> I do not know where you pick up these "more elegant" and "more
> pretty" from, but please refrain from using _only_ such vague and
> subjective phrases to describe the change in the log message.
> Saying "make it <<better>> by doing X" (with various subjective
> adjectives to say "better") is fine, but make sure you have "doing
> X" part in the explanation.
> 
> Perhaps like this.
> 
>     Function 'test_format' has become harder to read after its
>     change in de6029a2 (pretty: Add failing tests: --format output
>     should honor logOutputEncoding, 2013-06-26).  Simplify it by
>     moving its "should we expect it to fail?" parameter to the end.
I'm not sure whether this "last parameter" is needed in that code as far as we
already removed expected to fail tests
> 
> I cannot read why you think the updated commit_msg is "more pretty"
> in the message or in the patch.
> 
> > -commit_msg () {
> > -	# String "initial. initial" partly in German (translated with Google Translate),
> > +commit_msg() {
> 
> Style.  Have SP on both sides of () in a shell function definition.
Could you point me to the coding style guide, please?
> 
> > +	# String "initial. initial" partly in German
> > +	# (translated with Google Translate),
> >  	# encoded in UTF-8, used as a commit log message below.
> >  	msg=$(printf "initial. anf\303\244nglich")
> >  	if test -n "$1"
> 
> This is not "more pretty" but "better commented".
Well, this is "better formatted comment", I guess :)
> 
> > diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
> > index 2ef96e9..73a1bdb 100755
> > --- a/t/t7102-reset.sh
> > +++ b/t/t7102-reset.sh
> > @@ -9,15 +9,17 @@ Documented tests for git reset'
> >  
> >  . ./test-lib.sh
> >  
> > -commit_msg () {
> > -	# String "modify 2nd file (changed)" partly in German(translated with Google Translate),
> > +commit_msg() {
> > +	# String "modify 2nd file (changed)" partly in German
> > +	# (translated with Google Translate),
> >  	# encoded in UTF-8, used as a commit log message below.
> > -	msg=$(printf "modify 2nd file (ge\303\244ndert)")
> > +	printf "modify 2nd file (ge\303\244ndert)" |
> >  	if test -n "$1"
> >  	then
> > -		msg=$(echo $msg | iconv -f utf-8 -t $1)
> > +		iconv -f utf-8 -t $1
> > +	else
> > +		cat
> >  	fi
> > -	echo $msg
> 
> Is it "more pretty"?  The "we have to have cat only because we want
> to pipe into a conditional" look somewhat ugly.
That was a proposition of J6t :-D
(see http://article.gmane.org/gmane.comp.version-control.git/229291):
    >If you wanted to, you could write this as
    >
    >commit_msg () {
    >    # String "modify 2nd file (changed)" partly in German
    >    #(translated with Google Translate),
    >    # encoded in UTF-8, used as a commit log message below.
    >    printf "modify 2nd file (ge\303\244ndert)" |
    >    if test -n "$1"
    >    then
    >        iconv -f utf-8 -t $1
    >    else
    >        cat
    >    fi
    >}
    >
    >but I'm not sure whether it's a lot better.

Last sentence has apperared to be a key

> 
> 	msg="modify 2nd file (ge\303\244ndert)"
>         if test -n "$1"
> 	then
> 		printf "$msg" | iconv -f utf-8 -t "$1"
> 	else
> 		printf "$msg"
> 	fi
> 
> >  }
> >  
> >  test_expect_success 'creating initial files and commits' '

-- 
Alexey Shumkin

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

* Re: [PATCH v9 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1
  2013-07-05  8:11                                     ` Junio C Hamano
@ 2013-07-05  8:42                                       ` Alexey Shumkin
  2013-07-05  8:56                                         ` Junio C Hamano
  0 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-05  8:42 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, John Keeping, Johannes Sixt

On Fri, Jul 05, 2013 at 01:11:49AM -0700, Junio C Hamano wrote:
> Alexey Shumkin <alex.crezoff@gmail.com> writes:
> 
> >> 	Both "iso8859-1" and "iso-8859-1" are understood as latin-1
> >> 	by modern platforms, but the latter is not understood by
> >> 	older platforms;update tests to use the former.
> >> 
> >>         This is in line with 3994e8a9 (t4201: use ISO8859-1 rather
> >> 	than ISO-8859-1, 2009-12-03), which did the same.
> > Yep, it whould be better, I thought to do like this but I didn't )
> >> 
> >> > Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
> >> > Reviewed-by: Johannes Sixt <j.sixt@viscovery.net>
> >> 
> >> I do not recall this exact patch reviewed by J6t, but perhaps I
> >> missed a message on the list?
> > I've reread 'SubmittingPatches' doc, and I can say I used "Reviewed-by"
> > incorrectly. Sorry for this. It must be "Suggested-by" there, I guess.
> 
> OK, then I'll queue this patch (but not 2-4/5 yet) with log message
> amended.
Excuse me, you've said "Ok" for 2/5 message, and then explained (as I
understood) then "subtle difference" between EOF and \EOF.
Should I change the message somehow?
> 
> Thanks.

-- 
Alexey Shumkin

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

* Re: [PATCH v9 3/5] t4205, t6006, t7102: make functions more readable
  2013-07-05  8:13                                   ` Alexey Shumkin
@ 2013-07-05  8:44                                     ` Junio C Hamano
  2013-07-05  8:51                                       ` Alexey Shumkin
  0 siblings, 1 reply; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05  8:44 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt

Alexey Shumkin <alex.crezoff@gmail.com> writes:

>> Perhaps like this.
>> 
>>     Function 'test_format' has become harder to read after its
>>     change in de6029a2 (pretty: Add failing tests: --format output
>>     should honor logOutputEncoding, 2013-06-26).  Simplify it by
>>     moving its "should we expect it to fail?" parameter to the end.
> I'm not sure whether this "last parameter" is needed in that code as far as we
> already removed expected to fail tests

Whatever.

The above is an example of justifying a more vague "simple" ("is
better" is implied) with a concrete point (i.e. By moving that to
the end, you removed the need to conditionally shift $@ in the
function to simplify the codepath), based on my _guess_ of what you
possibly meant to say, from reading your description that did not
give much clue for me to guess why you thought the result was "more
elegant".  If my guess missed what your true justification was,
please replace it with the more correct one ;-)

>> I cannot read why you think the updated commit_msg is "more pretty"
>> in the message or in the patch.
>> 
>> > -commit_msg () {
>> > -	# String "initial. initial" partly in German (translated with Google Translate),
>> > +commit_msg() {
>> 
>> Style.  Have SP on both sides of () in a shell function definition.
> Could you point me to the coding style guide, please?

Documentation/CodingGuidelines::

 - We prefer a space between the function name and the parentheses. The
   opening "{" should also be on the same line.
   E.g.: my_function () {

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

* Re: [PATCH v9 3/5] t4205, t6006, t7102: make functions more readable
  2013-07-05  8:44                                     ` Junio C Hamano
@ 2013-07-05  8:51                                       ` Alexey Shumkin
  2013-07-05  8:58                                         ` Junio C Hamano
  0 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-05  8:51 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, John Keeping, Johannes Sixt

On Fri, Jul 05, 2013 at 01:44:07AM -0700, Junio C Hamano wrote:
> Alexey Shumkin <alex.crezoff@gmail.com> writes:
> 
> >> Perhaps like this.
> >> 
> >>     Function 'test_format' has become harder to read after its
> >>     change in de6029a2 (pretty: Add failing tests: --format output
> >>     should honor logOutputEncoding, 2013-06-26).  Simplify it by
> >>     moving its "should we expect it to fail?" parameter to the end.
> > I'm not sure whether this "last parameter" is needed in that code as far as we
> > already removed expected to fail tests
> 
> Whatever.
> 
> The above is an example of justifying a more vague "simple" ("is
> better" is implied) with a concrete point (i.e. By moving that to
> the end, you removed the need to conditionally shift $@ in the
> function to simplify the codepath), based on my _guess_ of what you
> possibly meant to say, from reading your description that did not
> give much clue for me to guess why you thought the result was "more
> elegant".  If my guess missed what your true justification was,
> please replace it with the more correct one ;-)
Ok
> 
> >> I cannot read why you think the updated commit_msg is "more pretty"
> >> in the message or in the patch.
> >> 
> >> > -commit_msg () {
> >> > -	# String "initial. initial" partly in German (translated with Google Translate),
> >> > +commit_msg() {
> >> 
> >> Style.  Have SP on both sides of () in a shell function definition.
> > Could you point me to the coding style guide, please?
> 
> Documentation/CodingGuidelines::
Oh! :)
thank you
>  
>  - We prefer a space between the function name and the parentheses. The
>    opening "{" should also be on the same line.
>    E.g.: my_function () {
Aha

-- 
Alexey Shumkin

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

* Re: [PATCH v9 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1
  2013-07-05  8:42                                       ` Alexey Shumkin
@ 2013-07-05  8:56                                         ` Junio C Hamano
  0 siblings, 0 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05  8:56 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt

Alexey Shumkin <alex.crezoff@gmail.com> writes:

>> OK, then I'll queue this patch (but not 2-4/5 yet) with log message
>> amended.
> Excuse me, you've said "Ok" for 2/5 message, and then explained (as I
> understood) then "subtle difference" between EOF and \EOF.
> Should I change the message somehow?

I left it up to you.  If I queued without waiting, it wouldn't have
been up-to-you, so...

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

* Re: [PATCH v9 3/5] t4205, t6006, t7102: make functions more readable
  2013-07-05  8:51                                       ` Alexey Shumkin
@ 2013-07-05  8:58                                         ` Junio C Hamano
  0 siblings, 0 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05  8:58 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt

Alexey Shumkin <alex.crezoff@gmail.com> writes:

>> > Could you point me to the coding style guide, please?
>> 
>> Documentation/CodingGuidelines::
> Oh! :)
> thank you

The most important part of the coding guidelines is to match the
style to existing code when writing a new one:

    $ git grep '^[a-z_]* ()' -- *.sh | wc -l
    132
    $ git grep '^[a-z_]*()' -- *.sh | wc -l
    55

We have acquired quite a few violators, but that is no reason to add
more.

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

* [PATCH v10 0/5] Incremental updates against 'next' branch
  2013-07-04 12:45                               ` [PATCH v9 0/5] Incremental updates against 'next' branch Alexey Shumkin
@ 2013-07-05 12:01                                 ` Alexey Shumkin
  2013-07-05 12:01                                 ` [PATCH v10 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1 Alexey Shumkin
                                                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-05 12:01 UTC (permalink / raw)
  To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano

This patches series includes following changes against v9
1. [PATCH v10 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1
    reworded. reasons of renaming explained "here and now" but not only
    redirects to an older commit which did the same.
2. [PATCH v10 2/5] t4205 (log-pretty-formats): revert back single quotes
    little change to commit message (added "(log-pretty-formats)" after
    "t4205")
3. [PATCH v10 3/5] t4205, t6006, t7102: make functions better readable
    reworded. comments reformatted. function 'test_format' refactored.
4. [PATCH v10 4/5] t6006 (rev-list-format): add tests for "%b" and "%s" for the case i18n.commitEncoding is not set
    reworded. Now whole file is in utf-8. Tested output messages are
    converted from utf-8 to iso8859-1 "on the fly" and written fo files.
5. [PATCH v10 5/5] t4205 (log-pretty-formats): avoid using `sed`
    little change to commit message (added "(log-pretty-formats)" after
    "t4205")

And references to "de6029a2d7734a93a9e27b9c4471862a47dd8123" commit in
all patch messages replaced with "de6029a (pretty: Add failing
tests: --format output should honor logOutputEncoding, 2013-06-26)"

P.S. This patch series is an incremental updates on top of (7c375214 t4205:
replace .\+ with ..* in sed commands, 2013-07-01) as far as v7 patches
were applied to the 'next' branch but there were more improvements made
in v8.

Alexey Shumkin (5):
  t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1
  t4205 (log-pretty-formats): revert back single quotes
  t4205, t6006, t7102: make functions better readable
  t6006 (rev-list-format): add tests for "%b" and "%s" for the case
    i18n.commitEncoding is not set
  t4205 (log-pretty-formats): avoid using `sed`

 t/t4041-diff-submodule-option.sh |   4 +-
 t/t4205-log-pretty-formats.sh    | 143 +++++++++++++++++++--------------------
 t/t6006-rev-list-format.sh       |  83 ++++++++++++-----------
 t/t7102-reset.sh                 |  20 +++---
 4 files changed, 125 insertions(+), 125 deletions(-)

-- 
1.8.3.2.16.gb1f0d63

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

* [PATCH v10 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1
  2013-07-04 12:45                               ` [PATCH v9 0/5] Incremental updates against 'next' branch Alexey Shumkin
  2013-07-05 12:01                                 ` [PATCH v10 " Alexey Shumkin
@ 2013-07-05 12:01                                 ` Alexey Shumkin
  2013-07-05 12:01                                 ` [PATCH v10 2/5] t4205 (log-pretty-formats): revert back single quotes Alexey Shumkin
                                                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-05 12:01 UTC (permalink / raw)
  To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano

Both "iso8859-1" and "iso-8859-1" are understood as latin-1
by modern platforms, but the latter is not understood by
older platforms; update tests to use the former.

This is in line with 3994e8a9 (t4201: use ISO8859-1 rather
than ISO-8859-1, 2009-12-03), which did the same.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Suggested-by: Johannes Sixt <j.sixt@viscovery.net>
---
 t/t4041-diff-submodule-option.sh |  4 ++--
 t/t4205-log-pretty-formats.sh    |  8 ++++----
 t/t6006-rev-list-format.sh       | 14 +++++++-------
 t/t7102-reset.sh                 | 10 +++++-----
 4 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 0a4f496..1751c83 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -23,8 +23,8 @@ add_file () {
 			echo "$name" >"$name" &&
 			git add "$name" &&
 			test_tick &&
-			msg_added_iso88591=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t iso-8859-1) &&
-			git -c 'i18n.commitEncoding=iso-8859-1' commit -m "$msg_added_iso88591"
+			msg_added_iso88591=$(echo "Add $name ($added $name)" | iconv -f utf-8 -t iso8859-1) &&
+			git -c 'i18n.commitEncoding=iso8859-1' commit -m "$msg_added_iso88591"
 		done >/dev/null &&
 		git rev-parse --short --verify HEAD
 	)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 3cfb744..c283842 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -32,8 +32,8 @@ test_expect_success 'set up basic repos' '
 	>bar &&
 	git add foo &&
 	test_tick &&
-	git config i18n.commitEncoding iso-8859-1 &&
-	git commit -m "$(commit_msg iso-8859-1)" &&
+	git config i18n.commitEncoding iso8859-1 &&
+	git commit -m "$(commit_msg iso8859-1)" &&
 	git add bar &&
 	test_tick &&
 	git commit -m "add bar" &&
@@ -61,8 +61,8 @@ test_expect_success 'alias user-defined format' '
 	test_cmp expected actual
 '
 
-test_expect_success 'alias user-defined tformat with %s (iso-8859-1 encoding)' '
-	git config i18n.logOutputEncoding iso-8859-1 &&
+test_expect_success 'alias user-defined tformat with %s (iso8859-1 encoding)' '
+	git config i18n.logOutputEncoding iso8859-1 &&
 	git log --oneline >expected-s &&
 	git log --pretty="tformat:%h %s" >actual-s &&
 	git config --unset i18n.logOutputEncoding &&
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 380c85b..4751d22 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -12,15 +12,15 @@ test_tick
 # String "added" in German (translated with Google Translate), encoded in UTF-8,
 # used as a commit log message below.
 added=$(printf "added (hinzugef\303\274gt) foo")
-added_iso88591=$(echo "$added" | iconv -f utf-8 -t iso-8859-1)
+added_iso88591=$(echo "$added" | iconv -f utf-8 -t iso8859-1)
 # same but "changed"
 changed=$(printf "changed (ge\303\244ndert) foo")
-changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t iso-8859-1)
+changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t iso8859-1)
 
 test_expect_success 'setup' '
 	: >foo &&
 	git add foo &&
-	git config i18n.commitEncoding iso-8859-1 &&
+	git config i18n.commitEncoding iso8859-1 &&
 	git commit -m "$added_iso88591" &&
 	head1=$(git rev-parse --verify HEAD) &&
 	head1_short=$(git rev-parse --verify --short $head1) &&
@@ -136,9 +136,9 @@ EOF
 
 test_format encoding %e <<EOF
 commit $head2
-iso-8859-1
+iso8859-1
 commit $head1
-iso-8859-1
+iso8859-1
 EOF
 
 test_format subject %s <<EOF
@@ -242,9 +242,9 @@ test_format complex-encoding %e <<EOF
 commit $head3
 iso8859-1
 commit $head2
-iso-8859-1
+iso8859-1
 commit $head1
-iso-8859-1
+iso8859-1
 EOF
 
 test_format complex-subject %s <<EOF
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 9132dd9..2ef96e9 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -39,7 +39,7 @@ test_expect_success 'creating initial files and commits' '
 
 	echo "1st line 2nd file" >secondfile &&
 	echo "2nd line 2nd file" >>secondfile &&
-	git -c "i18n.commitEncoding=iso-8859-1" commit -a -m "$(commit_msg iso-8859-1)" &&
+	git -c "i18n.commitEncoding=iso8859-1" commit -a -m "$(commit_msg iso8859-1)" &&
 	head5=$(git rev-parse --verify HEAD)
 '
 # git log --pretty=oneline # to see those SHA1 involved
@@ -62,10 +62,10 @@ test_expect_success 'reset --hard message' '
 	test_cmp .expected .actual
 '
 
-test_expect_success 'reset --hard message (iso-8859-1 logoutencoding)' '
+test_expect_success 'reset --hard message (iso8859-1 logoutputencoding)' '
 	hex=$(git log -1 --format="%h") &&
-	git -c "i18n.logOutputEncoding=iso-8859-1" reset --hard > .actual &&
-	echo HEAD is now at $hex $(commit_msg iso-8859-1) > .expected &&
+	git -c "i18n.logOutputEncoding=iso8859-1" reset --hard > .actual &&
+	echo HEAD is now at $hex $(commit_msg iso8859-1) > .expected &&
 	test_cmp .expected .actual
 '
 
@@ -329,7 +329,7 @@ test_expect_success 'redoing the last two commits should succeed' '
 
 	echo "1st line 2nd file" >secondfile &&
 	echo "2nd line 2nd file" >>secondfile &&
-	git -c "i18n.commitEncoding=iso-8859-1" commit -a -m "$(commit_msg iso-8859-1)" &&
+	git -c "i18n.commitEncoding=iso8859-1" commit -a -m "$(commit_msg iso8859-1)" &&
 	check_changes $head5
 '
 
-- 
1.8.3.2.16.gb1f0d63

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

* [PATCH v10 2/5] t4205 (log-pretty-formats): revert back single quotes
  2013-07-04 12:45                               ` [PATCH v9 0/5] Incremental updates against 'next' branch Alexey Shumkin
  2013-07-05 12:01                                 ` [PATCH v10 " Alexey Shumkin
  2013-07-05 12:01                                 ` [PATCH v10 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1 Alexey Shumkin
@ 2013-07-05 12:01                                 ` Alexey Shumkin
  2013-07-05 12:01                                 ` [PATCH v10 3/5] t4205, t6006, t7102: make functions better readable Alexey Shumkin
                                                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-05 12:01 UTC (permalink / raw)
  To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano

In previuos commit de6029a (pretty: Add failing tests: --format output
should honor logOutputEncoding, 2013-06-26) single quotes were replaced
with double quotes to make "$(commit_msg)" expression in heredoc to
work. The same effect can be achieved by using "EOF" as a heredoc
delimiter instead of "\EOF".

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Suggested-by: Johannes Sixt <j.sixt@viscovery.net>
---
 t/t4205-log-pretty-formats.sh | 106 +++++++++++++++++++++---------------------
 1 file changed, 53 insertions(+), 53 deletions(-)

diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index c283842..ef9770a 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -145,174 +145,174 @@ test_expect_success 'setup more commits' '
 	head4=$(git rev-parse --verify --short HEAD~3)
 '
 
-test_expect_success 'left alignment formatting' "
-	git log --pretty='format:%<(40)%s' >actual &&
+test_expect_success 'left alignment formatting' '
+	git log --pretty="format:%<(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 message two                            Z
 message one                            Z
 add bar                                Z
 $(commit_msg)                    Z
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'left alignment formatting at the nth column' "
-	git log --pretty='format:%h %<|(40)%s' >actual &&
+test_expect_success 'left alignment formatting at the nth column' '
+	git log --pretty="format:%h %<|(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 $head1 message two                    Z
 $head2 message one                    Z
 $head3 add bar                        Z
 $head4 $(commit_msg)            Z
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'left alignment formatting with no padding' "
-	git log --pretty='format:%<(1)%s' >actual &&
+test_expect_success 'left alignment formatting with no padding' '
+	git log --pretty="format:%<(1)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	cat <<\EOF >expected &&
+	cat <<EOF >expected &&
 message two
 message one
 add bar
 $(commit_msg)
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'left alignment formatting with trunc' "
-	git log --pretty='format:%<(10,trunc)%s' >actual &&
+test_expect_success 'left alignment formatting with trunc' '
+	git log --pretty="format:%<(10,trunc)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 message ..
 message ..
 add bar  Z
 $(commit_msg "" "8" "..*$")
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'left alignment formatting with ltrunc' "
-	git log --pretty='format:%<(10,ltrunc)%s' >actual &&
+test_expect_success 'left alignment formatting with ltrunc' '
+	git log --pretty="format:%<(10,ltrunc)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 ..sage two
 ..sage one
 add bar  Z
 $(commit_msg "" "0" ".\{11\}")
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'left alignment formatting with mtrunc' "
-	git log --pretty='format:%<(10,mtrunc)%s' >actual &&
+test_expect_success 'left alignment formatting with mtrunc' '
+	git log --pretty="format:%<(10,mtrunc)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 mess.. two
 mess.. one
 add bar  Z
 $(commit_msg "" "4" ".\{11\}")
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'right alignment formatting' "
-	git log --pretty='format:%>(40)%s' >actual &&
+test_expect_success 'right alignment formatting' '
+	git log --pretty="format:%>(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 Z                            message two
 Z                            message one
 Z                                add bar
 Z                    $(commit_msg)
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'right alignment formatting at the nth column' "
-	git log --pretty='format:%h %>|(40)%s' >actual &&
+test_expect_success 'right alignment formatting at the nth column' '
+	git log --pretty="format:%h %>|(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 $head1                      message two
 $head2                      message one
 $head3                          add bar
 $head4              $(commit_msg)
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'right alignment formatting with no padding' "
-	git log --pretty='format:%>(1)%s' >actual &&
+test_expect_success 'right alignment formatting with no padding' '
+	git log --pretty="format:%>(1)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	cat <<\EOF >expected &&
+	cat <<EOF >expected &&
 message two
 message one
 add bar
 $(commit_msg)
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'center alignment formatting' "
-	git log --pretty='format:%><(40)%s' >actual &&
+test_expect_success 'center alignment formatting' '
+	git log --pretty="format:%><(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 Z             message two              Z
 Z             message one              Z
 Z               add bar                Z
 Z         $(commit_msg)          Z
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'center alignment formatting at the nth column' "
-	git log --pretty='format:%h %><|(40)%s' >actual &&
+test_expect_success 'center alignment formatting at the nth column' '
+	git log --pretty="format:%h %><|(40)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	qz_to_tab_space <<\EOF >expected &&
+	qz_to_tab_space <<EOF >expected &&
 $head1           message two          Z
 $head2           message one          Z
 $head3             add bar            Z
 $head4       $(commit_msg)      Z
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'center alignment formatting with no padding' "
-	git log --pretty='format:%><(1)%s' >actual &&
+test_expect_success 'center alignment formatting with no padding' '
+	git log --pretty="format:%><(1)%s" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	cat <<\EOF >expected &&
+	cat <<EOF >expected &&
 message two
 message one
 add bar
 $(commit_msg)
 EOF
 	test_cmp expected actual
-"
+'
 
-test_expect_success 'left/right alignment formatting with stealing' "
-	git commit --amend -m short --author 'long long long <long@me.com>' &&
-	git log --pretty='format:%<(10,trunc)%s%>>(10,ltrunc)% an' >actual &&
+test_expect_success 'left/right alignment formatting with stealing' '
+	git commit --amend -m short --author "long long long <long@me.com>" &&
+	git log --pretty="format:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
 	# complete the incomplete line at the end
 	echo >>actual &&
-	cat <<\EOF >expected &&
+	cat <<EOF >expected &&
 short long  long long
 message ..   A U Thor
 add bar      A U Thor
 $(commit_msg "" "8" "..*$")   A U Thor
 EOF
 	test_cmp expected actual
-"
+'
 
 test_done
-- 
1.8.3.2.16.gb1f0d63

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

* [PATCH v10 3/5] t4205, t6006, t7102: make functions better readable
  2013-07-04 12:45                               ` [PATCH v9 0/5] Incremental updates against 'next' branch Alexey Shumkin
                                                   ` (2 preceding siblings ...)
  2013-07-05 12:01                                 ` [PATCH v10 2/5] t4205 (log-pretty-formats): revert back single quotes Alexey Shumkin
@ 2013-07-05 12:01                                 ` Alexey Shumkin
  2013-07-05 18:38                                   ` Junio C Hamano
  2013-07-05 12:01                                 ` [PATCH v10 4/5] t6006 (rev-list-format): add tests for "%b" and "%s" for the case i18n.commitEncoding is not set Alexey Shumkin
  2013-07-05 12:01                                 ` [PATCH v10 5/5] t4205 (log-pretty-formats): avoid using `sed` Alexey Shumkin
  5 siblings, 1 reply; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-05 12:01 UTC (permalink / raw)
  To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano

Function 'test_format' has become harder to read after its
change in de6029a2 (pretty: Add failing tests: --format output
should honor logOutputEncoding, 2013-06-26). Simplify it by
moving its "should we expect it to fail?" parameter to the end.

Note, current code does not use this last parameter as far as there
are no tests expected to fail. We can keep that for future use.

Also, reformat comments

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Improved-by: Johannes Sixt <j.sixt@viscovery.net>
---
 t/t4205-log-pretty-formats.sh |  3 ++-
 t/t6006-rev-list-format.sh    | 28 ++++++++--------------------
 t/t7102-reset.sh              | 10 ++++++----
 3 files changed, 16 insertions(+), 25 deletions(-)

diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index ef9770a..2933c63 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -8,7 +8,8 @@ test_description='Test pretty formats'
 . ./test-lib.sh
 
 commit_msg () {
-	# String "initial. initial" partly in German (translated with Google Translate),
+	# String "initial. initial" partly in German
+	# (translated with Google Translate),
 	# encoded in UTF-8, used as a commit log message below.
 	msg=$(printf "initial. anf\303\244nglich")
 	if test -n "$1"
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 4751d22..b32405a 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -9,8 +9,9 @@ test_description='git rev-list --pretty=format test'
 . "$TEST_DIRECTORY"/lib-terminal.sh
 
 test_tick
-# String "added" in German (translated with Google Translate), encoded in UTF-8,
-# used as a commit log message below.
+# String "added" in German
+# (translated with Google Translate),
+# encoded in UTF-8, used as a commit log message below.
 added=$(printf "added (hinzugef\303\274gt) foo")
 added_iso88591=$(echo "$added" | iconv -f utf-8 -t iso8859-1)
 # same but "changed"
@@ -35,26 +36,13 @@ test_expect_success 'setup' '
 	git config --unset i18n.commitEncoding
 '
 
-# usage: test_format [failure] name format_string <expected_output
+# usage: test_format name format_string [failure] <expected_output
 test_format () {
-	must_fail=0
-	# if parameters count is more than 2 then test must fail
-	if test $# -gt 2
-	then
-		must_fail=1
-		# remove first parameter which is flag for test failure
-		shift
-	fi
 	cat >expect.$1
-	name="format $1"
-	command="git rev-list --pretty=format:'$2' master >output.$1 &&
-		test_cmp expect.$1 output.$1"
-	if test $must_fail -eq 1
-	then
-		test_expect_failure "$name" "$command"
-	else
-		test_expect_success "$name" "$command"
-	fi
+	test_expect_${3:-success} "format $1" "
+		git rev-list --pretty=format:'$2' master >output.$1 &&
+		test_cmp expect.$1 output.$1
+	"
 }
 
 # Feed to --format to provide predictable colored sequences.
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 2ef96e9..535e609 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -10,14 +10,16 @@ Documented tests for git reset'
 . ./test-lib.sh
 
 commit_msg () {
-	# String "modify 2nd file (changed)" partly in German(translated with Google Translate),
+	# String "modify 2nd file (changed)" partly in German
+	# (translated with Google Translate),
 	# encoded in UTF-8, used as a commit log message below.
-	msg=$(printf "modify 2nd file (ge\303\244ndert)")
+	msg="modify 2nd file (ge\303\244ndert)"
 	if test -n "$1"
 	then
-		msg=$(echo $msg | iconv -f utf-8 -t $1)
+		print "$msg" | iconv -f utf-8 -t "$1"
+	else
+		print "$msg"
 	fi
-	echo $msg
 }
 
 test_expect_success 'creating initial files and commits' '
-- 
1.8.3.2.16.gb1f0d63

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

* [PATCH v10 4/5] t6006 (rev-list-format): add tests for "%b" and "%s" for the case i18n.commitEncoding is not set
  2013-07-04 12:45                               ` [PATCH v9 0/5] Incremental updates against 'next' branch Alexey Shumkin
                                                   ` (3 preceding siblings ...)
  2013-07-05 12:01                                 ` [PATCH v10 3/5] t4205, t6006, t7102: make functions better readable Alexey Shumkin
@ 2013-07-05 12:01                                 ` Alexey Shumkin
  2013-07-05 12:01                                 ` [PATCH v10 5/5] t4205 (log-pretty-formats): avoid using `sed` Alexey Shumkin
  5 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-05 12:01 UTC (permalink / raw)
  To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano

In de6029a (pretty: Add failing tests: --format output should honor
logOutputEncoding, 2013-06-26) 'complex-subject' test was changed.
Revert it back, because that change actually removed tests for "%b" and
"%s" with i18n.commitEncoding set.
Also, add two more tests for mentioned above "%b" and "%s" to test
encoding conversions with no i18n.commitEncoding set.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Suggested-by: Johannes Sixt <j.sixt@viscovery.net>
---
 t/t6006-rev-list-format.sh | 41 ++++++++++++++++++++++++++++-------------
 1 file changed, 28 insertions(+), 13 deletions(-)

diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index b32405a..e51d0f0 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -218,12 +218,7 @@ test_expect_success 'setup complex body' '
 	git config i18n.commitencoding iso8859-1 &&
 	echo change2 >foo && git commit -a -F commit-msg &&
 	head3=$(git rev-parse --verify HEAD) &&
-	head3_short=$(git rev-parse --short $head3) &&
-	# unset commit encoding config
-	# otherwise %e does not print encoding value
-	# and following test fails
-	git config --unset i18n.commitEncoding
-
+	head3_short=$(git rev-parse --short $head3)
 '
 
 test_format complex-encoding %e <<EOF
@@ -239,21 +234,41 @@ test_format complex-subject %s <<EOF
 commit $head3
 Test printing of complex bodies
 commit $head2
-$changed
+$changed_iso88591
 commit $head1
-$added
+$added_iso88591
 EOF
 
-test_format complex-body %b <<EOF
-commit $head3
-This commit message is much longer than the others,
-and it will be encoded in iso8859-1. We should therefore
-include an iso8859 character: ¡bueno!
+test_expect_success 'prepare expected messages (for test %b)' '
+    cat <<-EOF >expected.utf-8 &&
+	commit $head3
+	This commit message is much longer than the others,
+	and it will be encoded in iso8859-1. We should therefore
+	include an iso8859 character: ¡bueno!
+
+	commit $head2
+	commit $head1
+EOF
+	iconv -f utf-8 -t iso8859-1 expected.utf-8 >expected.iso8859-1
+'
+
+test_format complex-body %b <expected.iso8859-1
 
+# Git uses i18n.commitEncoding if no i18n.logOutputEncoding set
+# so unset i18n.commitEncoding to test encoding conversion
+git config --unset i18n.commitEncoding
+
+test_format complex-subject-commitencoding-unset %s <<EOF
+commit $head3
+Test printing of complex bodies
 commit $head2
+$changed
 commit $head1
+$added
 EOF
 
+test_format complex-body-commitencoding-unset %b <expected.utf-8
+
 test_expect_success '%x00 shows NUL' '
 	echo  >expect commit $head3 &&
 	echo >>expect fooQbar &&
-- 
1.8.3.2.16.gb1f0d63

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

* [PATCH v10 5/5] t4205 (log-pretty-formats): avoid using `sed`
  2013-07-04 12:45                               ` [PATCH v9 0/5] Incremental updates against 'next' branch Alexey Shumkin
                                                   ` (4 preceding siblings ...)
  2013-07-05 12:01                                 ` [PATCH v10 4/5] t6006 (rev-list-format): add tests for "%b" and "%s" for the case i18n.commitEncoding is not set Alexey Shumkin
@ 2013-07-05 12:01                                 ` Alexey Shumkin
  5 siblings, 0 replies; 104+ messages in thread
From: Alexey Shumkin @ 2013-07-05 12:01 UTC (permalink / raw)
  To: git; +Cc: John Keeping, Johannes Sixt, Alexey Shumkin, Junio C Hamano

For testing truncated log messages 'commit_msg' function uses `sed` to
cut a message. On various platforms `sed` behaves differently and
results of its work depend on locales installed. So, avoid using `sed`.
Use predefined expected outputs instead of calculated ones.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t4205-log-pretty-formats.sh | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 2933c63..73fd236 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -7,25 +7,19 @@
 test_description='Test pretty formats'
 . ./test-lib.sh
 
+sample_utf8_part=$(printf "f\303\244ng")
+
 commit_msg () {
 	# String "initial. initial" partly in German
 	# (translated with Google Translate),
 	# encoded in UTF-8, used as a commit log message below.
-	msg=$(printf "initial. anf\303\244nglich")
+	msg="initial. an${sample_utf8_part}lich"
 	if test -n "$1"
 	then
-		msg=$(echo $msg | iconv -f utf-8 -t $1)
-	fi
-	if test -n "$2" -a -n "$3"
-	then
-		# cut string, replace cut part with two dots
-		# $2 - chars count from the beginning of the string
-		# $3 - "trailing" chars
-		# LC_ALL is set to make `sed` interpret "." as a UTF-8 char not a byte
-		# as it does with C locale
-		msg=$(echo $msg | LC_ALL=en_US.UTF-8 sed -e "s/^\(.\{$2\}\)$3/\1../")
+		print $msg | iconv -f utf-8 -t "$1"
+	else
+		print $msg
 	fi
-	echo $msg
 }
 
 test_expect_success 'set up basic repos' '
@@ -193,7 +187,7 @@ test_expect_success 'left alignment formatting with trunc' '
 message ..
 message ..
 add bar  Z
-$(commit_msg "" "8" "..*$")
+initial...
 EOF
 	test_cmp expected actual
 '
@@ -206,7 +200,7 @@ test_expect_success 'left alignment formatting with ltrunc' '
 ..sage two
 ..sage one
 add bar  Z
-$(commit_msg "" "0" ".\{11\}")
+..${sample_utf8_part}lich
 EOF
 	test_cmp expected actual
 '
@@ -219,7 +213,7 @@ test_expect_success 'left alignment formatting with mtrunc' '
 mess.. two
 mess.. one
 add bar  Z
-$(commit_msg "" "4" ".\{11\}")
+init..lich
 EOF
 	test_cmp expected actual
 '
@@ -311,7 +305,7 @@ test_expect_success 'left/right alignment formatting with stealing' '
 short long  long long
 message ..   A U Thor
 add bar      A U Thor
-$(commit_msg "" "8" "..*$")   A U Thor
+initial...   A U Thor
 EOF
 	test_cmp expected actual
 '
-- 
1.8.3.2.16.gb1f0d63

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

* Re: [PATCH v10 3/5] t4205, t6006, t7102: make functions better readable
  2013-07-05 12:01                                 ` [PATCH v10 3/5] t4205, t6006, t7102: make functions better readable Alexey Shumkin
@ 2013-07-05 18:38                                   ` Junio C Hamano
  2013-07-05 18:45                                     ` Junio C Hamano
  0 siblings, 1 reply; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05 18:38 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt

Alexey Shumkin <alex.crezoff@gmail.com> writes:

> -	msg=$(printf "modify 2nd file (ge\303\244ndert)")
> +	msg="modify 2nd file (ge\303\244ndert)"
>  	if test -n "$1"
>  	then
> -		msg=$(echo $msg | iconv -f utf-8 -t $1)
> +		print "$msg" | iconv -f utf-8 -t "$1"
> +	else
> +		print "$msg"
>  	fi
> -	echo $msg
>  }

I think I'll do s/print/&f/ before queuing this.

Thanks.

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

* Re: [PATCH v10 3/5] t4205, t6006, t7102: make functions better readable
  2013-07-05 18:38                                   ` Junio C Hamano
@ 2013-07-05 18:45                                     ` Junio C Hamano
  0 siblings, 0 replies; 104+ messages in thread
From: Junio C Hamano @ 2013-07-05 18:45 UTC (permalink / raw)
  To: Alexey Shumkin; +Cc: git, John Keeping, Johannes Sixt

Junio C Hamano <gitster@pobox.com> writes:

> Alexey Shumkin <alex.crezoff@gmail.com> writes:
>
>> -	msg=$(printf "modify 2nd file (ge\303\244ndert)")
>> +	msg="modify 2nd file (ge\303\244ndert)"
>>  	if test -n "$1"
>>  	then
>> -		msg=$(echo $msg | iconv -f utf-8 -t $1)
>> +		print "$msg" | iconv -f utf-8 -t "$1"
>> +	else
>> +		print "$msg"
>>  	fi
>> -	echo $msg
>>  }
>
> I think I'll do s/print/&f/ before queuing this.

Also, I'll change the $msg constant to have \n at the end, as we are
losing it by bypassing "echo".

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

end of thread, other threads:[~2013-07-05 18:46 UTC | newest]

Thread overview: 104+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-22  7:06 git log --oneline and git log --pretty=format... give differrent outputs Shumkin Alexey
2011-07-22  7:53 ` Alexey Shumkin
2011-07-25 10:31   ` [PATCH] pretty: user format ignores i18n.logOutputEncoding setting Alexey Shumkin
2011-07-25 10:31     ` Alexey Shumkin
2011-07-25 19:45       ` Junio C Hamano
2011-07-26 13:18         ` Alexey Shumkin
2011-09-09  8:43         ` [PATCH v2] " Alexey Shumkin
2011-09-09  8:43           ` [PATCH 1/2] pretty: Add failing tests: " Alexey Shumkin
2011-09-09  8:43           ` [PATCH 2/2] pretty: " Alexey Shumkin
2011-09-09  8:53         ` [PATCH v2] " Alexey Shumkin
2011-09-09  8:53           ` [PATCH 1/2] pretty: Add failing tests: " Alexey Shumkin
2011-09-09 22:54             ` Junio C Hamano
2011-09-20  8:20               ` [PATCH v3 0/2] pretty: " Alexey Shumkin
2011-09-20  8:21               ` [PATCH v3 1/2] pretty: Add failing tests: " Alexey Shumkin
2011-09-20 19:12                 ` Junio C Hamano
2011-09-20 20:46                   ` Alexey Shumkin
2013-01-24  9:10                     ` [PATCH v4 0/4] Reroll patches against v1.8.1.1 Alexey Shumkin
2013-06-20  9:26                       ` [PATCH v5 0/5] Reroll patches against v1.8.3.1 Alexey Shumkin
2013-06-20 20:10                         ` Junio C Hamano
2013-06-25  8:55                         ` [PATCH v6 " Alexey Shumkin
2013-06-25 19:28                           ` Junio C Hamano
2013-06-26  7:37                             ` Alexey Shumkin
2013-06-26 14:24                               ` Junio C Hamano
2013-06-26 10:19                           ` [PATCH v7 " Alexey Shumkin
2013-06-26 16:19                             ` Junio C Hamano
2013-07-01 23:18                             ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 Alexey Shumkin
2013-07-02 19:41                               ` Junio C Hamano
2013-07-03 20:03                                 ` Alexey Shumkin
2013-07-03 20:06                                   ` Junio C Hamano
2013-07-04 12:45                               ` [PATCH v9 0/5] Incremental updates against 'next' branch Alexey Shumkin
2013-07-05 12:01                                 ` [PATCH v10 " Alexey Shumkin
2013-07-05 12:01                                 ` [PATCH v10 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1 Alexey Shumkin
2013-07-05 12:01                                 ` [PATCH v10 2/5] t4205 (log-pretty-formats): revert back single quotes Alexey Shumkin
2013-07-05 12:01                                 ` [PATCH v10 3/5] t4205, t6006, t7102: make functions better readable Alexey Shumkin
2013-07-05 18:38                                   ` Junio C Hamano
2013-07-05 18:45                                     ` Junio C Hamano
2013-07-05 12:01                                 ` [PATCH v10 4/5] t6006 (rev-list-format): add tests for "%b" and "%s" for the case i18n.commitEncoding is not set Alexey Shumkin
2013-07-05 12:01                                 ` [PATCH v10 5/5] t4205 (log-pretty-formats): avoid using `sed` Alexey Shumkin
2013-07-04 12:45                               ` [PATCH v9 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1 Alexey Shumkin
2013-07-05  6:47                                 ` Junio C Hamano
2013-07-05  8:00                                   ` Alexey Shumkin
2013-07-05  8:11                                     ` Junio C Hamano
2013-07-05  8:42                                       ` Alexey Shumkin
2013-07-05  8:56                                         ` Junio C Hamano
2013-07-04 12:45                               ` [PATCH v9 2/5] t4205: revert back single quotes Alexey Shumkin
2013-07-05  7:07                                 ` Junio C Hamano
2013-07-04 12:45                               ` [PATCH v9 3/5] t4205, t6006, t7102: make functions more readable Alexey Shumkin
2013-07-05  6:45                                 ` Junio C Hamano
2013-07-05  8:13                                   ` Alexey Shumkin
2013-07-05  8:44                                     ` Junio C Hamano
2013-07-05  8:51                                       ` Alexey Shumkin
2013-07-05  8:58                                         ` Junio C Hamano
2013-07-04 12:45                               ` [PATCH v9 4/5] t6006: add two more tests for the case i18n.commitEncoding is not set Alexey Shumkin
2013-07-05  6:52                                 ` Junio C Hamano
2013-07-05  7:04                                 ` Junio C Hamano
2013-07-05  7:46                                   ` Alexey Shumkin
2013-07-05  8:09                                     ` Junio C Hamano
2013-07-04 12:45                               ` [PATCH v9 5/5] t4205: avoid using `sed` Alexey Shumkin
2013-07-01 23:19                             ` [PATCH v8 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
2013-07-01 23:19                             ` [PATCH v8 2/5] t7102 (reset): " Alexey Shumkin
2013-07-01 23:19                             ` [PATCH v8 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
2013-07-01 23:19                             ` [PATCH v8 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
2013-07-02  6:46                               ` Johannes Sixt
2013-07-01 23:19                             ` [PATCH v8 5/5] pretty: " Alexey Shumkin
2013-06-26 10:19                           ` [PATCH v7 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
2013-06-26 10:19                           ` [PATCH v7 2/5] t7102 (reset): " Alexey Shumkin
2013-06-26 10:19                           ` [PATCH v7 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
2013-06-26 10:19                           ` [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
2013-07-01  7:00                             ` Johannes Sixt
2013-07-01 22:50                               ` Alexey Shumkin
2013-07-02  7:22                                 ` Johannes Sixt
2013-07-03 20:20                                   ` Alexey Shumkin
2013-06-26 10:19                           ` [PATCH v7 5/5] pretty: " Alexey Shumkin
2013-06-25  8:55                         ` [PATCH v6 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
2013-06-25  8:55                         ` [PATCH v6 2/5] t7102 (reset): " Alexey Shumkin
2013-06-25  8:55                         ` [PATCH v6 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
2013-06-25  8:55                         ` [PATCH v6 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
2013-06-25  8:55                         ` [PATCH v6 5/5] pretty: " Alexey Shumkin
2013-06-20  9:26                       ` [PATCH v5 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
2013-06-20 20:38                         ` Junio C Hamano
2013-06-20  9:26                       ` [PATCH v5 2/5] t7102 (reset): " Alexey Shumkin
2013-06-20  9:26                       ` [PATCH v5 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
2013-06-20 20:38                         ` Junio C Hamano
2013-06-20  9:26                       ` [PATCH v5 4/5] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting Alexey Shumkin
2013-06-20 20:23                         ` Junio C Hamano
2013-06-20  9:26                       ` [PATCH v5 5/5] pretty: " Alexey Shumkin
2013-06-20 20:37                         ` Junio C Hamano
2013-01-24  9:10                     ` [PATCH v4 1/4] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
2013-01-24 20:29                       ` Junio C Hamano
2013-01-25  9:20                         ` Alexey Shumkin
2013-01-25 11:06                         ` Alexey Shumkin
2013-01-25 15:16                           ` Junio C Hamano
2013-01-25 15:27                             ` Alexey Shumkin
2013-01-24  9:10                     ` [PATCH v4 2/4] t7102 (reset): refactoring: " Alexey Shumkin
2013-01-24 20:30                       ` Junio C Hamano
2013-01-25  9:08                         ` Alexey Shumkin
2013-01-24  9:10                     ` [PATCH v4 3/4] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting Alexey Shumkin
2013-01-24 20:44                       ` Junio C Hamano
2013-01-25  9:07                         ` Alexey Shumkin
2013-01-24 21:02                       ` Junio C Hamano
2013-01-25  9:01                         ` Alexey Shumkin
2013-01-24  9:10                     ` [PATCH v4 4/4] pretty: " Alexey Shumkin
2011-09-20  8:21               ` [PATCH v3 2/2] " Alexey Shumkin
2011-09-09  8:53           ` [PATCH " Alexey Shumkin

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).