Re: [PATCH 0/7] contrib/subtree: Testsuite cleanup

2015-11-13 Thread Alexey Shumkin
On Thu, Nov 12, 2015 at 08:32:29PM -0600, David Greene wrote:
> Sending again with a proper From: address after rebasing on latest master.
> 
> Copying the maintainers because the origin patchset didn't get any
> comments and I'm unsure of how to proceed.
> 
> These are some old changes I have lying around that should get applied
> to clean up git-subtree's testbase.  With these changes post-mortem
> analysis is much easier and adding new tests can be done in an orderly
> fashion.
> 
> I have a number of future patches and further development ideas for
> git-subtree that require these changes as a prerequisite.
Please, could you take a look to the following thread
http://thread.gmane.org/gmane.comp.version-control.git/277343
to take into account the mentioned bug for your futher work?

Thank you
> 
> -David
> 
>  contrib/subtree/git-subtree.sh |2 +-
>  contrib/subtree/t/Makefile |   31 +-
>  contrib/subtree/t/t7900-subtree.sh | 1366 +--
>  3 files changed, 956 insertions(+), 443 deletions(-)
> 

-- 
Alexey Shumkin
E-mail: alex.crez...@gmail.com
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1 0/2] contrib/subtree: make it respect spaces in a repository path

2015-09-07 Thread Alexey Shumkin
On Fri, Sep 04, 2015 at 04:08:06PM -0700, Junio C Hamano wrote:
> Alexey Shumkin  writes:
> 
> > Some repositories may have spaces in their paths. Currently `git-subtree`
> > raises an error in such cases.
> > Also, `git-subtree` currently does not have tests for its 'push' command.
> > Following patches are to fix these statements.
> >
> > Alexey Shumkin (2):
> >   t7900-subtree: test the "space in a subdirectory name" case
> >   contrib/subtree: respect spaces in a repository path
> 
> Doesn't this order break bisection?  It seems that you turn "subdir"
> to "sub dir" in existing tests, and I understand that the whole
> point of this series is that such a change will expose that the tool
> is broken, making tests fail.
It seems I have to reword commit messages to avoid such an interpretation.
Because, the first commit does not break anything. It is to change the
tests for `git-subtree` "to show" that `git-subtree`s already tested
commands (almost) work correctly if there are spaces in paths (except
--rejoin-msg issue).
And the second commit adds missing tests and the fix.
Should I add/commit the breaking test first and then commit the fix?
> 
> Also, if you feel up to it, it might be a good idea to clean t7900
> test up to the current best practice before doing any other changes
> as a pure preparatory clean-up patch.
> 
> Namely, using cd outside a subshell of the tests to move around is a
> bad thing to do, and you are adding more instance of it in this
> series.  If one test with such a cd to go down fails before it has a
> chance to come back up (or go up and then fail to come back down),
> the later tests will be left in an unexpected place.
I understand this issue with "cd" (I've just followed the existing t7900
tests "code style").
> 
> >  contrib/subtree/git-subtree.sh |   4 +-
> >  contrib/subtree/t/t7900-subtree.sh | 194 
> > +++--
> >  2 files changed, 124 insertions(+), 74 deletions(-)
> 
> Thanks.

-- 
Alexey Shumkin
E-mail: alex.crez...@gmail.com
ICQ: 118001447
Jabber (GoogleTalk): alex.crez...@gmail.com
Skype: crezoff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v1 1/2] t7900-subtree: test the "space in a subdirectory name" case

2015-09-04 Thread Alexey Shumkin
In common case there can be spaces in a subdirectory name. Change tests
accorgingly to this statement.

Also, as far as a call to the `rejoin_msg` function (in `cmd_split`)
does not take into account such a case this patch fixes commit message
when `--rejoin` option is set .

Besides, as `fixnl` and `multiline` functions did not take into account
the "new" tested "space in a subdirectory name" case they become unused
and redundant, so they are removed.

Signed-off-by: Alexey Shumkin 
---
 contrib/subtree/git-subtree.sh |   2 +-
 contrib/subtree/t/t7900-subtree.sh | 147 +++--
 2 files changed, 76 insertions(+), 73 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 9f06571..72a20c0 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -648,7 +648,7 @@ cmd_split()
debug "Merging split branch into HEAD..."
latest_old=$(cache_get latest_old)
git merge -s ours \
-   -m "$(rejoin_msg $dir $latest_old $latest_new)" \
+   -m "$(rejoin_msg "$dir" $latest_old $latest_new)" \
$latest_new >&2 || exit $?
fi
if [ -n "$branch" ]; then
diff --git a/contrib/subtree/t/t7900-subtree.sh 
b/contrib/subtree/t/t7900-subtree.sh
index 9051982..9979827 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -32,25 +32,6 @@ check_equal()
fi
 }
 
-fixnl()
-{
-   t=""
-   while read x; do
-   t="$t$x "
-   done
-   echo $t
-}
-
-multiline()
-{
-   while read x; do
-   set -- $x
-   for d in "$@"; do
-   echo "$d"
-   done
-   done
-}
-
 undo()
 {
git reset --hard HEAD~
@@ -62,11 +43,11 @@ last_commit_message()
 }
 
 test_expect_success 'init subproj' '
-   test_create_repo subproj
+   test_create_repo "sub proj"
 '
 
 # To the subproject!
-cd subproj
+cd ./"sub proj"
 
 test_expect_success 'add sub1' '
create sub1 &&
@@ -106,39 +87,39 @@ test_expect_success 'add main4' '
 '
 
 test_expect_success 'fetch subproj history' '
-   git fetch ./subproj sub1 &&
+   git fetch ./"sub proj" sub1 &&
git branch sub1 FETCH_HEAD
 '
 
 test_expect_success 'no subtree exists in main tree' '
-   test_must_fail git subtree merge --prefix=subdir sub1
+   test_must_fail git subtree merge --prefix="sub dir" sub1
 '
 
 test_expect_success 'no pull from non-existant subtree' '
-   test_must_fail git subtree pull --prefix=subdir ./subproj sub1
+   test_must_fail git subtree pull --prefix="sub dir" ./"sub proj" sub1
 '
 
 test_expect_success 'check if --message works for add' '
-   git subtree add --prefix=subdir --message="Added subproject" sub1 &&
+   git subtree add --prefix="sub dir" --message="Added subproject" sub1 &&
check_equal ''"$(last_commit_message)"'' "Added subproject" &&
undo
 '
 
 test_expect_success 'check if --message works as -m and --prefix as -P' '
-   git subtree add -P subdir -m "Added subproject using git subtree" sub1 
&&
+   git subtree add -P "sub dir" -m "Added subproject using git subtree" 
sub1 &&
check_equal ''"$(last_commit_message)"'' "Added subproject using git 
subtree" &&
undo
 '
 
 test_expect_success 'check if --message works with squash too' '
-   git subtree add -P subdir -m "Added subproject with squash" --squash 
sub1 &&
+   git subtree add -P "sub dir" -m "Added subproject with squash" --squash 
sub1 &&
check_equal ''"$(last_commit_message)"'' "Added subproject with squash" 
&&
undo
 '
 
 test_expect_success 'add subproj to mainline' '
-   git subtree add --prefix=subdir/ FETCH_HEAD &&
-   check_equal ''"$(last_commit_message)"'' "Add '"'subdir/'"' from commit 
'"'"'''"$(git rev-parse sub1)"'''"'"'"
+   git subtree add --prefix="sub dir"/ FETCH_HEAD &&
+   check_equal ''"$(last_commit_message)"'' "Add '"'sub dir/'"

[PATCH v1 2/2] contrib/subtree: respect spaces in a repository path

2015-09-04 Thread Alexey Shumkin
Remote repository may have spaces in its path, so take it into account.

Also, as far as there are no tests for the `push` command, add them.

Signed-off-by: Alexey Shumkin 
---
 contrib/subtree/git-subtree.sh |  2 +-
 contrib/subtree/t/t7900-subtree.sh | 47 ++
 2 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 72a20c0..308b777 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -735,7 +735,7 @@ cmd_push()
refspec=$2
echo "git push using: " $repository $refspec
localrev=$(git subtree split --prefix="$prefix") || die
-   git push $repository $localrev:refs/heads/$refspec
+   git push "$repository" $localrev:refs/heads/$refspec
else
die "'$dir' must already exist. Try 'git subtree add'."
fi
diff --git a/contrib/subtree/t/t7900-subtree.sh 
b/contrib/subtree/t/t7900-subtree.sh
index 9979827..dfbe443 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 #
 # Copyright (c) 2012 Avery Pennaraum
+# Copyright (c) 2015 Alexey Shumkin
 #
 test_description='Basic porcelain support for subtrees
 
@@ -471,4 +472,50 @@ test_expect_success 'verify one file change per commit' '
))
 '
 
+# test push
+
+cd ../..
+
+mkdir test-push
+
+cd test-push
+
+test_expect_success 'init main' '
+   test_create_repo main
+'
+
+test_expect_success 'init sub' '
+   test_create_repo "sub project"
+'
+
+cd ./"sub project"
+
+test_expect_success 'add subproject' '
+   create "sub project" &&
+   git commit -m "Sub project: 1" &&
+   git branch sub-branch-1
+'
+
+cd ../main
+
+test_expect_success 'make first commit and add subproject' '
+   create "main-1" &&
+   git commit -m "main: 1" &&
+   git subtree add "../sub project" --prefix "sub dir" --message "Added 
subproject" sub-branch-1 &&
+   check_equal "$(last_commit_message)" "Added subproject"
+'
+
+test_expect_success 'make second commit to a subproject file and push it into 
a sub project' '
+   create "sub dir/sub1" &&
+   git commit -m "Sub project: 2" &&
+   git subtree push "../sub project" --prefix "sub dir" sub-branch-1
+'
+
+cd ../"sub project"
+
+test_expect_success 'Test second commit is pushed' '
+   git checkout sub-branch-1 &&
+   check_equal "$(last_commit_message)" "Sub project: 2"
+'
+
 test_done
-- 
2.4.1-21

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v1 0/2] contrib/subtree: make it respect spaces in a repository path

2015-09-04 Thread Alexey Shumkin
Some repositories may have spaces in their paths. Currently `git-subtree`
raises an error in such cases.
Also, `git-subtree` currently does not have tests for its 'push' command.
Following patches are to fix these statements.

Alexey Shumkin (2):
  t7900-subtree: test the "space in a subdirectory name" case
  contrib/subtree: respect spaces in a repository path

 contrib/subtree/git-subtree.sh |   4 +-
 contrib/subtree/t/t7900-subtree.sh | 194 +++--
 2 files changed, 124 insertions(+), 74 deletions(-)

-- 
2.4.1-21

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: mktime call hangs on Cygwin 1.7.30, Windows 7 32 bit

2014-09-10 Thread Alexey Shumkin
On Tue, Sep 02, 2014 at 01:32:29PM +0200, Marco Atzeri wrote:
> On 02/09/2014 13:10, Alexey Shumkin wrote:
> >Prelude.
> >I use "self-compiled" Git (v2.x) on Cygwin (v1.7.30).
> >Sometimes Git v2.0.4 hung while performing
> >   git prune --expire 2.weeks.ago
> >
> >I have investigated while debugging that `mktime` call hung.
> >But that was an avoidable bug (skip prune - and all is ok). So, I've not
> >reported it.
> >
> >But after updating Git to v2.1.0
> >   git commit --amend -C HEAD --date=''
> >hangs, too. And now it is the often used operation by me.
> >So, I've made a simple example (copied from Git sources) to reproduce
> >the error.
> >
> >$ cat cygwin-mktime-bug.c
> >#include 
> >#include 
> >#include 
> >
> >int main(int argc, char **argv)
> >{
> >  struct tm tm;
> >
> >  memset(&tm, 0, sizeof(tm));
> >  tm.tm_year = -1;
> >  tm.tm_mon = -1;
> >  tm.tm_mday = -1;
> >  tm.tm_isdst = -1;
> >  tm.tm_hour = -1;
> >  tm.tm_min = -1;
> >  tm.tm_sec = -1;
> >
> >  printf("Working...\n");
> >  time_t temp_time = mktime(&tm);
> >   printf("Worked");
> -   printf("Worked");
> -   printf("Worked\n");
> >}
> >
> >$ gcc cygwin-mktime-bug.c -o cygwin-mktime-bug -I/usr/include -g
> >$ ./cygwin-mktime-bug.exe
> >Working...
> >
> no issue on my side.
I've tested on another machines with Cygwin v1.7.11 and v1.7.25. And it
worked. That`s Ok.
Also, I've run ./cygwin-mktime-bug.exe in CMD, and SUPRISINGLY it
worked, but when I run the SAME `cygwin-mktime-bug.exe` in `bash -l -i` it does 
not!

Ha-ha! After I've wrote text above, I've tested run `cygwin-mktime-bug.exe`
in `bash`, `bash -i`, `bash -l` AND(!) it worked well in first TWO
cases (`bash` & `bash -i`), and DOES NOT in `bash -l`.
How can it be? 8-O
> 
> $ LIMIT=1000
> $ for ((a=1 ; a <= LIMIT ; a++ )); do ./cygwin-mktime-bug.exe ; done
> 
> Working...
> Worked
> ...
> Working...
> Worked
> $
> 
> 
> >
> >So, there is a question: how to fix it?
> >Nota bene: I do not want to use Cygwin x64 (there were no exim when I've 
> >tested it).
> 
> 32 bit here.
> 
> $ uname -svr
> CYGWIN_NT-6.1-WOW64 1.7.32(0.274/5/3) 2014-08-13 23:03
> 
> please update to 1.7.32 and than follows:
> https://cygwin.com/problems.html
> 
> Regards
> Marco
> 
> --
> Problem reports:   http://cygwin.com/problems.html
> FAQ:   http://cygwin.com/faq/
> Documentation: http://cygwin.com/docs.html
> Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



mktime call hangs on Cygwin 1.7.30, Windows 7 32 bit

2014-09-02 Thread Alexey Shumkin
Prelude.
I use "self-compiled" Git (v2.x) on Cygwin (v1.7.30).
Sometimes Git v2.0.4 hung while performing
  git prune --expire 2.weeks.ago

I have investigated while debugging that `mktime` call hung.
But that was an avoidable bug (skip prune - and all is ok). So, I've not
reported it.

But after updating Git to v2.1.0
  git commit --amend -C HEAD --date=''
hangs, too. And now it is the often used operation by me.
So, I've made a simple example (copied from Git sources) to reproduce
the error.

$ cat cygwin-mktime-bug.c
#include 
#include 
#include 

int main(int argc, char **argv)
{
 struct tm tm;

 memset(&tm, 0, sizeof(tm));
 tm.tm_year = -1;
 tm.tm_mon = -1;
 tm.tm_mday = -1;
 tm.tm_isdst = -1;
 tm.tm_hour = -1;
 tm.tm_min = -1;
 tm.tm_sec = -1;

 printf("Working...\n");
 time_t temp_time = mktime(&tm);
 printf("Worked");
}

$ gcc cygwin-mktime-bug.c -o cygwin-mktime-bug -I/usr/include -g
$ ./cygwin-mktime-bug.exe
Working...



So, there is a question: how to fix it?
Nota bene: I do not want to use Cygwin x64 (there were no exim when I've tested 
it).


-- 
Alexey Shumkin

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



[PATCH v4 5/5] pretty.c: format string with truncate respects logOutputEncoding

2014-05-21 Thread Alexey Shumkin
Pretty format string %<(N,[ml]trunc)>%s truncates subject to a given
length with an appropriate padding. This works for non-ASCII texts when
i18n.logOutputEncoding is UTF-8 only (independently of a printed commit
message encoding) but does not work when i18n.logOutputEncoding is NOT
UTF-8.

In 7e77df3 (pretty: two phase conversion for non utf-8 commits, 2013-04-19)
'format_commit_item' function assumes commit message to be in UTF-8.
And that was so until ecaee80 (pretty: --format output should honor
logOutputEncoding, 2013-06-26) where conversion to logOutputEncoding was
added before calling 'format_commit_message'.

Correct this by converting a commit message to UTF-8 first (as it
assumed in 7e77df3 (pretty: two phase conversion for non utf-8 commits,
2013-04-19)). Only after that convert a commit message to an actual
logOutputEncoding.

Signed-off-by: Alexey Shumkin 
Reviewed-by: Nguyễn Thái Ngọc Duy 
---
 pretty.c  | 7 ++-
 t/t4205-log-pretty-formats.sh | 8 
 t/t6006-rev-list-format.sh| 6 +++---
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/pretty.c b/pretty.c
index 6e266dd..25e8825 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1507,13 +1507,18 @@ void format_commit_message(const struct commit *commit,
context.commit = commit;
context.pretty_ctx = pretty_ctx;
context.wrap_start = sb->len;
+   /*
+* convert a commit message to UTF-8 first
+* as far as 'format_commit_item' assumes it in UTF-8
+*/
context.message = logmsg_reencode(commit,
  &context.commit_encoding,
- output_enc);
+ utf8);
 
strbuf_expand(sb, format, format_commit_item, &context);
rewrap_message_tail(sb, &context, 0, 0, 0);
 
+   /* then convert a commit message to an actual output encoding */
if (output_enc) {
if (same_encoding(utf8, output_enc))
output_enc = NULL;
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 74babce..c84ec9a 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -220,7 +220,7 @@ EOF
test_cmp expected actual
 '
 
-test_expect_failure 'left alignment formatting with trunc. 
i18n.logOutputEncoding' '
+test_expect_success 'left alignment formatting with trunc. 
i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log 
--pretty="tformat:%<(10,trunc)%s" >actual &&
qz_to_tab_space <expected &&
 message ..
@@ -242,7 +242,7 @@ EOF
test_cmp expected actual
 '
 
-test_expect_failure 'left alignment formatting with ltrunc. 
i18n.logOutputEncoding' '
+test_expect_success 'left alignment formatting with ltrunc. 
i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log 
--pretty="tformat:%<(10,ltrunc)%s" >actual &&
qz_to_tab_space <expected &&
 ..sage two
@@ -264,7 +264,7 @@ EOF
test_cmp expected actual
 '
 
-test_expect_failure 'left alignment formatting with mtrunc. 
i18n.logOutputEncoding' '
+test_expect_success 'left alignment formatting with mtrunc. 
i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log 
--pretty="tformat:%<(10,mtrunc)%s" >actual &&
qz_to_tab_space <expected &&
 mess.. two
@@ -420,7 +420,7 @@ initial...   A U Thor
 EOF
test_cmp expected actual
 '
-test_expect_failure 'left/right alignment formatting with stealing. 
i18n.logOutputEncoding' '
+test_expect_success 'left/right alignment formatting with stealing. 
i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log 
--pretty="tformat:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
cat <expected &&
 short long  long long
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 42bdefe..19434ad 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -259,7 +259,7 @@ commit $head1
 $added_iso88591
 EOF
 
-test_format complex-subject-trunc "%<($truncate_count,trunc)%s" failure <http://vger.kernel.org/majordomo-info.html


[PATCH v4 2/5] t4041, t4205, t6006, t7102: Don't hardcode tested encoding value

2014-05-21 Thread Alexey Shumkin
The tested encoding is always available in a variable. Use it instead of
hardcoding. Also, to be in line with other tests use ISO8859-1
(uppercase) rather then iso8859-1.

Signed-off-by: Alexey Shumkin 
---
 t/t4041-diff-submodule-option.sh |  7 +--
 t/t4205-log-pretty-formats.sh| 11 +++
 t/t6006-rev-list-format.sh   | 35 +++
 t/t7102-reset.sh | 13 -
 4 files changed, 39 insertions(+), 27 deletions(-)

diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 1751c83..463d63b 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -11,6 +11,9 @@ This test tries to verify the sanity of the --submodule 
option of git diff.
 
 . ./test-lib.sh
 
+# Tested non-UTF-8 encoding
+test_encoding="ISO8859-1"
+
 # 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")
@@ -23,8 +26,8 @@ add_file () {
echo "$name" >"$name" &&
git add "$name" &&
test_tick &&
-   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"
+   msg_added_iso88591=$(echo "Add $name ($added $name)" | 
iconv -f utf-8 -t $test_encoding) &&
+   git -c "i18n.commitEncoding=$test_encoding" 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 f9f33ae..f5ea3f8 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -7,6 +7,9 @@
 test_description='Test pretty formats'
 . ./test-lib.sh
 
+# Tested non-UTF-8 encoding
+test_encoding="ISO8859-1"
+
 sample_utf8_part=$(printf "f\303\244ng")
 
 commit_msg () {
@@ -27,8 +30,8 @@ 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)" &&
+   git config i18n.commitEncoding $test_encoding &&
+   git commit -m "$(commit_msg $test_encoding)" &&
git add bar &&
test_tick &&
git commit -m "add bar" &&
@@ -56,8 +59,8 @@ 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 &&
+test_expect_success 'alias user-defined tformat with %s (ISO8859-1 encoding)' '
+   git config i18n.logOutputEncoding $test_encoding &&
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 9874403..9e4ba62 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -9,19 +9,22 @@ test_description='git rev-list --pretty=format test'
 . "$TEST_DIRECTORY"/lib-terminal.sh
 
 test_tick
+# Tested non-UTF-8 encoding
+test_encoding="ISO8859-1"
+
 # 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)
+added_iso88591=$(echo "$added" | iconv -f utf-8 -t $test_encoding)
 # same but "changed"
 changed=$(printf "changed (ge\303\244ndert) foo")
-changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t iso8859-1)
+changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t $test_encoding)
 
 test_expect_success 'setup' '
: >foo &&
git add foo &&
-   git config i18n.commitEncoding iso8859-1 &&
+   git config i18n.commitEncoding $test_encoding &&
git commit -m "$added_iso88591" &&
head1=$(git rev-parse --verify HEAD) &&
head1_short=$(git rev-parse --verify --short $head1) &&
@@ -124,9 +127,9 @@ EOF
 
 test_format encoding %e < commit-msg < commit-msg <foo && git commit -a -F c

[PATCH v4 3/5] t4205 (log-pretty-format): Use `tformat` rather than `format`

2014-05-21 Thread Alexey Shumkin
Use `tformat` to avoid using of `echo` to complete end of line.

Signed-off-by: Alexey Shumkin 
---
 t/t4205-log-pretty-formats.sh | 52 +++
 1 file changed, 13 insertions(+), 39 deletions(-)

diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index f5ea3f8..c03a65e 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -144,9 +144,7 @@ test_expect_success 'setup more commits' '
 '
 
 test_expect_success 'left alignment formatting' '
-   git log --pretty="format:%<(40)%s" >actual &&
-   # complete the incomplete line at the end
-   echo >>actual &&
+   git log --pretty="tformat:%<(40)%s" >actual &&
qz_to_tab_space <expected &&
 message twoZ
 message oneZ
@@ -157,9 +155,7 @@ EOF
 '
 
 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 &&
+   git log --pretty="tformat:%h %<|(40)%s" >actual &&
qz_to_tab_space <expected &&
 $head1 message twoZ
 $head2 message oneZ
@@ -170,9 +166,7 @@ EOF
 '
 
 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 &&
+   git log --pretty="tformat:%<(1)%s" >actual &&
cat <expected &&
 message two
 message one
@@ -183,9 +177,7 @@ EOF
 '
 
 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 &&
+   git log --pretty="tformat:%<(10,trunc)%s" >actual &&
qz_to_tab_space <expected &&
 message ..
 message ..
@@ -196,9 +188,7 @@ EOF
 '
 
 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 &&
+   git log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
qz_to_tab_space <expected &&
 ..sage two
 ..sage one
@@ -209,9 +199,7 @@ EOF
 '
 
 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 &&
+   git log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
qz_to_tab_space <expected &&
 mess.. two
 mess.. one
@@ -222,9 +210,7 @@ EOF
 '
 
 test_expect_success 'right alignment formatting' '
-   git log --pretty="format:%>(40)%s" >actual &&
-   # complete the incomplete line at the end
-   echo >>actual &&
+   git log --pretty="tformat:%>(40)%s" >actual &&
qz_to_tab_space <expected &&
 Zmessage two
 Zmessage one
@@ -235,9 +221,7 @@ EOF
 '
 
 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 &&
+   git log --pretty="tformat:%h %>|(40)%s" >actual &&
qz_to_tab_space <expected &&
 $head1  message two
 $head2  message one
@@ -248,9 +232,7 @@ EOF
 '
 
 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 &&
+   git log --pretty="tformat:%>(1)%s" >actual &&
cat <expected &&
 message two
 message one
@@ -261,9 +243,7 @@ EOF
 '
 
 test_expect_success 'center alignment formatting' '
-   git log --pretty="format:%><(40)%s" >actual &&
-   # complete the incomplete line at the end
-   echo >>actual &&
+   git log --pretty="tformat:%><(40)%s" >actual &&
qz_to_tab_space <expect

[PATCH v4 4/5] t4205, t6006: Add failing tests for the case when i18n.logOutputEncoding is set

2014-05-21 Thread Alexey Shumkin
Pretty format string %<(N,[ml]trunc)>%s truncates subject to a given
length with an appropriate padding. This works for non-ASCII texts when
i18n.logOutputEncoding is UTF-8 only (independently of a printed commit
message encoding) but does not work when i18n.logOutputEncoding is NOT
UTF-8.

There were no breakages as far as were no tests for the case
when both a commit message and logOutputEncoding are not UTF-8.

Add failing tests for that which will be fixed in the next patch.

Signed-off-by: Alexey Shumkin 
Reviewed-by: Nguyễn Thái Ngọc Duy 
Reviewed-by: Ramsay Jones 
---
 t/t4205-log-pretty-formats.sh | 140 ++
 t/t6006-rev-list-format.sh|  75 +-
 2 files changed, 213 insertions(+), 2 deletions(-)

diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index c03a65e..74babce 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -154,6 +154,17 @@ EOF
test_cmp expected actual
 '
 
+test_expect_success 'left alignment formatting. i18n.logOutputEncoding' '
+   git -c i18n.logOutputEncoding=$test_encoding log 
--pretty="tformat:%<(40)%s" >actual &&
+   qz_to_tab_space <expected &&
+message twoZ
+message oneZ
+add barZ
+$(commit_msg)Z
+EOF
+   test_cmp expected actual
+'
+
 test_expect_success 'left alignment formatting at the nth column' '
git log --pretty="tformat:%h %<|(40)%s" >actual &&
qz_to_tab_space <expected &&
@@ -165,6 +176,17 @@ EOF
test_cmp expected actual
 '
 
+test_expect_success 'left alignment formatting at the nth column. 
i18n.logOutputEncoding' '
+   git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h 
%<|(40)%s" >actual &&
+   qz_to_tab_space <expected &&
+$head1 message twoZ
+$head2 message oneZ
+$head3 add barZ
+$head4 $(commit_msg)Z
+EOF
+   test_cmp expected actual
+'
+
 test_expect_success 'left alignment formatting with no padding' '
git log --pretty="tformat:%<(1)%s" >actual &&
cat <expected &&
@@ -176,6 +198,17 @@ EOF
test_cmp expected actual
 '
 
+test_expect_success 'left alignment formatting with no padding. 
i18n.logOutputEncoding' '
+   git -c i18n.logOutputEncoding=$test_encoding log 
--pretty="tformat:%<(1)%s" >actual &&
+   cat <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="tformat:%<(10,trunc)%s" >actual &&
qz_to_tab_space <expected &&
@@ -187,6 +220,17 @@ EOF
test_cmp expected actual
 '
 
+test_expect_failure 'left alignment formatting with trunc. 
i18n.logOutputEncoding' '
+   git -c i18n.logOutputEncoding=$test_encoding log 
--pretty="tformat:%<(10,trunc)%s" >actual &&
+   qz_to_tab_space <expected &&
+message ..
+message ..
+add bar  Z
+initial...
+EOF
+   test_cmp expected actual
+'
+
 test_expect_success 'left alignment formatting with ltrunc' '
git log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
qz_to_tab_space <expected &&
@@ -198,6 +242,17 @@ EOF
test_cmp expected actual
 '
 
+test_expect_failure 'left alignment formatting with ltrunc. 
i18n.logOutputEncoding' '
+   git -c i18n.logOutputEncoding=$test_encoding log 
--pretty="tformat:%<(10,ltrunc)%s" >actual &&
+   qz_to_tab_space <expected &&
+..sage two
+..sage one
+add bar  Z
+..${sample_utf8_part}lich
+EOF
+   test_cmp expected actual
+'
+
 test_expect_success 'left alignment formatting with mtrunc' '
git log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
qz_to_tab_space <expected &&
@@ -209,6 +264,17 @@ EOF
test_cmp expected actual
 '
 
+test_expect_failure 'left alignment formatting with mtrunc. 
i18n.logOutputEncoding' '
+   git -c i18n.logOutputEncoding=$test_encoding log 
--pretty="tformat:%<(10,mtrunc)%s" >actual &&
+   qz_to_tab_space <expected &&
+mess.. two
+mess.. one
+add bar  Z
+init..lich
+EOF
+   test_cmp expected actual
+'
+
 test_expect_success 'right alignment formatting' '
git log --pretty="tformat:%>(40)%s" >act

[PATCH v4 0/5] Reroll patches. Pretty print truncate does not work

2014-05-21 Thread Alexey Shumkin
This version (v4) differs from the previuos (v3):
1. Fixed typo ISO8895-1 (vs ISO8859-1)
2. Fixed t4205 test: tested format strings are double-quoted

Alexey Shumkin (5):
  t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
  t4041, t4205, t6006, t7102: Don't hardcode tested encoding value
  t4205 (log-pretty-format): Use `tformat` rather than `format`
  t4205, t6006: Add failing tests for the case when
i18n.logOutputEncoding is set
  pretty.c: format string with truncate respects logOutputEncoding

 pretty.c |   7 +-
 t/t4041-diff-submodule-option.sh |   7 +-
 t/t4205-log-pretty-formats.sh| 217 ++-
 t/t6006-rev-list-format.sh   | 110 
 t/t7102-reset.sh |  13 ++-
 5 files changed, 282 insertions(+), 72 deletions(-)

-- 
1.9.2-15

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 1/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs

2014-05-21 Thread Alexey Shumkin
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

That was introduced in a742f2a (t4205 (log-pretty-formats): don't
hardcode SHA-1 in expected outputs, 2013-06-26) but unfortunately was
not followed in 5e1361c (log: properly handle decorations with chained
tags, 2013-12-17)

Signed-off-by: Alexey Shumkin 
---
 t/t4205-log-pretty-formats.sh | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 2a6278b..f9f33ae 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -296,6 +296,10 @@ EOF
test_cmp expected actual
 '
 
+# save HEAD's SHA-1 digest (with no abbreviations) to use it below
+# as far as the next test amends HEAD
+old_head1=$(git rev-parse --verify HEAD~0)
+
 test_expect_success 'left/right alignment formatting with stealing' '
git commit --amend -m short --author "long long long " &&
git log --pretty="format:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
@@ -310,6 +314,10 @@ EOF
test_cmp expected actual
 '
 
+# get new digests (with no abbreviations)
+head1=$(git rev-parse --verify HEAD~0) &&
+head2=$(git rev-parse --verify HEAD~1) &&
+
 test_expect_success 'log decoration properly follows tag chain' '
git tag -a tag1 -m tag1 &&
git tag -a tag2 -m tag2 tag1 &&
@@ -317,9 +325,9 @@ test_expect_success 'log decoration properly follows tag 
chain' '
git commit --amend -m shorter &&
git log --no-walk --tags --pretty="%H %d" --decorate=full >actual &&
cat <expected &&
-6a908c10688b2503073c39c9ba26322c73902bb5  (tag: refs/tags/tag2)
-9f716384d92283fb915a4eee5073f030638e05f9  (tag: refs/tags/message-one)
-b87e4cccdb77336ea79d89224737be7ea8e95367  (tag: refs/tags/message-two)
+$head1  (tag: refs/tags/tag2)
+$head2  (tag: refs/tags/message-one)
+$old_head1  (tag: refs/tags/message-two)
 EOF
sort actual >actual1 &&
test_cmp expected actual1
-- 
1.9.2-15

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] t6006 (rev-list-format): quote format strings to avoid error on some shells

2014-05-21 Thread Alexey Shumkin
This patch is redundant then.
It will be squashed into next patch series.

On Tue, May 20, 2014 at 06:48:43PM +0400, Alexey Shumkin wrote:
> Added in 0a144b3 (t4205, t6006: add failing tests for the case when
> i18n.logOutputEncoding is set, 2014-05-19) tests give no error
> (somehow) with Bash as /bin/sh but fail for some other shells.
> 
> Quote format strings to avoid errors.
> 
> Signed-off-by: Alexey Shumkin 
> Suggested-by: Ramsay Jones 
> ---
>  t/t6006-rev-list-format.sh | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
> index c6e9a73..19434ad 100755
> --- a/t/t6006-rev-list-format.sh
> +++ b/t/t6006-rev-list-format.sh
> @@ -149,7 +149,7 @@ commit $head1
>  $added
>  EOF
>  
> -test_format subject-truncated %<($truncate_count,trunc)%s < +test_format subject-truncated "%<($truncate_count,trunc)%s" <  commit $head2
>  changed (ge${changed_utf8_part}ndert)..
>  commit $head1
> @@ -259,7 +259,7 @@ commit $head1
>  $added_iso88591
>  EOF
>  
> -test_format complex-subject-trunc %<($truncate_count,trunc)%s < +test_format complex-subject-trunc "%<($truncate_count,trunc)%s" <  commit $head3
>  Test printing of c..
>  commit $head2
> @@ -268,7 +268,7 @@ commit $head1
>  added (hinzugef${added_utf8_part_iso88591}gt..
>  EOF
>  
> -test_format complex-subject-mtrunc %<($truncate_count,mtrunc)%s < +test_format complex-subject-mtrunc "%<($truncate_count,mtrunc)%s" <  commit $head3
>  Test prin..ex bodies
>  commit $head2
> @@ -277,7 +277,7 @@ commit $head1
>  added (hi..f${added_utf8_part_iso88591}gt) foo
>  EOF
>  
> -test_format complex-subject-ltrunc %<($truncate_count,ltrunc)%s < +test_format complex-subject-ltrunc "%<($truncate_count,ltrunc)%s" <  commit $head3
>  .. of complex bodies
>  commit $head2
> @@ -314,7 +314,7 @@ commit $head1
>  $added
>  EOF
>  
> -test_format complex-subject-commitencoding-unset-trunc 
> %<($truncate_count,trunc)%s < +test_format complex-subject-commitencoding-unset-trunc 
> "%<($truncate_count,trunc)%s" <  commit $head3
>  Test printing of c..
>  commit $head2
> @@ -323,7 +323,7 @@ commit $head1
>  added (hinzugef${added_utf8_part}gt..
>  EOF
>  
> -test_format complex-subject-commitencoding-unset-mtrunc 
> %<($truncate_count,mtrunc)%s < +test_format complex-subject-commitencoding-unset-mtrunc 
> "%<($truncate_count,mtrunc)%s" <  commit $head3
>  Test prin..ex bodies
>  commit $head2
> @@ -332,7 +332,7 @@ commit $head1
>  added (hi..f${added_utf8_part}gt) foo
>  EOF
>  
> -test_format complex-subject-commitencoding-unset-ltrunc 
> %<($truncate_count,ltrunc)%s < +test_format complex-subject-commitencoding-unset-ltrunc 
> "%<($truncate_count,ltrunc)%s" <  commit $head3
>  .. of complex bodies
>  commit $head2
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] t6006-*.sh: Fix truncation tests

2014-05-20 Thread Alexey Shumkin
On Tue, May 20, 2014 at 10:10:46AM -0700, Junio C Hamano wrote:
> Alexey Shumkin  writes:
> 
> > AFAIU, Junio already applied my patches (existance of a branch
> > as/pretty-truncate tells us that). So, we can only send other patches that
> > fix errors brought with former patches.
> 
> No, NO, NO
> 
> The existence of a branch merely means that I saw the patches, and
> that I thought that the series was not completely useless.  In other
> words, it indicates that I wanted to make sure that I won't forget
> about the topic, and it was worth my time to create the branch and
> apply there for that purpose.
Oh, I got it!
I'll fix my typo (ISO8895-1 vs ISO8859-1) and quotes issue then.
And will reroll patches.

Thanks!
> 
> Please do not read anything more than that.  Presense of a topic
> branch by itself does not say that I _read_ the patches or I thought
> they did not need reroll.
> 
> When such a branch is merged to 'next', that means I read the
> patches myself, or I saw somebody whose judgement I and others in
> the community trust read them and gave a positive response or an
> Ack, and that I decided that the topic is in a good enough shape to
> be worked on further with incremental updates.
> 
> You are talking about the latter state, but as/pretty-truncate is in
> the former state.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] t6006-*.sh: Fix truncation tests

2014-05-20 Thread Alexey Shumkin
On Tue, May 20, 2014 at 04:01:22PM +0100, Ramsay Jones wrote:
> On 20/05/14 15:19, Alexey Shumkin wrote:
> > On Tue, May 20, 2014 at 02:54:20PM +0100, Ramsay Jones wrote:
> >>
> >> Signed-off-by: Ramsay Jones 
> >> ---
> >>
> >> Hi Alexey,
> >>
> >> If you need to re-roll your 'as/pretty-truncate' branch, could
> >> you please squash the relevant parts of this patch into the
> >> corresponding patches of your patch series. (ie this is a patch
> >> against the head of the current pu branch ...).
> >>
> >> Without this patch I get:
> >>
> >>   $ ./t6006-rev-list-format.sh
> >>   ok 1 - setup
> >>   ok 2 - format percent
> >>   ok 3 - format hash
> >>   ok 4 - format tree
> >>   ok 5 - format parents
> >>   ok 6 - format author
> >>   ok 7 - format committer
> >>   ok 8 - format encoding
> >>   ok 9 - format subject
> >>   ./t6006-rev-list-format.sh: 152: ./t6006-rev-list-format.sh: Syntax 
> >> error: "(" unexpected
> >>   FATAL: Unexpected exit with code 2
> >>   $ 
> > Ooops, my fault.
> >>
> >> (if you have bash as /bin/sh you get different but related errors).
> >> The additional quoting suppresses the 'command redirection' errors, etc...
> > It's strange but I do have Bash as /bin/sh and unfortunately I have no
> > this error
> 
> Hmm, I see this:
> 
>   $ bash t6006-rev-list-format.sh -i
AFAIK, this is not "running Bash as /bin/sh" :)
Maybe I'm wrong but Bash as /bin/sh is:
  $ ls -l /bin/sh
  lrwxrwxrwx 1 root root 4 May 12 18:35 /bin/sh -> bash

But it does not matter here much, you've noticed my foolish mistake :)
>   ok 1 - setup
>   ok 2 - format percent
>   ok 3 - format hash
>   ok 4 - format tree
>   ok 5 - format parents
>   ok 6 - format author
>   ok 7 - format committer
>   ok 8 - format encoding
>   ok 9 - format subject
>   t6006-rev-list-format.sh: line 152: 20,trunc: command not found
>   not ok 10 - format subject-truncated
>   #   
>   #   git rev-list --pretty=format:'%/dev/fd/63%s' master 
> >output.subject-truncated &&
>   #   test_cmp expect.subject-truncated 
> output.subject-truncated
>   #   
>   $ 
> 
> (Since I'm on Linux Mint, my /bin/sh is dash, which produces the output in my 
> previous mail).
> 
> ATB,
> Ramsay Jones
> 
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] t6006 (rev-list-format): quote format strings to avoid error on some shells

2014-05-20 Thread Alexey Shumkin
Added in 0a144b3 (t4205, t6006: add failing tests for the case when
i18n.logOutputEncoding is set, 2014-05-19) tests give no error
(somehow) with Bash as /bin/sh but fail for some other shells.

Quote format strings to avoid errors.

Signed-off-by: Alexey Shumkin 
Suggested-by: Ramsay Jones 
---
 t/t6006-rev-list-format.sh | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index c6e9a73..19434ad 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -149,7 +149,7 @@ commit $head1
 $added
 EOF
 
-test_format subject-truncated %<($truncate_count,trunc)%s <http://vger.kernel.org/majordomo-info.html


Re: [PATCH] t6006-*.sh: Fix truncation tests

2014-05-20 Thread Alexey Shumkin
On Tue, May 20, 2014 at 06:19:36PM +0400, Alexey Shumkin wrote:
> On Tue, May 20, 2014 at 02:54:20PM +0100, Ramsay Jones wrote:
> > 
> > Signed-off-by: Ramsay Jones 
> > ---
> > 
> > Hi Alexey,
> > 
> > If you need to re-roll your 'as/pretty-truncate' branch, could
> > you please squash the relevant parts of this patch into the
> > corresponding patches of your patch series. (ie this is a patch
> > against the head of the current pu branch ...).
> > 
> > Without this patch I get:
> > 
> >   $ ./t6006-rev-list-format.sh
> >   ok 1 - setup
> >   ok 2 - format percent
> >   ok 3 - format hash
> >   ok 4 - format tree
> >   ok 5 - format parents
> >   ok 6 - format author
> >   ok 7 - format committer
> >   ok 8 - format encoding
> >   ok 9 - format subject
> >   ./t6006-rev-list-format.sh: 152: ./t6006-rev-list-format.sh: Syntax 
> > error: "(" unexpected
> >   FATAL: Unexpected exit with code 2
> >   $ 
> Ooops, my fault.
> > 
> > (if you have bash as /bin/sh you get different but related errors).
> > The additional quoting suppresses the 'command redirection' errors, etc...
> It's strange but I do have Bash as /bin/sh and unfortunately I have no
> this error
> 
> AFAIU, Junio already applied my patches (existance of a branch
> as/pretty-truncate tells us that). So, we can only send other patches that
> fix errors brought with former patches.
> You can send, too.
> > 
> > Thanks.
> > 
> > ATB
> > Ramsay Jones
> > 
> >  t/t6006-rev-list-format.sh | 14 +++---
> >  1 file changed, 7 insertions(+), 7 deletions(-)
> > 
> > diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
> > index 9bc089b..e1dec3e 100755
> > --- a/t/t6006-rev-list-format.sh
> > +++ b/t/t6006-rev-list-format.sh
> > @@ -149,7 +149,7 @@ commit $head1
> >  $added
> >  EOF
> >  
> > -test_format subject-truncated %<($truncate_count,trunc)%s < > +test_format subject-truncated %\<\($truncate_count,trunc\)%s <http://vger.kernel.org/majordomo-info.html


Re: [PATCH] t6006-*.sh: Fix truncation tests

2014-05-20 Thread Alexey Shumkin
On Tue, May 20, 2014 at 02:54:20PM +0100, Ramsay Jones wrote:
> 
> Signed-off-by: Ramsay Jones 
> ---
> 
> Hi Alexey,
> 
> If you need to re-roll your 'as/pretty-truncate' branch, could
> you please squash the relevant parts of this patch into the
> corresponding patches of your patch series. (ie this is a patch
> against the head of the current pu branch ...).
> 
> Without this patch I get:
> 
>   $ ./t6006-rev-list-format.sh
>   ok 1 - setup
>   ok 2 - format percent
>   ok 3 - format hash
>   ok 4 - format tree
>   ok 5 - format parents
>   ok 6 - format author
>   ok 7 - format committer
>   ok 8 - format encoding
>   ok 9 - format subject
>   ./t6006-rev-list-format.sh: 152: ./t6006-rev-list-format.sh: Syntax error: 
> "(" unexpected
>   FATAL: Unexpected exit with code 2
>   $ 
Ooops, my fault.
> 
> (if you have bash as /bin/sh you get different but related errors).
> The additional quoting suppresses the 'command redirection' errors, etc...
It's strange but I do have Bash as /bin/sh and unfortunately I have no
this error

AFAIU, Junio already applied my patches (existance of a branch
as/pretty-truncate tells us that). So, we can only send other patches that
fix errors brought with former patches.
You can send, too.
> 
> Thanks.
> 
> ATB
> Ramsay Jones
> 
>  t/t6006-rev-list-format.sh | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
> index 9bc089b..e1dec3e 100755
> --- a/t/t6006-rev-list-format.sh
> +++ b/t/t6006-rev-list-format.sh
> @@ -149,7 +149,7 @@ commit $head1
>  $added
>  EOF
>  
> -test_format subject-truncated %<($truncate_count,trunc)%s < +test_format subject-truncated %\<\($truncate_count,trunc\)%s <  commit $head2
>  changed (ge${changed_utf8_part}ndert)..
>  commit $head1
> @@ -256,7 +256,7 @@ commit $head1
>  $added_iso88591
>  EOF
>  
> -test_format complex-subject-trunc %<($truncate_count,trunc)%s < +test_format complex-subject-trunc %\<\($truncate_count,trunc\)%s <  commit $head3
>  Test printing of c..
>  commit $head2
> @@ -265,7 +265,7 @@ commit $head1
>  added (hinzugef${added_utf8_part_iso88591}gt..
>  EOF
>  
> -test_format complex-subject-mtrunc %<($truncate_count,mtrunc)%s < +test_format complex-subject-mtrunc %\<\($truncate_count,mtrunc\)%s <  commit $head3
>  Test prin..ex bodies
>  commit $head2
> @@ -274,7 +274,7 @@ commit $head1
>  added (hi..f${added_utf8_part_iso88591}gt) foo
>  EOF
>  
> -test_format complex-subject-ltrunc %<($truncate_count,ltrunc)%s < +test_format complex-subject-ltrunc %\<\($truncate_count,ltrunc\)%s <  commit $head3
>  .. of complex bodies
>  commit $head2
> @@ -311,7 +311,7 @@ commit $head1
>  $added
>  EOF
>  
> -test_format complex-subject-commitencoding-unset-trunc 
> %<($truncate_count,trunc)%s < +test_format complex-subject-commitencoding-unset-trunc 
> %\<\($truncate_count,trunc\)%s <  commit $head3
>  Test printing of c..
>  commit $head2
> @@ -320,7 +320,7 @@ commit $head1
>  added (hinzugef${added_utf8_part}gt..
>  EOF
>  
> -test_format complex-subject-commitencoding-unset-mtrunc 
> %<($truncate_count,mtrunc)%s < +test_format complex-subject-commitencoding-unset-mtrunc 
> %\<\($truncate_count,mtrunc\)%s <  commit $head3
>  Test prin..ex bodies
>  commit $head2
> @@ -329,7 +329,7 @@ commit $head1
>  added (hi..f${added_utf8_part}gt) foo
>  EOF
>  
> -test_format complex-subject-commitencoding-unset-ltrunc 
> %<($truncate_count,ltrunc)%s < +test_format complex-subject-commitencoding-unset-ltrunc 
> %\<\($truncate_count,ltrunc\)%s <  commit $head3
>  .. of complex bodies
>  commit $head2
> -- 
> 1.9.0

-- 
Alexey Shumkin
E-mail: alex.crez...@gmail.com
ICQ: 118001447
Jabber (GoogleTalk): alex.crez...@gmail.com
Skype: crezoff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 2/5] t4041, t4205, t6006, t7102: Don't hardcode tested encoding value

2014-05-19 Thread Alexey Shumkin
On Tue, May 20, 2014 at 01:49:31AM +, brian m. carlson wrote:
> On Mon, May 19, 2014 at 07:28:17PM +0400, Alexey Shumkin wrote:
> > The tested encoding is always available in a variable. Use it instead of
> > hardcoding. Also, to be in line with other tests use ISO8859-1
> > (uppercase) rather then iso8895-1.
> 
> You wrote "iso8895" when I think you meant "iso8859".
Oops!
Yes, you're right, I've meant iso8859.
> 
> -- 
> brian m. carlson / brian with sandals: Houston, Texas, US
> +1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only
> OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187



-- 
Alexey Shumkin
E-mail: alex.crez...@gmail.com
ICQ: 118001447
Jabber (GoogleTalk): alex.crez...@gmail.com
Skype: crezoff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 3/5] t4205 (log-pretty-format): Use `tformat` rather than `format`

2014-05-19 Thread Alexey Shumkin
Use `tformat` to avoid using of `echo` to complete end of line.

Signed-off-by: Alexey Shumkin 
---
 t/t4205-log-pretty-formats.sh | 52 +++
 1 file changed, 13 insertions(+), 39 deletions(-)

diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index f5ea3f8..c03a65e 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -144,9 +144,7 @@ test_expect_success 'setup more commits' '
 '
 
 test_expect_success 'left alignment formatting' '
-   git log --pretty="format:%<(40)%s" >actual &&
-   # complete the incomplete line at the end
-   echo >>actual &&
+   git log --pretty="tformat:%<(40)%s" >actual &&
qz_to_tab_space <expected &&
 message twoZ
 message oneZ
@@ -157,9 +155,7 @@ EOF
 '
 
 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 &&
+   git log --pretty="tformat:%h %<|(40)%s" >actual &&
qz_to_tab_space <expected &&
 $head1 message twoZ
 $head2 message oneZ
@@ -170,9 +166,7 @@ EOF
 '
 
 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 &&
+   git log --pretty="tformat:%<(1)%s" >actual &&
cat <expected &&
 message two
 message one
@@ -183,9 +177,7 @@ EOF
 '
 
 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 &&
+   git log --pretty="tformat:%<(10,trunc)%s" >actual &&
qz_to_tab_space <expected &&
 message ..
 message ..
@@ -196,9 +188,7 @@ EOF
 '
 
 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 &&
+   git log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
qz_to_tab_space <expected &&
 ..sage two
 ..sage one
@@ -209,9 +199,7 @@ EOF
 '
 
 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 &&
+   git log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
qz_to_tab_space <expected &&
 mess.. two
 mess.. one
@@ -222,9 +210,7 @@ EOF
 '
 
 test_expect_success 'right alignment formatting' '
-   git log --pretty="format:%>(40)%s" >actual &&
-   # complete the incomplete line at the end
-   echo >>actual &&
+   git log --pretty="tformat:%>(40)%s" >actual &&
qz_to_tab_space <expected &&
 Zmessage two
 Zmessage one
@@ -235,9 +221,7 @@ EOF
 '
 
 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 &&
+   git log --pretty="tformat:%h %>|(40)%s" >actual &&
qz_to_tab_space <expected &&
 $head1  message two
 $head2  message one
@@ -248,9 +232,7 @@ EOF
 '
 
 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 &&
+   git log --pretty="tformat:%>(1)%s" >actual &&
cat <expected &&
 message two
 message one
@@ -261,9 +243,7 @@ EOF
 '
 
 test_expect_success 'center alignment formatting' '
-   git log --pretty="format:%><(40)%s" >actual &&
-   # complete the incomplete line at the end
-   echo >>actual &&
+   git log --pretty="tformat:%><(40)%s" >actual &&
qz_to_tab_space <expect

[PATCH v3 5/5] pretty.c: format string with truncate respects logOutputEncoding

2014-05-19 Thread Alexey Shumkin
Pretty format string %<(N,[ml]trunc)>%s truncates subject to a given
length with an appropriate padding. This works for non-ASCII texts when
i18n.logOutputEncoding is UTF-8 only (independently of a printed commit
message encoding) but does not work when i18n.logOutputEncoding is NOT
UTF-8.

In 7e77df3 (pretty: two phase conversion for non utf-8 commits, 2013-04-19)
'format_commit_item' function assumes commit message to be in UTF-8.
And that was so until ecaee80 (pretty: --format output should honor
logOutputEncoding, 2013-06-26) where conversion to logOutputEncoding was
added before calling 'format_commit_message'.

Correct this by converting a commit message to UTF-8 first (as it
assumed in 7e77df3 (pretty: two phase conversion for non utf-8 commits,
2013-04-19)). Only after that convert a commit message to an actual
logOutputEncoding.

Signed-off-by: Alexey Shumkin 
Reviewed-by: Nguyễn Thái Ngọc Duy 
---
 pretty.c  | 7 ++-
 t/t4205-log-pretty-formats.sh | 8 
 t/t6006-rev-list-format.sh| 6 +++---
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/pretty.c b/pretty.c
index 6e266dd..25e8825 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1507,13 +1507,18 @@ void format_commit_message(const struct commit *commit,
context.commit = commit;
context.pretty_ctx = pretty_ctx;
context.wrap_start = sb->len;
+   /*
+* convert a commit message to UTF-8 first
+* as far as 'format_commit_item' assumes it in UTF-8
+*/
context.message = logmsg_reencode(commit,
  &context.commit_encoding,
- output_enc);
+ utf8);
 
strbuf_expand(sb, format, format_commit_item, &context);
rewrap_message_tail(sb, &context, 0, 0, 0);
 
+   /* then convert a commit message to an actual output encoding */
if (output_enc) {
if (same_encoding(utf8, output_enc))
output_enc = NULL;
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 74babce..c84ec9a 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -220,7 +220,7 @@ EOF
test_cmp expected actual
 '
 
-test_expect_failure 'left alignment formatting with trunc. 
i18n.logOutputEncoding' '
+test_expect_success 'left alignment formatting with trunc. 
i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log 
--pretty="tformat:%<(10,trunc)%s" >actual &&
qz_to_tab_space <expected &&
 message ..
@@ -242,7 +242,7 @@ EOF
test_cmp expected actual
 '
 
-test_expect_failure 'left alignment formatting with ltrunc. 
i18n.logOutputEncoding' '
+test_expect_success 'left alignment formatting with ltrunc. 
i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log 
--pretty="tformat:%<(10,ltrunc)%s" >actual &&
qz_to_tab_space <expected &&
 ..sage two
@@ -264,7 +264,7 @@ EOF
test_cmp expected actual
 '
 
-test_expect_failure 'left alignment formatting with mtrunc. 
i18n.logOutputEncoding' '
+test_expect_success 'left alignment formatting with mtrunc. 
i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log 
--pretty="tformat:%<(10,mtrunc)%s" >actual &&
qz_to_tab_space <expected &&
 mess.. two
@@ -420,7 +420,7 @@ initial...   A U Thor
 EOF
test_cmp expected actual
 '
-test_expect_failure 'left/right alignment formatting with stealing. 
i18n.logOutputEncoding' '
+test_expect_success 'left/right alignment formatting with stealing. 
i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log 
--pretty="tformat:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
cat <expected &&
 short long  long long
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index a932f34..c6e9a73 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -259,7 +259,7 @@ commit $head1
 $added_iso88591
 EOF
 
-test_format complex-subject-trunc %<($truncate_count,trunc)%s failure <http://vger.kernel.org/majordomo-info.html


[PATCH v3 4/5] t4205, t6006: Add failing tests for the case when i18n.logOutputEncoding is set

2014-05-19 Thread Alexey Shumkin
Pretty format string %<(N,[ml]trunc)>%s truncates subject to a given
length with an appropriate padding. This works for non-ASCII texts when
i18n.logOutputEncoding is UTF-8 only (independently of a printed commit
message encoding) but does not work when i18n.logOutputEncoding is NOT
UTF-8.

There were no breakages as far as were no tests for the case
when both a commit message and logOutputEncoding are not UTF-8.

Add failing tests for that which will be fixed in the next patch.

Signed-off-by: Alexey Shumkin 
Reviewed-by: Nguyễn Thái Ngọc Duy 
---
 t/t4205-log-pretty-formats.sh | 140 ++
 t/t6006-rev-list-format.sh|  75 +-
 2 files changed, 213 insertions(+), 2 deletions(-)

diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index c03a65e..74babce 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -154,6 +154,17 @@ EOF
test_cmp expected actual
 '
 
+test_expect_success 'left alignment formatting. i18n.logOutputEncoding' '
+   git -c i18n.logOutputEncoding=$test_encoding log 
--pretty="tformat:%<(40)%s" >actual &&
+   qz_to_tab_space <expected &&
+message twoZ
+message oneZ
+add barZ
+$(commit_msg)Z
+EOF
+   test_cmp expected actual
+'
+
 test_expect_success 'left alignment formatting at the nth column' '
git log --pretty="tformat:%h %<|(40)%s" >actual &&
qz_to_tab_space <expected &&
@@ -165,6 +176,17 @@ EOF
test_cmp expected actual
 '
 
+test_expect_success 'left alignment formatting at the nth column. 
i18n.logOutputEncoding' '
+   git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h 
%<|(40)%s" >actual &&
+   qz_to_tab_space <expected &&
+$head1 message twoZ
+$head2 message oneZ
+$head3 add barZ
+$head4 $(commit_msg)Z
+EOF
+   test_cmp expected actual
+'
+
 test_expect_success 'left alignment formatting with no padding' '
git log --pretty="tformat:%<(1)%s" >actual &&
cat <expected &&
@@ -176,6 +198,17 @@ EOF
test_cmp expected actual
 '
 
+test_expect_success 'left alignment formatting with no padding. 
i18n.logOutputEncoding' '
+   git -c i18n.logOutputEncoding=$test_encoding log 
--pretty="tformat:%<(1)%s" >actual &&
+   cat <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="tformat:%<(10,trunc)%s" >actual &&
qz_to_tab_space <expected &&
@@ -187,6 +220,17 @@ EOF
test_cmp expected actual
 '
 
+test_expect_failure 'left alignment formatting with trunc. 
i18n.logOutputEncoding' '
+   git -c i18n.logOutputEncoding=$test_encoding log 
--pretty="tformat:%<(10,trunc)%s" >actual &&
+   qz_to_tab_space <expected &&
+message ..
+message ..
+add bar  Z
+initial...
+EOF
+   test_cmp expected actual
+'
+
 test_expect_success 'left alignment formatting with ltrunc' '
git log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
qz_to_tab_space <expected &&
@@ -198,6 +242,17 @@ EOF
test_cmp expected actual
 '
 
+test_expect_failure 'left alignment formatting with ltrunc. 
i18n.logOutputEncoding' '
+   git -c i18n.logOutputEncoding=$test_encoding log 
--pretty="tformat:%<(10,ltrunc)%s" >actual &&
+   qz_to_tab_space <expected &&
+..sage two
+..sage one
+add bar  Z
+..${sample_utf8_part}lich
+EOF
+   test_cmp expected actual
+'
+
 test_expect_success 'left alignment formatting with mtrunc' '
git log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
qz_to_tab_space <expected &&
@@ -209,6 +264,17 @@ EOF
test_cmp expected actual
 '
 
+test_expect_failure 'left alignment formatting with mtrunc. 
i18n.logOutputEncoding' '
+   git -c i18n.logOutputEncoding=$test_encoding log 
--pretty="tformat:%<(10,mtrunc)%s" >actual &&
+   qz_to_tab_space <expected &&
+mess.. two
+mess.. one
+add bar  Z
+init..lich
+EOF
+   test_cmp expected actual
+'
+
 test_expect_success 'right alignment formatting' '
git log --pretty="tformat:%>(40)%s" >actual &&
qz_t

[PATCH v3 2/5] t4041, t4205, t6006, t7102: Don't hardcode tested encoding value

2014-05-19 Thread Alexey Shumkin
The tested encoding is always available in a variable. Use it instead of
hardcoding. Also, to be in line with other tests use ISO8859-1
(uppercase) rather then iso8895-1.

Signed-off-by: Alexey Shumkin 
---
 t/t4041-diff-submodule-option.sh |  7 +--
 t/t4205-log-pretty-formats.sh| 11 +++
 t/t6006-rev-list-format.sh   | 35 +++
 t/t7102-reset.sh | 13 -
 4 files changed, 39 insertions(+), 27 deletions(-)

diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 1751c83..463d63b 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -11,6 +11,9 @@ This test tries to verify the sanity of the --submodule 
option of git diff.
 
 . ./test-lib.sh
 
+# Tested non-UTF-8 encoding
+test_encoding="ISO8859-1"
+
 # 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")
@@ -23,8 +26,8 @@ add_file () {
echo "$name" >"$name" &&
git add "$name" &&
test_tick &&
-   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"
+   msg_added_iso88591=$(echo "Add $name ($added $name)" | 
iconv -f utf-8 -t $test_encoding) &&
+   git -c "i18n.commitEncoding=$test_encoding" 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 f9f33ae..f5ea3f8 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -7,6 +7,9 @@
 test_description='Test pretty formats'
 . ./test-lib.sh
 
+# Tested non-UTF-8 encoding
+test_encoding="ISO8859-1"
+
 sample_utf8_part=$(printf "f\303\244ng")
 
 commit_msg () {
@@ -27,8 +30,8 @@ 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)" &&
+   git config i18n.commitEncoding $test_encoding &&
+   git commit -m "$(commit_msg $test_encoding)" &&
git add bar &&
test_tick &&
git commit -m "add bar" &&
@@ -56,8 +59,8 @@ 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 &&
+test_expect_success 'alias user-defined tformat with %s (ISO8859-1 encoding)' '
+   git config i18n.logOutputEncoding $test_encoding &&
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 9874403..9e4ba62 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -9,19 +9,22 @@ test_description='git rev-list --pretty=format test'
 . "$TEST_DIRECTORY"/lib-terminal.sh
 
 test_tick
+# Tested non-UTF-8 encoding
+test_encoding="ISO8859-1"
+
 # 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)
+added_iso88591=$(echo "$added" | iconv -f utf-8 -t $test_encoding)
 # same but "changed"
 changed=$(printf "changed (ge\303\244ndert) foo")
-changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t iso8859-1)
+changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t $test_encoding)
 
 test_expect_success 'setup' '
: >foo &&
git add foo &&
-   git config i18n.commitEncoding iso8859-1 &&
+   git config i18n.commitEncoding $test_encoding &&
git commit -m "$added_iso88591" &&
head1=$(git rev-parse --verify HEAD) &&
head1_short=$(git rev-parse --verify --short $head1) &&
@@ -124,9 +127,9 @@ EOF
 
 test_format encoding %e < commit-msg < commit-msg <foo && git commit -a -F c

[PATCH v3 1/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs

2014-05-19 Thread Alexey Shumkin
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

That was introduced in a742f2a (t4205 (log-pretty-formats): don't
hardcode SHA-1 in expected outputs, 2013-06-26) but unfortunately was
not followed in 5e1361c (log: properly handle decorations with chained
tags, 2013-12-17)

Signed-off-by: Alexey Shumkin 
---
 t/t4205-log-pretty-formats.sh | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 2a6278b..f9f33ae 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -296,6 +296,10 @@ EOF
test_cmp expected actual
 '
 
+# save HEAD's SHA-1 digest (with no abbreviations) to use it below
+# as far as the next test amends HEAD
+old_head1=$(git rev-parse --verify HEAD~0)
+
 test_expect_success 'left/right alignment formatting with stealing' '
git commit --amend -m short --author "long long long " &&
git log --pretty="format:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
@@ -310,6 +314,10 @@ EOF
test_cmp expected actual
 '
 
+# get new digests (with no abbreviations)
+head1=$(git rev-parse --verify HEAD~0) &&
+head2=$(git rev-parse --verify HEAD~1) &&
+
 test_expect_success 'log decoration properly follows tag chain' '
git tag -a tag1 -m tag1 &&
git tag -a tag2 -m tag2 tag1 &&
@@ -317,9 +325,9 @@ test_expect_success 'log decoration properly follows tag 
chain' '
git commit --amend -m shorter &&
git log --no-walk --tags --pretty="%H %d" --decorate=full >actual &&
cat <expected &&
-6a908c10688b2503073c39c9ba26322c73902bb5  (tag: refs/tags/tag2)
-9f716384d92283fb915a4eee5073f030638e05f9  (tag: refs/tags/message-one)
-b87e4cccdb77336ea79d89224737be7ea8e95367  (tag: refs/tags/message-two)
+$head1  (tag: refs/tags/tag2)
+$head2  (tag: refs/tags/message-one)
+$old_head1  (tag: refs/tags/message-two)
 EOF
sort actual >actual1 &&
test_cmp expected actual1
-- 
1.9.2-15

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 0/5] Reroll patches. Pretty print truncate does not work

2014-05-19 Thread Alexey Shumkin
This patch series differs from the previous (v2) version in the following:
t4205 refactored: hardcoded SHA-1 digests replaced with variabled
Tested encoding `iso8859-1` replaced with variable (and uppercased to be in line
  in other tests)
Usage of `format` + `echo` replaced with `tformat`

brian m. carlson  CCed as he committed 5e1361c
(log: properly handle decorations with chained tags, 2013-12-17)

Alexey Shumkin (5):
  t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs
  t4041, t4205, t6006, t7102: Don't hardcode tested encoding value
  t4205 (log-pretty-format): Use `tformat` rather than `format`
  t4205, t6006: Add failing tests for the case when
i18n.logOutputEncoding is set
  pretty.c: format string with truncate respects logOutputEncoding

 pretty.c |   7 +-
 t/t4041-diff-submodule-option.sh |   7 +-
 t/t4205-log-pretty-formats.sh| 217 ++-
 t/t6006-rev-list-format.sh   | 110 
 t/t7102-reset.sh |  13 ++-
 5 files changed, 282 insertions(+), 72 deletions(-)

-- 
1.9.2-15
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/2] t4205, t6006: Add failing tests for the case when i18n.logOutputEncoding is set

2014-05-17 Thread Alexey Shumkin
On Fri, May 16, 2014 at 11:49:40AM -0700, Junio C Hamano wrote:
> Alexey Shumkin  writes:
> 
> > Pretty format string %<(N,[ml]trunc)>%s truncates subject to a given
> > length with an appropriate padding. This works for non-ASCII texts when
> > i18n.logOutputEncoding is UTF-8 only (independently of a printed commit
> > message encoding) but does not work when i18n.logOutputEncoding is NOT
> > UTF-8.
> >
> > There were no breakages as far as were no tests for the case
> > when both a commit message and logOutputEncoding are not UTF-8.
> >
> > Add failing tests for that which will be fixed in the next patch.
> >
> > Signed-off-by: Alexey Shumkin 
> > Reviewed-by: Nguyễn Thái Ngọc Duy 
> > ---
> >  t/t4205-log-pretty-formats.sh | 169 
> > ++
> >  t/t6006-rev-list-format.sh|  75 ++-
> >  2 files changed, 242 insertions(+), 2 deletions(-)
> >
> > diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
> > index 2a6278b..6791e0d 100755
> > --- a/t/t4205-log-pretty-formats.sh
> > +++ b/t/t4205-log-pretty-formats.sh
> > @@ -153,6 +153,19 @@ EOF
> > test_cmp expected actual
> >  '
> >  
> > +test_expect_success 'left alignment formatting. i18n.logOutputEncoding' '
> > +   git -c i18n.logOutputEncoding=iso8859-1 log --pretty="format:%<(40)%s" 
> > >actual &&
> > +   # complete the incomplete line at the end
> > +   echo >>actual &&
> 
> Would it change the meaning of the test if you used tformat: instead
> of format: (or --format="%<(40)%s")?  If it doesn't, it would make
> it unnecessary to append an extra LF and explain why you do so.
Well, actually, I just copied previous tests and added
i18n.logOutputEncoding.

But as I can see in the code - no, tformat will not change the meaning.
so, may be there is a reason to change that (initial) tests from format
to tformat first? And then add mine new.
> 
> > +   qz_to_tab_space <expected &&
> 
> It is minor but many existing uses of iconv in our tests spell these
> as UTF-8 and ISO8859-1 in uppercase.  I vaguely recall there was a
> portability concern to favor the ones that are used in existing
> tests, but probably it no longer matters (I see you added the
> lowercase one with de6029a2 mid last year), so I am fine if these
> stay lowercase.
I've grep'ed for lowercase iso8859-1 in test, and found almost all of
them is code added by me.
Grep for uppercase gives more results. I can refactor that first for
uniformity.
> 
> > +   git -c i18n.logOutputEncoding=iso8859-1 log --pretty="format:%<(1)%s" 
> > >actual &&
> > +   # complete the incomplete line at the end
> > +   echo >>actual &&
> 
> Likewise for all the other "--pretty=format:" followed by an echo.
the same copy-paste-modify.

> 
> Thanks.

-- 
Alexey Shumkin
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/2] pretty.c: format string with truncate respects logOutputEncoding

2014-05-16 Thread Alexey Shumkin
Pretty format string %<(N,[ml]trunc)>%s truncates subject to a given
length with an appropriate padding. This works for non-ASCII texts when
i18n.logOutputEncoding is UTF-8 only (independently of a printed commit
message encoding) but does not work when i18n.logOutputEncoding is NOT
UTF-8.

In 7e77df3 (pretty: two phase conversion for non utf-8 commits, 2013-04-19)
'format_commit_item' function assumes commit message to be in UTF-8.
And that was so until ecaee80 (pretty: --format output should honor
logOutputEncoding, 2013-06-26) where conversion to logOutputEncoding was
added before calling 'format_commit_message'.

Correct this by converting a commit message to UTF-8 first (as it
assumed in 7e77df3 (pretty: two phase conversion for non utf-8 commits,
2013-04-19)). Only after that convert a commit message to an actual
logOutputEncoding.

Signed-off-by: Alexey Shumkin 
Reviewed-by: Nguyễn Thái Ngọc Duy 
---
 pretty.c  | 7 ++-
 t/t4205-log-pretty-formats.sh | 8 
 t/t6006-rev-list-format.sh| 6 +++---
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/pretty.c b/pretty.c
index 6e266dd..25e8825 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1507,13 +1507,18 @@ void format_commit_message(const struct commit *commit,
context.commit = commit;
context.pretty_ctx = pretty_ctx;
context.wrap_start = sb->len;
+   /*
+* convert a commit message to UTF-8 first
+* as far as 'format_commit_item' assumes it in UTF-8
+*/
context.message = logmsg_reencode(commit,
  &context.commit_encoding,
- output_enc);
+ utf8);
 
strbuf_expand(sb, format, format_commit_item, &context);
rewrap_message_tail(sb, &context, 0, 0, 0);
 
+   /* then convert a commit message to an actual output encoding */
if (output_enc) {
if (same_encoding(utf8, output_enc))
output_enc = NULL;
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 6791e0d..7426fe2 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -231,7 +231,7 @@ EOF
test_cmp expected actual
 '
 
-test_expect_failure 'left alignment formatting with trunc. 
i18n.logOutputEncoding' '
+test_expect_success 'left alignment formatting with trunc. 
i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=iso8859-1 log 
--pretty="format:%<(10,trunc)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
@@ -257,7 +257,7 @@ EOF
test_cmp expected actual
 '
 
-test_expect_failure 'left alignment formatting with ltrunc. 
i18n.logOutputEncoding' '
+test_expect_success 'left alignment formatting with ltrunc. 
i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=iso8859-1 log 
--pretty="format:%<(10,ltrunc)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
@@ -283,7 +283,7 @@ EOF
test_cmp expected actual
 '
 
-test_expect_failure 'left alignment formatting with mtrunc. 
i18n.logOutputEncoding' '
+test_expect_success 'left alignment formatting with mtrunc. 
i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=iso8859-1 log 
--pretty="format:%<(10,mtrunc)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
@@ -465,7 +465,7 @@ EOF
test_cmp expected actual
 '
 
-test_expect_failure 'left/right alignment formatting with stealing. 
i18n.logOutputEncoding' '
+test_expect_success 'left/right alignment formatting with stealing. 
i18n.logOutputEncoding' '
git commit --amend -m short --author "long long long " &&
git -c i18n.logOutputEncoding=iso8859-1 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 09cdf24..04811fd 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -256,7 +256,7 @@ commit $head1
 $added_iso88591
 EOF
 
-test_format complex-subject-trunc %<($truncate_count,trunc)%s failure <http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/2] t4205, t6006: Add failing tests for the case when i18n.logOutputEncoding is set

2014-05-16 Thread Alexey Shumkin
Pretty format string %<(N,[ml]trunc)>%s truncates subject to a given
length with an appropriate padding. This works for non-ASCII texts when
i18n.logOutputEncoding is UTF-8 only (independently of a printed commit
message encoding) but does not work when i18n.logOutputEncoding is NOT
UTF-8.

There were no breakages as far as were no tests for the case
when both a commit message and logOutputEncoding are not UTF-8.

Add failing tests for that which will be fixed in the next patch.

Signed-off-by: Alexey Shumkin 
Reviewed-by: Nguyễn Thái Ngọc Duy 
---
 t/t4205-log-pretty-formats.sh | 169 ++
 t/t6006-rev-list-format.sh|  75 ++-
 2 files changed, 242 insertions(+), 2 deletions(-)

diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 2a6278b..6791e0d 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -153,6 +153,19 @@ EOF
test_cmp expected actual
 '
 
+test_expect_success 'left alignment formatting. i18n.logOutputEncoding' '
+   git -c i18n.logOutputEncoding=iso8859-1 log --pretty="format:%<(40)%s" 
>actual &&
+   # complete the incomplete line at the end
+   echo >>actual &&
+   qz_to_tab_space <expected &&
+message twoZ
+message oneZ
+add barZ
+$(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 &&
# complete the incomplete line at the end
@@ -166,6 +179,19 @@ EOF
test_cmp expected actual
 '
 
+test_expect_success 'left alignment formatting at the nth column. 
i18n.logOutputEncoding' '
+   git -c i18n.logOutputEncoding=iso8859-1 log --pretty="format:%h 
%<|(40)%s" >actual &&
+   # complete the incomplete line at the end
+   echo >>actual &&
+   qz_to_tab_space <expected &&
+$head1 message twoZ
+$head2 message oneZ
+$head3 add barZ
+$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 &&
# complete the incomplete line at the end
@@ -179,6 +205,19 @@ EOF
test_cmp expected actual
 '
 
+test_expect_success 'left alignment formatting with no padding. 
i18n.logOutputEncoding' '
+   git -c i18n.logOutputEncoding=iso8859-1 log --pretty="format:%<(1)%s" 
>actual &&
+   # complete the incomplete line at the end
+   echo >>actual &&
+   cat <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 &&
# complete the incomplete line at the end
@@ -192,6 +231,19 @@ EOF
test_cmp expected actual
 '
 
+test_expect_failure 'left alignment formatting with trunc. 
i18n.logOutputEncoding' '
+   git -c i18n.logOutputEncoding=iso8859-1 log 
--pretty="format:%<(10,trunc)%s" >actual &&
+   # complete the incomplete line at the end
+   echo >>actual &&
+   qz_to_tab_space <expected &&
+message ..
+message ..
+add bar  Z
+initial...
+EOF
+   test_cmp expected actual
+'
+
 test_expect_success 'left alignment formatting with ltrunc' '
git log --pretty="format:%<(10,ltrunc)%s" >actual &&
# complete the incomplete line at the end
@@ -205,6 +257,19 @@ EOF
test_cmp expected actual
 '
 
+test_expect_failure 'left alignment formatting with ltrunc. 
i18n.logOutputEncoding' '
+   git -c i18n.logOutputEncoding=iso8859-1 log 
--pretty="format:%<(10,ltrunc)%s" >actual &&
+   # complete the incomplete line at the end
+   echo >>actual &&
+   qz_to_tab_space <expected &&
+..sage two
+..sage one
+add bar  Z
+..${sample_utf8_part}lich
+EOF
+   test_cmp expected actual
+'
+
 test_expect_success 'left alignment formatting with mtrunc' '
git log --pretty="format:%<(10,mtrunc)%s" >actual &&
# complete the incomplete line at the end
@@ -218,6 +283,19 @@ EOF
test_cmp expected actual
 '
 
+test_expect_failure 'left alignment formatting with mtrunc. 
i18n.logOutputEncoding' '
+

[PATCH v2 0/2] Reroll patch series. Pretty print truncate does not work

2014-05-16 Thread Alexey Shumkin
In this reroll (against v1) remarks of Nguyễn are respected.
Comments style changed from C++ to C. variable declaration moved back to
the beginning of a function.
Also, added tests for the same case for git rev-list
(see t6006-rev-list-format.sh)

Alexey Shumkin (2):
  t4205, t6006: Add failing tests for the case when
i18n.logOutputEncoding is set
  pretty.c: format string with truncate respects logOutputEncoding

 pretty.c  |   7 +-
 t/t4205-log-pretty-formats.sh | 169 ++
 t/t6006-rev-list-format.sh|  75 ++-
 3 files changed, 248 insertions(+), 3 deletions(-)

-- 
1.9.2-17

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] Pretty print truncate does not work

2014-05-16 Thread Alexey Shumkin
Pretty format string %<(N,[ml]trunc)>%s truncates subject to a given
length with an appropriate padding. This works for non-ASCII texts when
i18n.logOutputEncoding is UTF-8 only (independently of a printed commit
message encoding) but does not work when i18n.logOutputEncoding is NOT
UTF-8.

Following patches are:
1. failing tests
2. Fix patch

Alexey Shumkin (2):
  t4205 (log-pretty-formats): Add failing tests for the case when
i18n.logOutputEncoding is set
  pretty.c: format string with truncate respects logOutputEncoding

 pretty.c  |   7 +-
 t/t4205-log-pretty-formats.sh | 169 ++
 2 files changed, 174 insertions(+), 2 deletions(-)

-- 
1.9.2-15

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] t4205 (log-pretty-formats): Add failing tests for the case when i18n.logOutputEncoding is set

2014-05-16 Thread Alexey Shumkin
Pretty format string %<(N,[ml]trunc)>%s truncates subject to a given
length with an appropriate padding. This works for non-ASCII texts when
i18n.logOutputEncoding is UTF-8 only (independently of a printed commit
message encoding) but does not work when i18n.logOutputEncoding is NOT
UTF-8.

There were no breakages as far as were no tests for the case
when both a commit message and logOutputEncoding are not UTF-8.

Add failing tests for that which will be fixed in the next patch.

Signed-off-by: Alexey Shumkin 
---
 t/t4205-log-pretty-formats.sh | 169 ++
 1 file changed, 169 insertions(+)

diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 2a6278b..6791e0d 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -153,6 +153,19 @@ EOF
test_cmp expected actual
 '
 
+test_expect_success 'left alignment formatting. i18n.logOutputEncoding' '
+   git -c i18n.logOutputEncoding=iso8859-1 log --pretty="format:%<(40)%s" 
>actual &&
+   # complete the incomplete line at the end
+   echo >>actual &&
+   qz_to_tab_space <expected &&
+message twoZ
+message oneZ
+add barZ
+$(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 &&
# complete the incomplete line at the end
@@ -166,6 +179,19 @@ EOF
test_cmp expected actual
 '
 
+test_expect_success 'left alignment formatting at the nth column. 
i18n.logOutputEncoding' '
+   git -c i18n.logOutputEncoding=iso8859-1 log --pretty="format:%h 
%<|(40)%s" >actual &&
+   # complete the incomplete line at the end
+   echo >>actual &&
+   qz_to_tab_space <expected &&
+$head1 message twoZ
+$head2 message oneZ
+$head3 add barZ
+$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 &&
# complete the incomplete line at the end
@@ -179,6 +205,19 @@ EOF
test_cmp expected actual
 '
 
+test_expect_success 'left alignment formatting with no padding. 
i18n.logOutputEncoding' '
+   git -c i18n.logOutputEncoding=iso8859-1 log --pretty="format:%<(1)%s" 
>actual &&
+   # complete the incomplete line at the end
+   echo >>actual &&
+   cat <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 &&
# complete the incomplete line at the end
@@ -192,6 +231,19 @@ EOF
test_cmp expected actual
 '
 
+test_expect_failure 'left alignment formatting with trunc. 
i18n.logOutputEncoding' '
+   git -c i18n.logOutputEncoding=iso8859-1 log 
--pretty="format:%<(10,trunc)%s" >actual &&
+   # complete the incomplete line at the end
+   echo >>actual &&
+   qz_to_tab_space <expected &&
+message ..
+message ..
+add bar  Z
+initial...
+EOF
+   test_cmp expected actual
+'
+
 test_expect_success 'left alignment formatting with ltrunc' '
git log --pretty="format:%<(10,ltrunc)%s" >actual &&
# complete the incomplete line at the end
@@ -205,6 +257,19 @@ EOF
test_cmp expected actual
 '
 
+test_expect_failure 'left alignment formatting with ltrunc. 
i18n.logOutputEncoding' '
+   git -c i18n.logOutputEncoding=iso8859-1 log 
--pretty="format:%<(10,ltrunc)%s" >actual &&
+   # complete the incomplete line at the end
+   echo >>actual &&
+   qz_to_tab_space <expected &&
+..sage two
+..sage one
+add bar  Z
+..${sample_utf8_part}lich
+EOF
+   test_cmp expected actual
+'
+
 test_expect_success 'left alignment formatting with mtrunc' '
git log --pretty="format:%<(10,mtrunc)%s" >actual &&
# complete the incomplete line at the end
@@ -218,6 +283,19 @@ EOF
test_cmp expected actual
 '
 
+test_expect_failure 'left alignment formatting with mtrunc. 
i18n.logOutputEncoding' '
+   git -c i18n.logOutputEncoding=iso8859-1 log 
--pretty="format:%<(10,mtrunc)%

[PATCH 2/2] pretty.c: format string with truncate respects logOutputEncoding

2014-05-16 Thread Alexey Shumkin
Pretty format string %<(N,[ml]trunc)>%s truncates subject to a given
length with an appropriate padding. This works for non-ASCII texts when
i18n.logOutputEncoding is UTF-8 only (independently of a printed commit
message encoding) but does not work when i18n.logOutputEncoding is NOT
UTF-8.

In 7e77df3 (pretty: two phase conversion for non utf-8 commits, 2013-04-19)
'format_commit_item' function assumes commit message to be in UTF-8.
And that was so until ecaee80 (pretty: --format output should honor
logOutputEncoding, 2013-06-26) where conversion to logOutputEncoding was
added before calling 'format_commit_message'.

Correct this by converting a commit message to UTF-8 first (as it
assumed in 7e77df3 (pretty: two phase conversion for non utf-8 commits,
2013-04-19)). Only after that set 'output_enc' variable to an actual
logOutputEncoding.

Signed-off-by: Alexey Shumkin 
---
 pretty.c  | 7 +--
 t/t4205-log-pretty-formats.sh | 8 
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/pretty.c b/pretty.c
index 6e266dd..7eb43c1 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1500,16 +1500,19 @@ void format_commit_message(const struct commit *commit,
   const struct pretty_print_context *pretty_ctx)
 {
struct format_commit_context context;
-   const char *output_enc = pretty_ctx->output_encoding;
const char *utf8 = "UTF-8";
 
memset(&context, 0, sizeof(context));
context.commit = commit;
context.pretty_ctx = pretty_ctx;
context.wrap_start = sb->len;
+   // convert a commit message to UTF-8 first
+   // as far as 'format_commit_item' assumes it in UTF-8
context.message = logmsg_reencode(commit,
  &context.commit_encoding,
- output_enc);
+ utf8);
+   // then convert to an actual output encoding
+   const char *output_enc = pretty_ctx->output_encoding;
 
strbuf_expand(sb, format, format_commit_item, &context);
rewrap_message_tail(sb, &context, 0, 0, 0);
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 6791e0d..7426fe2 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -231,7 +231,7 @@ EOF
test_cmp expected actual
 '
 
-test_expect_failure 'left alignment formatting with trunc. 
i18n.logOutputEncoding' '
+test_expect_success 'left alignment formatting with trunc. 
i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=iso8859-1 log 
--pretty="format:%<(10,trunc)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
@@ -257,7 +257,7 @@ EOF
test_cmp expected actual
 '
 
-test_expect_failure 'left alignment formatting with ltrunc. 
i18n.logOutputEncoding' '
+test_expect_success 'left alignment formatting with ltrunc. 
i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=iso8859-1 log 
--pretty="format:%<(10,ltrunc)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
@@ -283,7 +283,7 @@ EOF
test_cmp expected actual
 '
 
-test_expect_failure 'left alignment formatting with mtrunc. 
i18n.logOutputEncoding' '
+test_expect_success 'left alignment formatting with mtrunc. 
i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=iso8859-1 log 
--pretty="format:%<(10,mtrunc)%s" >actual &&
# complete the incomplete line at the end
echo >>actual &&
@@ -465,7 +465,7 @@ EOF
test_cmp expected actual
 '
 
-test_expect_failure 'left/right alignment formatting with stealing. 
i18n.logOutputEncoding' '
+test_expect_success 'left/right alignment formatting with stealing. 
i18n.logOutputEncoding' '
git commit --amend -m short --author "long long long " &&
git -c i18n.logOutputEncoding=iso8859-1 log 
--pretty="format:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
# complete the incomplete line at the end
-- 
1.9.2-15

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Git bug. "make [all]" does not use USE_LIBPCRE when "configure --with-libpcre" was previously run

2013-08-14 Thread Alexey Shumkin
On Wed, Aug 14, 2013 at 09:39:10AM -0700, Junio C Hamano wrote:
> Junio C Hamano  writes:
> 
> > This does not have anything to do with C, but is a breakage in our
> > autoconf script.
I've meant C-programmers does understand autoconf, too. But I do not :(.

> > It appears that anything that is meant to be
> > appended at end via $config_appended_defs mechanism is missing from
> > the end result.
> >
> > In fact, symbols whose explicit substitution the above patch
> > removes, e.g. CC_LD_DYNPATH, TCLTK_PATH, NEEDS_SSL_WITH_CRYPTO,
> > etc. are all missing.
> 
> Wait, I spoke too soon.
> 
> $ rm -f configure config.status &&
>   make configure &&
>   ./configure --with-libpcre &&
>   grep USE_LIBPCRE config.mak.autogen
> USE_LIBPCRE=YesPlease
> 
> no longer reproduces for me (even though I _thought_ I tried and saw
> the breakage).  Hmm.
Oh! That have worked for me, too. No more error occured.
Thank you! 

-- 
Alexey Shumkin
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Git bug. "make [all]" does not use USE_LIBPCRE when "configure --with-libpcre" was previously run

2013-08-14 Thread Alexey Shumkin
Hello, Stefan!

I'll begin from afar.

>From time to time, I use `git grep -P` to search text in sources using PCRE.
Today I was suprised when that command gave me the error
"fatal: cannot use Perl-compatible regexes when not compiled with
USE_LIBPCRE"

As far as I always use
./configure --with-libpcre 
make all
to build my Cygwin version of Git that was a VERY sudden error for me.
(but this is not a Cygwin-specific error, I've reproduced it on my Linux
box).

I've found out that `make` "does not know" anymore about USE_LIBPCRE=YesPlease
even `./configure --with-libpcre` was run before it. But I do remember
that it worked in some versions before (currently I use latest - v1.8.3.4).

So, I've got armed with the following test script:

---8<---
#!/bin/sh

set -e
./configure --with-libpcre
make
set +e
./bin-wrappers/git grep -qIP das+
# if "cannot use Perl-compatible regexes" error occurs
# then Git exits with an error code 128 (but `git bisect run` fails to
# expect this exit code).
if test $? -eq 128
then
exit 1
fi
---8<---

and `git bisect run` to find out where Git was broken.
That gave me:

---8<---
40bfbde9da5c6cbc85f49a755f27162dc966fd89 is the first bad commit
commit 40bfbde9da5c6cbc85f49a755f27162dc966fd89
Author: Stefano Lattarini 
Date:   Tue Sep 11 17:45:30 2012 +0200

build: don't duplicate substitution of make variables

Thanks to our 'GIT_CONF_SUBST' layer in configure.ac, a make variable 'VAR'
can be defined to a value 'VAL' at ./configure runtime in our build system
simply by using "GIT_CONF_SUBST([VAR], [VAL])" in configure.ac, rather than
having both to call "AC_SUBST([VAR], [VAL])" in configure.ac and adding the
'VAR = @VAR@' definition in config.mak.in.  Less duplication, less margin
for error, less possibility of confusion.

While at it, fix some formatting issues in configure.ac that unnecessarily
obscured the code flow.

Signed-off-by: Stefano Lattarini 
Signed-off-by: Junio C Hamano 

:100644 100644 802d34223a2859ee1341d94ee722d7939b7276aa 
69d48382fe69b8699eb350949fff04975db923f8 M  config.mak.in
:100644 100644 450bbe7f1020711b4af2ad6ea52d717651c30b0b 
da1f41f58871b2102a9ed5eaeff7df3c9623f4bd M  configure.ac
bisect run success

---8<---

I'm not a C programmer to fix that, so I ask you to.

-- 
Alexey Shumkin
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] hooks/post-receive-email: force log messages in UTF-8

2013-08-05 Thread Alexey Shumkin
On Sun, Aug 04, 2013 at 11:14:40AM -0700, Jonathan Nieder wrote:
> Alexey Shumkin wrote:
> > On Fri, Aug 02, 2013 at 04:23:38PM -0700, Jonathan Nieder wrote:
> 
> >>  1. Log messages use the configured log output encoding, which is
> >> meant to be whatever encoding works best with local terminals
> >> (and does not have much to do with what encoding should be used
> >> for email)
> >>
> >>  2. Filenames are left as is: on Linux, usually UTF-8, and in the Mingw
> >> port (which uses Unicode filesystem APIs), always UTF-8
> >
> > I cannot say exactly if it makes sense for THIS patch, but I'd like to
> > remind about Cygwin port, which definitely does not use UTF-8 encoding
> > (in my case it is Windows-1251) for filenames.
> >
> >> 
> >>  3. The "This is an automated email" preface uses a project description
> >> from .git/description, which is typically in UTF-8 to support
> >> gitweb.
> 
> Thanks for clarifying.  So in the context you describe, (1) is
> configurable, (2) is Windows-1251, (3) is unconfigurably UTF-8, and
> there is no way with current git facilities to force the email to use
> a single encoding unless (3) happens to contain no special characters.
> 
> What is the value of the "[i18n] commitEncoding" setting in your
> project?
commitEncoding is equal to filenames' encoding, Windows-1251, of course.

> What encoding do the raw commit messages (shown with
> "git log --format=raw") use for their text, and what do they declare
> with an in-commit 'encoding' header, if any?
Well, despite `git log --help` 
--8<--
raw
   The raw format shows the entire commit exactly as stored in
   the commit object"
--8<--
on a Linux box (UTF-8) I can see "readable" commit messages nevertheless
they are stored in 'Windows-1251' (so they are converted to UTF-8). To
be sure I've checked actual content of them with `git cat-file commit`
Actually, to be honest, I usually use modified version of Git (see
ecaee8050cec23eb4cf082512e907e3e52c20b57) in 'next' branch, that could
affect the results, so I've checked `git log --format=raw` with
unmodified v1.8.3.3 of Git.

But let's go back to the answer to your question. Commit encoding stored
as a header in a raw commit messages is 'Windows-1251'.
> 
> Does everyone on this project use Cygwin?i
This is a "closed" (commercial) project and every developer uses Cygwin,
except me. I use a Linux box as a desktop (mail, IM, web-browsing; but
development goes on Cygwin). And sometimes I run utility scripts
included to that project on my desktop (as far as Linux works with files
much faster than Cygwin does ;))
Also, a Git server is a coLinux box (http://www.colinux.org/) on a
Windows Server 2003, but I guess, it does not much matter here.
>  That should be fine, but
> I'd expect there to be problems as soon as someone wants to try the
> Mingw port ("Git for Windows").
Yep, one of our developers tried to use modern version of TortoiseGit
with MinGW port of Git. That was a failure. As far as since v1.7.9 MinGW
port transcodes filenames to store them internally in UTF-8. This
problem could be solved with converting once that non-ASCII filenames to
UTF-8, but I do not want to use MinGW port. I like Cygwin
"infrastructure" that is more Linux-like than MinGW.
> 
> I wonder if there should be an "[i18n] repositoryPathEncoding"
> configuration item to support this kind of repository.  Then git could
> be aware of the intended encoding of paths, could recode them for
> display to a terminal, and at least on Linux and Mingw could recode
> them for use in filenames on disk.  "repositoryPathEncoding = none"
> would mean the current behavior of treating paths as raw sequences of
> bytes.
I'd be happy if such a setting exists. That could solve many problems
with cross-platform projects with non-ASCII filenames.
Indeed, MinGW port does resolve that problem somehow!
> 
> What do you think?
> Jonathan

-- 
Alexey Shumkin
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] hooks/post-receive-email: force log messages in UTF-8

2013-08-04 Thread Alexey Shumkin
On Fri, Aug 02, 2013 at 04:23:38PM -0700, Jonathan Nieder wrote:
> Git commands write commit messages in UTF-8 by default, but that
> default can be overridden by the [i18n] commitEncoding and
> logOutputEncoding settings.  With such a setting, the emails written
> by the post-receive-email hook use a mixture of encodings:
> 
>  1. Log messages use the configured log output encoding, which is
> meant to be whatever encoding works best with local terminals
> (and does not have much to do with what encoding should be used
> for email)
> 
>  2. Filenames are left as is: on Linux, usually UTF-8, and in the Mingw
> port (which uses Unicode filesystem APIs), always UTF-8
I cannot say exactly if it makes sense for THIS patch, but I'd like to
remind about Cygwin port, which definitely does not use UTF-8 encoding
(in my case it is Windows-1251) for filenames.
> 
>  3. The "This is an automated email" preface uses a project description
> from .git/description, which is typically in UTF-8 to support
> gitweb.
> 
> So (1) is configurable, and (2) and (3) are unconfigurable and
> typically UTF-8.  Override the log output encoding to always use UTF-8
> when writing the email to get the best chance of a comprehensible
> single-encoding email.
I cannot agree to receive e-mails in UTF-8 only for Windows projects
which have non-UTF-8 encoding. I want to see and read correctly formed
e-mail without any corrupted symbols instead of filenames (that is the
main problem here as far as filenames are not converted unlike log
messages)
> 
> Signed-off-by: Jonathan Nieder 
> ---
>  contrib/hooks/post-receive-email | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/contrib/hooks/post-receive-email 
> b/contrib/hooks/post-receive-email
> index 72084511..ba93a0d8 100755
> --- a/contrib/hooks/post-receive-email
> +++ b/contrib/hooks/post-receive-email
> @@ -471,7 +471,7 @@ generate_delete_branch_email()
>   echo "   was  $oldrev"
>   echo ""
>   echo $LOGBEGIN
> - git diff-tree -s --always --pretty=oneline $oldrev
> + git diff-tree -s --always --encoding=UTF-8 --pretty=oneline $oldrev
>   echo $LOGEND
>  }
>  
> @@ -571,7 +571,7 @@ generate_delete_atag_email()
>   echo "   was  $oldrev"
>   echo ""
>   echo $LOGBEGIN
> - git diff-tree -s --always --pretty=oneline $oldrev
> + git diff-tree -s --always --encoding=UTF-8 --pretty=oneline $oldrev
>   echo $LOGEND
>  }
>  
> @@ -617,7 +617,7 @@ generate_general_email()
>   echo ""
>   if [ "$newrev_type" = "commit" ]; then
>   echo $LOGBEGIN
> - git diff-tree -s --always --pretty=medium $newrev
> + git diff-tree -s --always --encoding=UTF-8 --pretty=medium 
> $newrev
>   echo $LOGEND
>   else
>   # What can we do here?  The tag marks an object that is not
> @@ -636,7 +636,7 @@ generate_delete_general_email()
>   echo "   was  $oldrev"
>   echo ""
>   echo $LOGBEGIN
> - git diff-tree -s --always --pretty=oneline $oldrev
> + git diff-tree -s --always --encoding=UTF-8 --pretty=oneline $oldrev
>   echo $LOGEND
>  }
>  
> -- 
> 1.8.4.rc1
> 

-- 
Alexey Shumkin
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v10 4/5] t6006 (rev-list-format): add tests for "%b" and "%s" for the case i18n.commitEncoding is not set

2013-07-05 Thread Alexey Shumkin
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 
Suggested-by: Johannes Sixt 
---
 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 <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 expect commit $head3 &&
echo >>expect fooQbar &&
-- 
1.8.3.2.16.gb1f0d63

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v10 3/5] t4205, t6006, t7102: make functions better readable

2013-07-05 Thread Alexey Shumkin
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 
Improved-by: Johannes Sixt 
---
 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 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v10 5/5] t4205 (log-pretty-formats): avoid using `sed`

2013-07-05 Thread Alexey Shumkin
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 
Signed-off-by: Junio C Hamano 
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v10 0/5] Incremental updates against 'next' branch

2013-07-05 Thread Alexey Shumkin
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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v10 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1

2013-07-05 Thread Alexey Shumkin
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 
Suggested-by: Johannes Sixt 
---
 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 <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 -

[PATCH v10 2/5] t4205 (log-pretty-formats): revert back single quotes

2013-07-05 Thread Alexey Shumkin
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 
Suggested-by: Johannes Sixt 
---
 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 <expected &&
 message twoZ
 message oneZ
 add barZ
 $(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 <expected &&
 $head1 message twoZ
 $head2 message oneZ
 $head3 add barZ
 $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 <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 <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 <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 <expected &&
 mess.. two
 mess.. one
 add bar  Z
 $(commit_msg "" "4" ".\{11\}")
 EOF
test_cmp expected actual
-"
+'
 
-test_expect_success 'right alignment formatting' &quo

Re: [PATCH v9 3/5] t4205, t6006, t7102: make functions more readable

2013-07-05 Thread Alexey Shumkin
On Fri, Jul 05, 2013 at 01:44:07AM -0700, Junio C Hamano wrote:
> Alexey Shumkin  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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v9 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1

2013-07-05 Thread Alexey Shumkin
On Fri, Jul 05, 2013 at 01:11:49AM -0700, Junio C Hamano wrote:
> Alexey Shumkin  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 
> >> > Reviewed-by: Johannes Sixt 
> >> 
> >> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v9 3/5] t4205, t6006, t7102: make functions more readable

2013-07-05 Thread Alexey Shumkin
On Thu, Jul 04, 2013 at 11:45:57PM -0700, Junio C Hamano wrote:
> Alexey Shumkin  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 <> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v9 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1

2013-07-05 Thread Alexey Shumkin
On Thu, Jul 04, 2013 at 11:47:04PM -0700, Junio C Hamano wrote:
> Alexey Shumkin  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 
> > Reviewed-by: Johannes Sixt 
> 
> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v9 4/5] t6006: add two more tests for the case i18n.commitEncoding is not set

2013-07-05 Thread Alexey Shumkin
On Fri, Jul 05, 2013 at 12:04:34AM -0700, Junio C Hamano wrote:
> Alexey Shumkin  writes:
> 
> > +test_format complex-body %b < > +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: 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 < 
> > +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 < > +commit $head3
> > +Test printing of complex bodies
> > +commit $head2
> >  $changed
> >  commit $head1
> >  $added
> >  EOF
> >  
> > -test_format complex-body %b < > +test_format complex-body-commitencoding-unset %b < >  commit $head3
> >  This commit message is much longer than the others,
> >  and it will be encoded in iso8859-1. We should therefore

-- 
Alexey Shumkin
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v9 4/5] t6006: add two more tests for the case i18n.commitEncoding is not set

2013-07-04 Thread Alexey Shumkin
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 
Reviewed-by: Johannes Sixt 
---
 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 <http://vger.kernel.org/majordomo-info.html


[PATCH v9 5/5] t4205: avoid using `sed`

2013-07-04 Thread Alexey Shumkin
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 
Signed-off-by: Junio C Hamano 
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v9 2/5] t4205: revert back single quotes

2013-07-04 Thread Alexey Shumkin
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 
Suggested-by: Johannes Sixt 
---
 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 <expected &&
 message twoZ
 message oneZ
 add barZ
 $(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 <expected &&
 $head1 message twoZ
 $head2 message oneZ
 $head3 add barZ
 $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 <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 <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 <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 <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

[PATCH v9 3/5] t4205, t6006, t7102: make functions more readable

2013-07-04 Thread Alexey Shumkin
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 
Improved-by: Johannes Sixt 
---
 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 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v9 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1

2013-07-04 Thread Alexey Shumkin
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 
Reviewed-by: Johannes Sixt 
---
 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 <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.logO

[PATCH v9 0/5] Incremental updates against 'next' branch

2013-07-04 Thread Alexey Shumkin
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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] t4205: don't rely on en_US.UTF-8 locale existing

2013-07-03 Thread Alexey Shumkin
On Wed, Jul 03, 2013 at 10:53:03PM +0100, John Keeping wrote:
> On Wed, Jul 03, 2013 at 02:41:06PM -0700, Junio C Hamano wrote:
> > John Keeping  writes:
> > 
> > > My system doesn't have the en_US.UTF-8 locale (or plain en_US), which
> > > causes t4205 to fail by counting bytes instead of UTF-8 codepoints.
> > >
> > > Instead of using sed for this, use Perl which behaves predictably
> > > whatever locale is in use.
> > >
> > > Signed-off-by: John Keeping 
> > > ---
> > > This patch is on top of 'as/log-output-encoding-in-user-format'.
> > 
> > Thanks.  I think Alexey is going to send incremental updates to the
> > topic so I won't interfere by applying this patch on top of the
> > version I have in my tree.
> > 
> > But I do agree that using Perl may be a workable solution.
> > 
> > An alternative might be not to use this cryptic 3-arg form of
> > commit_msg at all.  They are used only for these three:
> > 
> > $(commit_msg "" "8" "..*$")
> > $(commit_msg "" "0" ".\{11\}")
> > $(commit_msg "" "4" ".\{11\}")
> > 
> > I somehow find them simply not readable, in order to figure out what
> > is going on.
> > 
> > Just using three variables to hold what are expected would be far
> > more portable and readable.
> > 
> > # "anfänglich" whatever it means.
> > sample_utf8_part=$(printf "anf\303\244ng")
> > 
> > commit_msg () {
> > msg="initial. ${sample_utf8_part}lich";
> > if test -n "$1"
> > then
> > echo "$msg" | iconv -f utf-8 -t "$1"
> > else
> > echo "$msg"
> > fi
> > }
> > 
> > And then instead of writing in the expected test output.
> > 
> > $(commit_msg "" "8" "..*$")
> > $(commit_msg "" "0" ".\{11\}")
> > $(commit_msg "" "4" ".\{11\}")
> > 
> > we can just say
> > 
> > initial...
> > ..an${sample_utf8_part}lich
> > init..lich
> > 
> > It is no worse than those cryptic 0, 4, 8 and 11 magic numbers we
> > see in the test, no?
> 
> That's probably better since we don't need to rely on some other tool
> getting it right.
> 
> Alexey, will you incorporate this change in your incremental updates?
Yes, of course!
Thank you for your additions
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] t4205: don't rely on en_US.UTF-8 locale existing

2013-07-03 Thread Alexey Shumkin
On Wed, Jul 03, 2013 at 02:41:06PM -0700, Junio C Hamano wrote:
> John Keeping  writes:
> 
> > My system doesn't have the en_US.UTF-8 locale (or plain en_US), which
> > causes t4205 to fail by counting bytes instead of UTF-8 codepoints.
> >
> > Instead of using sed for this, use Perl which behaves predictably
> > whatever locale is in use.
> >
> > Signed-off-by: John Keeping 
> > ---
> > This patch is on top of 'as/log-output-encoding-in-user-format'.
> 
> Thanks.  I think Alexey is going to send incremental updates to the
> topic so I won't interfere by applying this patch on top of the
> version I have in my tree.
> 
> But I do agree that using Perl may be a workable solution.
> 
> An alternative might be not to use this cryptic 3-arg form of
> commit_msg at all.  They are used only for these three:
> 
>   $(commit_msg "" "8" "..*$")
>   $(commit_msg "" "0" ".\{11\}")
>   $(commit_msg "" "4" ".\{11\}")
> 
> I somehow find them simply not readable, in order to figure out what
> is going on.
> 
> Just using three variables to hold what are expected would be far
> more portable and readable.
> 
> # "anfänglich" whatever it means.
> sample_utf8_part=$(printf "anf\303\244ng")
> 
> commit_msg () {
>   msg="initial. ${sample_utf8_part}lich";
>   if test -n "$1"
>   then
>   echo "$msg" | iconv -f utf-8 -t "$1"
>   else
>   echo "$msg"
> fi
> }
> 
> And then instead of writing in the expected test output.
> 
>   $(commit_msg "" "8" "..*$")
>   $(commit_msg "" "0" ".\{11\}")
>   $(commit_msg "" "4" ".\{11\}")
> 
> we can just say
> 
>   initial...
> ..an${sample_utf8_part}lich
>   init..lich
> 
> It is no worse than those cryptic 0, 4, 8 and 11 magic numbers we
> see in the test, no?
Yep!
when I was thinking about Johannes's suggestions, I finally came to the decision
alike yours.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] t4205: don't rely on en_US.UTF-8 locale existing

2013-07-03 Thread Alexey Shumkin
http://thread.gmane.org/gmane.comp.version-control.git/229291

this is why CCed
> CC this to Johannes Sixt
> 
> On Wed, Jul 03, 2013 at 09:18:08PM +0100, John Keeping wrote:
> > My system doesn't have the en_US.UTF-8 locale (or plain en_US), which
> > causes t4205 to fail by counting bytes instead of UTF-8 codepoints.
> > 
> > Instead of using sed for this, use Perl which behaves predictably
> > whatever locale is in use.
> > 
> > Signed-off-by: John Keeping 
> > ---
> > This patch is on top of 'as/log-output-encoding-in-user-format'.
> > 
> >  t/t4205-log-pretty-formats.sh | 8 +++-
> >  1 file changed, 3 insertions(+), 5 deletions(-)
> > 
> > diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
> > index 3cfb744..5864f5b 100755
> > --- a/t/t4205-log-pretty-formats.sh
> > +++ b/t/t4205-log-pretty-formats.sh
> > @@ -20,9 +20,7 @@ commit_msg () {
> > # 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../")
> > +   msg=$(echo $msg | "$PERL_PATH" -CIO -pe "s/^(.{$2})$3/\1../")
> > fi
> > echo $msg
> >  }
> > @@ -205,7 +203,7 @@ test_expect_success 'left alignment formatting with 
> > ltrunc' "
> >  ..sage two
> >  ..sage one
> >  add bar  Z
> > -$(commit_msg "" "0" ".\{11\}")
> > +$(commit_msg "" "0" ".{11}")
> >  EOF
> > test_cmp expected actual
> >  "
> > @@ -218,7 +216,7 @@ test_expect_success 'left alignment formatting with 
> > mtrunc' "
> >  mess.. two
> >  mess.. one
> >  add bar  Z
> > -$(commit_msg "" "4" ".\{11\}")
> > +$(commit_msg "" "4" ".{11}")
> >  EOF
> > test_cmp expected actual
> >  "
> > -- 
> > 1.8.3.1.747.g77f7d3a
> > 
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] t4205: don't rely on en_US.UTF-8 locale existing

2013-07-03 Thread Alexey Shumkin
CC this to Johannes Sixt

On Wed, Jul 03, 2013 at 09:18:08PM +0100, John Keeping wrote:
> My system doesn't have the en_US.UTF-8 locale (or plain en_US), which
> causes t4205 to fail by counting bytes instead of UTF-8 codepoints.
> 
> Instead of using sed for this, use Perl which behaves predictably
> whatever locale is in use.
> 
> Signed-off-by: John Keeping 
> ---
> This patch is on top of 'as/log-output-encoding-in-user-format'.
> 
>  t/t4205-log-pretty-formats.sh | 8 +++-
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
> index 3cfb744..5864f5b 100755
> --- a/t/t4205-log-pretty-formats.sh
> +++ b/t/t4205-log-pretty-formats.sh
> @@ -20,9 +20,7 @@ commit_msg () {
>   # 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../")
> + msg=$(echo $msg | "$PERL_PATH" -CIO -pe "s/^(.{$2})$3/\1../")
>   fi
>   echo $msg
>  }
> @@ -205,7 +203,7 @@ test_expect_success 'left alignment formatting with 
> ltrunc' "
>  ..sage two
>  ..sage one
>  add bar  Z
> -$(commit_msg "" "0" ".\{11\}")
> +$(commit_msg "" "0" ".{11}")
>  EOF
>   test_cmp expected actual
>  "
> @@ -218,7 +216,7 @@ test_expect_success 'left alignment formatting with 
> mtrunc' "
>  mess.. two
>  mess.. one
>  add bar  Z
> -$(commit_msg "" "4" ".\{11\}")
> +$(commit_msg "" "4" ".{11}")
>  EOF
>   test_cmp expected actual
>  "
> -- 
> 1.8.3.1.747.g77f7d3a
> 
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding

2013-07-03 Thread Alexey Shumkin
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 < >>>  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
loong 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v8 0/5] Reroll patches against Git v1.8.3.2

2013-07-03 Thread Alexey Shumkin
On Tue, Jul 02, 2013 at 12:41:03PM -0700, Junio C Hamano wrote:
> Alexey Shumkin  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.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v8 3/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs

2013-07-01 Thread Alexey Shumkin
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin 
---
 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 twoZ
-7cd6c63 message oneZ
-1711bf9 add barZ
-af20c06 initialZ
+$head1 message twoZ
+$head2 message oneZ
+$head3 add barZ
+$head4 initialZ
 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 barZ
-af20c06 initialZ
+$head1   message two  Z
+$head2   message one  Z
+$head3 add barZ
+$head4 initialZ
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2013-07-01 Thread Alexey Shumkin
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 
---
 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-

[PATCH v8 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding

2013-07-01 Thread 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 
---
 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 submodu

[PATCH v8 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs

2013-07-01 Thread Alexey Shumkin
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin 
---
 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 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 <expect commit 1ed88da4a5b5ed8c449114ac131efc62178734c3 &&
+   echo  >expect commit $head3 &&
echo >>expect fooQbar &&
git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
nul_to_q actual &&
-- 
1.8.3.1.16.gce2c52e

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v8 0/5] Reroll patches against Git v1.8.3.2

2013-07-01 Thread Alexey Shumkin
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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v8 2/5] t7102 (reset): don't hardcode SHA-1 in expected outputs

2013-07-01 Thread Alexey Shumkin
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin 
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding

2013-07-01 Thread Alexey Shumkin
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 
> 
> > 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 < 
> > 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_c

[PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding

2013-06-26 Thread 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 
---
 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 s

[PATCH v7 5/5] pretty: --format output should honor logOutputEncoding

2013-06-26 Thread Alexey Shumkin
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 
---
 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-

[PATCH v7 3/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs

2013-06-26 Thread Alexey Shumkin
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin 
---
 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 twoZ
-7cd6c63 message oneZ
-1711bf9 add barZ
-af20c06 initialZ
+$head1 message twoZ
+$head2 message oneZ
+$head3 add barZ
+$head4 initialZ
 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 barZ
-af20c06 initialZ
+$head1   message two  Z
+$head2   message one  Z
+$head3 add barZ
+$head4 initialZ
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs

2013-06-26 Thread Alexey Shumkin
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin 
---
 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 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 <expect commit 1ed88da4a5b5ed8c449114ac131efc62178734c3 &&
+   echo  >expect commit $head3 &&
echo >>expect fooQbar &&
git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
nul_to_q actual &&
-- 
1.8.3.1.15.g5c23c1e

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 0/5] Reroll patches against v1.8.3.1

2013-06-26 Thread Alexey Shumkin
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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 2/5] t7102 (reset): don't hardcode SHA-1 in expected outputs

2013-06-26 Thread Alexey Shumkin
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin 
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 0/5] Reroll patches against v1.8.3.1

2013-06-26 Thread Alexey Shumkin
On Tue, Jun 25, 2013 at 12:28:02PM -0700, Junio C Hamano wrote:
> Alexey Shumkin  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  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  > +# usage: test_format [failure] name format_string  >  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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs

2013-06-25 Thread Alexey Shumkin
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin 
---
 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 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 <expect commit 1ed88da4a5b5ed8c449114ac131efc62178734c3 &&
+   echo  >expect commit $head3 &&
echo >>expect fooQbar &&
git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
nul_to_q actual &&
-- 
1.8.3.1.15.g5c23c1e

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 3/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs

2013-06-25 Thread Alexey Shumkin
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin 
---
 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 twoZ
-7cd6c63 message oneZ
-1711bf9 add barZ
-af20c06 initialZ
+$head1 message twoZ
+$head2 message oneZ
+$head3 add barZ
+$head4 initialZ
 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 barZ
-af20c06 initialZ
+$head1   message two  Z
+$head2   message one  Z
+$head3 add barZ
+$head4 initialZ
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding

2013-06-25 Thread 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 
---
 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 s

[PATCH v6 0/5] Reroll patches against v1.8.3.1

2013-06-25 Thread Alexey Shumkin
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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 5/5] pretty: --format output should honor logOutputEncoding

2013-06-25 Thread Alexey Shumkin
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 
---
 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/t

[PATCH v6 2/5] t7102 (reset): don't hardcode SHA-1 in expected outputs

2013-06-25 Thread Alexey Shumkin
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin 
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 3/5] t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs

2013-06-20 Thread Alexey Shumkin
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin 
---
 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 twoZ
-7cd6c63 message oneZ
-1711bf9 add barZ
-af20c06 initialZ
+$head1 message twoZ
+$head2 message oneZ
+$head3 add barZ
+$head4 initialZ
 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 barZ
-af20c06 initialZ
+$head1   message two  Z
+$head2   message one  Z
+$head3 add barZ
+$head4 initialZ
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2013-06-20 Thread Alexey Shumkin
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 
---
 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 &&

[PATCH v5 2/5] t7102 (reset): don't hardcode SHA-1 in expected outputs

2013-06-20 Thread Alexey Shumkin
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin 
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 4/5] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting

2013-06-20 Thread Alexey Shumkin
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 
---
 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 ($a

[PATCH v5 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs

2013-06-20 Thread Alexey Shumkin
The expected SHA-1 digests are always available in variables. Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin 
---
 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 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 <expect commit 1ed88da4a5b5ed8c449114ac131efc62178734c3 &&
+   echo  >expect commit $head3 &&
echo >>expect fooQbar &&
git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
nul_to_q actual &&
-- 
1.8.3.1.15.g5c23c1e

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 0/5] Reroll patches against v1.8.3.1

2013-06-20 Thread Alexey Shumkin
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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/2] git-web--browser: avoid errors in terminal when running Firefox on Windows

2013-01-25 Thread Alexey Shumkin
Firefox on Windows by default is placed in "C:\Program Files\Mozilla Firefox"
folder, i.e. its path contains spaces. Before running this browser 
"git-web--browse"
tests version of Firefox to decide whether to use "-new-tab" option or not.

Quote browser path to avoid error during this test.

Signed-off-by: Alexey Shumkin 
Reviewed-by: Jeff King 
---
 git-web--browse.sh |  2 +-
 t/t9901-git-web--browse.sh | 53 +-
 2 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/git-web--browse.sh b/git-web--browse.sh
index 1e82726..f96e5bd 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -149,7 +149,7 @@ fi
 case "$browser" in
 firefox|iceweasel|seamonkey|iceape)
# Check version because firefox < 2.0 does not support "-new-tab".
-   vers=$(expr "$($browser_path -version)" : '.* \([0-9][0-9]*\)\..*')
+   vers=$(expr "$("$browser_path" -version)" : '.* \([0-9][0-9]*\)\..*')
NEWTAB='-new-tab'
test "$vers" -lt 2 && NEWTAB=''
"$browser_path" $NEWTAB "$@" &
diff --git a/t/t9901-git-web--browse.sh b/t/t9901-git-web--browse.sh
index b0dabf7..c1ee813 100755
--- a/t/t9901-git-web--browse.sh
+++ b/t/t9901-git-web--browse.sh
@@ -8,8 +8,23 @@ This test checks that git web--browse can handle various valid 
URLs.'
 . ./test-lib.sh
 
 test_web_browse () {
-   # browser=$1 url=$2
+   # browser=$1 url=$2 sleep_timeout=$3
+   sleep_timeout="$3"
+   rm -f fake_browser_ran &&
git web--browse --browser="$1" "$2" >actual &&
+   # if $3 is set
+   # as far as Firefox is run in background (it is run with &)
+   # we trying to avoid race condition
+   # by waiting for "$sleep_timeout" seconds of timeout for 
'fake_browser_ran' file appearance
+   if test -n "$sleep_timeout"
+   then
+   for timeout in $(test_seq $sleep_timeout)
+   do
+   test -f fake_browser_ran && break
+   sleep 1
+   done
+   test $timeout -ne $sleep_timeout
+   fi &&
tr -d '\015' text &&
test_cmp expect text
 }
@@ -46,6 +61,42 @@ test_expect_success \
 '
 
 test_expect_success \
+   'Paths are properly quoted for Firefox. Version older then v2.0' '
+   echo "fake: http://example.com/foo"; >expect &&
+   write_script "fake browser" <<-\EOF &&
+
+   if test "$1" = "-version"; then
+   echo "Fake Firefox browser version 1.2.3"
+   else
+   # Firefox (in contrast to w3m) is run in background (with &)
+   # so redirect output to "actual"
+   echo "fake: ""$@" >actual
+   fi
+   : >fake_browser_ran
+   EOF
+   git config browser.firefox.path "$(pwd)/fake browser" &&
+   test_web_browse firefox http://example.com/foo 5
+'
+
+test_expect_success \
+   'Paths are properly quoted for Firefox. Version v2.0 and above' '
+   echo "fake: -new-tab http://example.com/foo"; >expect &&
+   write_script "fake browser" <<-\EOF &&
+
+   if test "$1" = "-version"; then
+   echo "Fake Firefox browser version 2.0.0"
+   else
+   # Firefox (in contrast to w3m) is run in background (with &)
+   # so redirect output to "actual"
+   echo "fake: ""$@" >actual
+   fi
+   : >fake_browser_ran
+   EOF
+   git config browser.firefox.path "$(pwd)/fake browser" &&
+   test_web_browse firefox http://example.com/foo 5
+'
+
+test_expect_success \
'browser command allows arbitrary shell code' '
echo "arg: http://example.com/foo"; >expect &&
git config browser.custom.cmd "
-- 
1.8.1.1.10.g71fa0b7

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/2] t9901-git-web--browse.sh: Use "write_script" helper

2013-01-25 Thread Alexey Shumkin
Use "write_script" helper as suggested by Junio C Hamano.
Also, replace `pwd` with $(pwd) call convention.

Suggested-by: Junio C Hamano 
Signed-off-by: Alexey Shumkin 
---
 t/t9901-git-web--browse.sh | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/t/t9901-git-web--browse.sh b/t/t9901-git-web--browse.sh
index b0a6bad..b0dabf7 100755
--- a/t/t9901-git-web--browse.sh
+++ b/t/t9901-git-web--browse.sh
@@ -38,12 +38,10 @@ test_expect_success \
 test_expect_success \
'browser paths are properly quoted' '
echo fake: http://example.com/foo >expect &&
-   cat >"fake browser" <<-\EOF &&
-   #!/bin/sh
+   write_script "fake browser" <<-\EOF &&
echo fake: "$@"
EOF
-   chmod +x "fake browser" &&
-   git config browser.w3m.path "`pwd`/fake browser" &&
+   git config browser.w3m.path "$(pwd)/fake browser" &&
test_web_browse w3m http://example.com/foo
 '
 
-- 
1.8.1.1.10.g71fa0b7

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 0/2] git-web--browser: avoid errors in terminal when running

2013-01-25 Thread Alexey Shumkin
Reroll patch after all suggestions

Alexey Shumkin (2):
  t9901-git-web--browse.sh: Use "write_script" helper
  git-web--browser: avoid errors in terminal when running Firefox on
Windows

 git-web--browse.sh |  2 +-
 t/t9901-git-web--browse.sh | 59 ++
 2 files changed, 55 insertions(+), 6 deletions(-)

-- 
1.8.1.1.10.g71fa0b7

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH resent] send-email: Honor multi-part email messages

2013-01-25 Thread Alexey Shumkin
Let's try to involve Krzysztof Mazur 
who have met the similar problem recently
(according to this thread 
http://thread.gmane.org/gmane.comp.version-control.git/208297/focus=208310)
I recitate myself:
>Well, as I understand "current" algorithm:
>1. It assumes that file is one-part email message
>2. Function searches non-ASCII characters in Subject header
>3. If none then it looks non-ASCII characters at message body
>
>my changes are to skip looking at message body of a multi-part
>message as it has parts with their own Content-Type headers
>
>The said above in details:
>1. To set flag when we meet Content-Type: multipart/mixed header
>2. After we processed all headers and did not found non-ASCII characters
>in a Subject we take a look at this flag and exit with 0
>if it is a multi-part message


>>I think your patch is wrong.  What happens when we see a Subject:
>>line with a non-ascii on it that causes an early return of the loop
>>before your new code has a chance to see Content-Type: header?
This function is used to determine "broken" (non-ASCII) headers (to be encode 
them)
The problem is if "Subject" is not broken, but message body contains non-ASCII 
chars,
subject is marked as broken and encoded again.

P.S.
To involved: the beginning of thread is here 
http://thread.gmane.org/gmane.comp.version-control.git/181743

Alexey Shumkin (1):
  send-email: Honor multi-part email messages

 git-send-email.perl   |  5 
 t/t9001-send-email.sh | 66 +++
 2 files changed, 71 insertions(+)

-- 
1.8.1.1.10.g9255f3f

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] send-email: Honor multi-part email messages

2013-01-25 Thread Alexey Shumkin
"git format-patch --attach/--inline" generates multi-part messages.
Every part of such messages can contain non-ASCII characters with its own
"Content-Type" and "Content-Transfer-Encoding" headers.
But git-send-mail script interprets a patch-file as one-part message
and does not recognize multi-part messages.
So already quoted printable email subject may be encoded as quoted printable
again. Due to this bug email subject looks corrupted in email clients.

Signed-off-by: Alexey Shumkin 
---
 git-send-email.perl   |  5 
 t/t9001-send-email.sh | 66 +++
 2 files changed, 71 insertions(+)

diff --git a/git-send-email.perl b/git-send-email.perl
index 94c7f76..d49befe 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1499,12 +1499,17 @@ sub file_has_nonascii {
 
 sub body_or_subject_has_nonascii {
my $fn = shift;
+   my $multipart = 0;
open(my $fh, '<', $fn)
or die "unable to open $fn: $!\n";
while (my $line = <$fh>) {
last if $line =~ /^$/;
+   if ($line =~ /^Content-Type:\s*multipart\/mixed.*$/) {
+   $multipart = 1;
+   }
return 1 if $line =~ /^Subject.*[^[:ascii:]]/;
}
+   return 0 if $multipart;
while (my $line = <$fh>) {
return 1 if $line =~ /[^[:ascii:]]/;
}
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 97d6f4c..c7ed370 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -1323,4 +1323,70 @@ test_expect_success $PREREQ 
'sendemail.aliasfile=~/.mailrc' '
grep "^!someone@example\.org!$" commandline1
 '
 
+test_expect_success $PREREQ 'setup multi-part message' '
+cat >multi-part-email-using-8bit <
+From: aut...@example.com
+Date: Sat, 12 Jun 2010 15:53:58 +0200
+Subject: [PATCH] 
=?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=20?=
+ =?UTF-8?q?=D1=84=D0=B0=D0=B9=D0=BB?=
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="123"
+
+This is a multi-part message in MIME format.
+--1.7.6.3.4.gf71f
+Content-Type: text/plain; charset=UTF-8; format=fixed
+Content-Transfer-Encoding: 8bit
+
+This is a message created with "git format-patch --attach=123"
+---
+ master   |1 +
+ файл |1 +
+ 2 files changed, 2 insertions(+), 0 deletions(-)
+ create mode 100644 master
+ create mode 100644 файл
+
+
+--123
+Content-Type: text/x-patch; name="0001-.patch"
+Content-Transfer-Encoding: 8bit
+Content-Disposition: attachment; filename="0001-.patch"
+
+diff --git a/master b/master
+new file mode 100644
+index 000..1f7391f
+--- /dev/null
 b/master
+@@ -0,0 +1 @@
++master
+diff --git a/файл b/файл
+new file mode 100644
+index 000..44e5cfe
+--- /dev/null
 b/файл
+@@ -0,0 +1 @@
++содержимое файла
+
+--123--
+EOF
+'
+
+test_expect_success $PREREQ 'setup expect' '
+cat >expected <stdout &&
+   grep "Subject" msgtxt1 >actual &&
+   test_cmp expected actual
+'
+
 test_done
-- 
1.8.1.1.10.g9255f3f

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 1/4] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs

2013-01-25 Thread Alexey Shumkin
> Alexey Shumkin  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!
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] git-web--browser: avoid errors in terminal when running Firefox on Windows

2013-01-25 Thread Alexey Shumkin
Firefox on Windows by default is placed in "C:\Program Files\Mozilla Firefox"
folder, i.e. its path contains spaces. Before running this browser 
"git-web--browse"
tests version of Firefox to decide whether to use "-new-tab" option or not.

Quote browser path to avoid error during this test.

Signed-off-by: Alexey Shumkin 
Reviewed-by: Jeff King 
---
 git-web--browse.sh |  2 +-
 t/t9901-git-web--browse.sh | 57 +-
 2 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/git-web--browse.sh b/git-web--browse.sh
index 1e82726..f96e5bd 100755
--- a/git-web--browse.sh
+++ b/git-web--browse.sh
@@ -149,7 +149,7 @@ fi
 case "$browser" in
 firefox|iceweasel|seamonkey|iceape)
# Check version because firefox < 2.0 does not support "-new-tab".
-   vers=$(expr "$($browser_path -version)" : '.* \([0-9][0-9]*\)\..*')
+   vers=$(expr "$("$browser_path" -version)" : '.* \([0-9][0-9]*\)\..*')
NEWTAB='-new-tab'
test "$vers" -lt 2 && NEWTAB=''
"$browser_path" $NEWTAB "$@" &
diff --git a/t/t9901-git-web--browse.sh b/t/t9901-git-web--browse.sh
index b0a6bad..30d5294 100755
--- a/t/t9901-git-web--browse.sh
+++ b/t/t9901-git-web--browse.sh
@@ -8,8 +8,21 @@ This test checks that git web--browse can handle various valid 
URLs.'
 . ./test-lib.sh
 
 test_web_browse () {
-   # browser=$1 url=$2
+   # browser=$1 url=$2 sleep_timeout=$3
+   sleep_timeout="$3"
git web--browse --browser="$1" "$2" >actual &&
+   # if $3 is set
+   # as far as Firefox is run in background (it is run with &)
+   # we trying to avoid race condition
+   # by waiting for "$sleep_timeout" seconds of timeout for 
'fake_browser_ran' file appearance
+   (test -z "$sleep_timeout" || (
+   for timeout in $(seq 1 $sleep_timeout); do
+   test -f fake_browser_ran && break
+   sleep 1
+   done
+   test $timeout -ne $sleep_timeout
+   )
+   ) &&
tr -d '\015' text &&
test_cmp expect text
 }
@@ -48,6 +61,48 @@ test_expect_success \
 '
 
 test_expect_success \
+   'Firefox below v2.0 paths are properly quoted' '
+   echo fake: http://example.com/foo >expect &&
+   rm -f fake_browser_ran &&
+   cat >"fake browser" <<-\EOF &&
+   #!/bin/sh
+
+   : > fake_browser_ran
+   if test "$1" = "-version"; then
+   echo Fake Firefox browser version 1.2.3
+   else
+   # Firefox (in contrast to w3m) is run in background (with &)
+   # so redirect output to "actual"
+   echo fake: "$@" > actual
+   fi
+   EOF
+   chmod +x "fake browser" &&
+   git config browser.firefox.path "`pwd`/fake browser" &&
+   test_web_browse firefox http://example.com/foo 5
+'
+
+test_expect_success \
+   'Firefox not lower v2.0 paths are properly quoted' '
+   echo fake: -new-tab http://example.com/foo >expect &&
+   rm -f fake_browser_ran &&
+   cat >"fake browser" <<-\EOF &&
+   #!/bin/sh
+
+   : > fake_browser_ran
+   if test "$1" = "-version"; then
+   echo Fake Firefox browser version 2.0.0
+   else
+   # Firefox (in contrast to w3m) is run in background (with &)
+   # so redirect output to "actual"
+   echo fake: "$@" > actual
+   fi
+   EOF
+   chmod +x "fake browser" &&
+   git config browser.firefox.path "`pwd`/fake browser" &&
+   test_web_browse firefox http://example.com/foo 5
+'
+
+test_expect_success \
'browser command allows arbitrary shell code' '
echo "arg: http://example.com/foo"; >expect &&
git config browser.custom.cmd "
-- 
1.8.1.1.10.g9255f3f

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 1/4] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs

2013-01-25 Thread Alexey Shumkin
> 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?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 1/4] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs

2013-01-25 Thread Alexey Shumkin
> Alexey Shumkin  writes:
> 
> > The expected SHA-1 digests are always available in variables.  Use
> > them instead of hardcoding.
> >
> > Signed-off-by: Alexey Shumkin 
> > ---
> >  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.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 2/4] t7102 (reset): refactoring: don't hardcode SHA-1 in expected outputs

2013-01-25 Thread Alexey Shumkin
> Alexey Shumkin  writes:
> 
> > The expected SHA-1 digests are always available in variables.  Use
> > them instead of hardcoding.
> >
> > Signed-off-by: Alexey Shumkin 
> > ---
> 
> 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 aa &&
> > test_must_fail git reset --soft aa &&
> > test_must_fail git reset --hard aa &&
> > -   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
>

Re: [PATCH v4 3/4] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting

2013-01-25 Thread Alexey Shumkin
> Alexey Shumkin  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 
> > ---
> >  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.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 3/4] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting

2013-01-25 Thread Alexey Shumkin
> Alexey Shumkin  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 < > +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 < >  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"?

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] mergetool--lib: fix startup options for gvimdiff tool

2013-01-25 Thread Alexey Shumkin
Maybe, some time ;)
Actually, I'm not TCL-programmer. With one of these patches I just have
solved one my problem (to run tortoisemerge with git-gui) when I
was showing to my collegue how to work with Git, and on the side I
fixed another two bugs. So, I decided to sumbit these patches, to avoid
applying them every time after each Git update as I did last 1.5 years
with other patches which still are not submitted, because I'm too lazy
to follow Git development workflow in my free time )

> On Wed, Jan 23, 2013 at 11:16 PM, Alexey Shumkin
>  wrote:
> > Options are taken from /mergetools/vim
> >
> > Signed-off-by: Alexey Shumkin 
> > ---
> >  git-gui/lib/mergetool.tcl | 8 +++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> A better long-term solution might be to teach git gui to use "git
> difftool".
> 
> Would it be better to teach git-gui (and gitk) about
> mergetool/difftool? That would allow us to possibly eliminate this
> duplication.
> 
> We did start towards that path when difftool learned the --extcmd
> option (for use by gitk) but I have not followed through.
> 
> What do you think about trying that approach?
> 
> 
> > diff --git a/git-gui/lib/mergetool.tcl b/git-gui/lib/mergetool.tcl
> > index 3c8e73b..4fc1cab 100644
> > --- a/git-gui/lib/mergetool.tcl
> > +++ b/git-gui/lib/mergetool.tcl
> > @@ -211,7 +211,13 @@ proc merge_resolve_tool2 {} {
> > }
> > }
> > gvimdiff {
> > -   set cmdline [list "$merge_tool_path" -f "$LOCAL"
> > "$MERGED" "$REMOTE"]
> > +   if {$base_stage ne {}} {
> > +   set cmdline [list "$merge_tool_path" -f -d
> > -c "wincmd J" \
> > +   "$MERGED" "$LOCAL" "$BASE"
> > "$REMOTE"]
> > +   } else {
> > +   set cmdline [list "$merge_tool_path" -f -d
> > -c "wincmd l" \
> > +   "$LOCAL" "$MERGED" "$REMOTE"]
> > +   }
> > }
> > kdiff3 {
> > if {$base_stage ne {}} {
> > --
> > 1.8.1.1.10.g9255f3f
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe git" in
> > the body of a message to majord...@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] send-email: Honor multi-part email messages

2013-01-24 Thread Alexey Shumkin
Bump
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  1   2   >