From 3e065308cab1ac0855bf19be8881def74bfcf7fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kr=C3=BCger?= Date: Mon, 30 Apr 2012 22:28:25 +0200 Subject: log-tree: use custom line terminator in line termination mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using a custom format in line termination mode (as opposed to line separation mode), the configured line terminator is not used, so things like "git log --pretty=tformat:%H -z" do not work properly. Make it use the line terminator the user ordered. Signed-off-by: Jan Krüger Signed-off-by: Junio C Hamano --- t/t4205-log-pretty-formats.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 't/t4205-log-pretty-formats.sh') diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index 2ae9faa8b3..f00e446820 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -71,4 +71,16 @@ test_expect_success 'alias loop' ' test_must_fail git log --pretty=test-foo ' +test_expect_success 'NUL separation' ' + printf "add bar\0initial" >expected && + git log -z --pretty="format:%s" >actual && + test_cmp expected actual +' + +test_expect_success 'NUL termination' ' + printf "add bar\0initial\0" >expected && + git log -z --pretty="tformat:%s" >actual && + test_cmp expected actual +' + test_done -- cgit v1.2.1 From fafd38299bb6ff5634de89bcca35f622005d0279 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 1 May 2012 10:29:43 -0700 Subject: log-tree: the previous one is still not quite right The correct output would have NUL after each commit, so "-z --format=%s" would have a single-liner subject with the line-terminating LF replaced with NUL, and "-p/--stat -z --format=%s" would have a single-liner subject with its line-terminating LF, followed by the diff/diffstat in which the terminating LF of the last line is replaced with NUL, but to be consistent with what "-p/--stat -z --pretty=format:%s" does, I think it is OK to append NUL to the diff/diffstat part instead of replacing its last LF with NUL. The added test shows the update is still not right for "-p -z --format". Signed-off-by: Junio C Hamano --- t/t4205-log-pretty-formats.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 't/t4205-log-pretty-formats.sh') diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index f00e446820..4afd77815f 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -83,4 +83,20 @@ test_expect_success 'NUL termination' ' test_cmp expected actual ' +test_expect_success 'NUL separation with --stat' ' + stat0_part=$(git diff --stat HEAD^ HEAD) && + stat1_part=$(git diff --stat --root HEAD^) && + printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n" >expected && + git log -z --stat --pretty="format:%s" >actual && + test_cmp expected actual +' + +test_expect_failure 'NUL termination with --stat' ' + stat0_part=$(git diff --stat HEAD^ HEAD) && + stat1_part=$(git diff --stat --root HEAD^) && + printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n\0" >expected && + git log -z --stat --pretty="tformat:%s" >actual && + test_cmp expected actual +' + test_done -- cgit v1.2.1 From b354f11b595bb2bca4bae96b06778b3a9882b621 Mon Sep 17 00:00:00 2001 From: Jiang Xin Date: Mon, 27 Aug 2012 13:36:51 +0800 Subject: Fix tests under GETTEXT_POISON on diffstat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the i18n-specific test functions in test scripts for diffstat. This issue was was introduced in v1.7.9-1-g7f814: 7f814 Use correct grammar in diffstat summary line and been broken under GETTEXT_POISON=YesPlease since. Signed-off-by: Jiang Xin Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- t/t4205-log-pretty-formats.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/t4205-log-pretty-formats.sh') diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index 4afd77815f..2c45de7aea 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -88,7 +88,7 @@ test_expect_success 'NUL separation with --stat' ' stat1_part=$(git diff --stat --root HEAD^) && printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n" >expected && git log -z --stat --pretty="format:%s" >actual && - test_cmp expected actual + test_i18ncmp expected actual ' test_expect_failure 'NUL termination with --stat' ' @@ -96,7 +96,7 @@ test_expect_failure 'NUL termination with --stat' ' stat1_part=$(git diff --stat --root HEAD^) && printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n\0" >expected && git log -z --stat --pretty="tformat:%s" >actual && - test_cmp expected actual + test_i18ncmp expected actual ' test_done -- cgit v1.2.1 From 74faaa16f016af9fc429770ba701f2aa598d9f21 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 17 Oct 2012 10:00:37 -0700 Subject: Fix "git diff --stat" for interesting - but empty - file changes The behavior of "git diff --stat" is rather odd for files that have zero lines of changes: it will discount them entirely unless they were renames. Which means that the stat output will simply not show files that only had "other" changes: they were created or deleted, or their mode was changed. Now, those changes do show up in the summary, but so do renames, so the diffstat logic is inconsistent. Why does it show renames with zero lines changed, but not mode changes or added files with zero lines changed? So change the logic to not check for "is_renamed", but for "is_interesting" instead, where "interesting" is judged to be any action but a pure data change (because a pure data change with zero data changed really isn't worth showing, if we ever get one in our diffpairs). So if you did chmod +x Makefile git diff --stat before, it would show empty (" 0 files changed"), with this it shows Makefile | 0 1 file changed, 0 insertions(+), 0 deletions(-) which I think is a more correct diffstat (and then with "--summary" it shows *what* the metadata change to Makefile was - this is completely consistent with our handling of renamed files). Side note: the old behavior was *really* odd. With no changes at all, "git diff --stat" output was empty. With just a chmod, it said "0 files changed". No way is our legacy behavior sane. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- t/t4205-log-pretty-formats.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/t4205-log-pretty-formats.sh') diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index 2c45de7aea..98a43d457a 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -85,7 +85,7 @@ test_expect_success 'NUL termination' ' test_expect_success 'NUL separation with --stat' ' stat0_part=$(git diff --stat HEAD^ HEAD) && - stat1_part=$(git diff --stat --root HEAD^) && + stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) && printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n" >expected && git log -z --stat --pretty="format:%s" >actual && test_i18ncmp expected actual @@ -93,7 +93,7 @@ test_expect_success 'NUL separation with --stat' ' test_expect_failure 'NUL termination with --stat' ' stat0_part=$(git diff --stat HEAD^ HEAD) && - stat1_part=$(git diff --stat --root HEAD^) && + stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) && printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n\0" >expected && git log -z --stat --pretty="tformat:%s" >actual && test_i18ncmp expected actual -- cgit v1.2.1 From a57523428b4c08795e793356e12afc3de812f84a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Fri, 19 Apr 2013 09:08:50 +1000 Subject: pretty: support padding placeholders, %< %> and %>< MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Either %<, %> or %>< standing before a placeholder specifies how many columns (at least as the placeholder can exceed it) it takes. Each differs on how spaces are padded: %< pads on the right (aka left alignment) %> pads on the left (aka right alignment) %>< pads both ways equally (aka centered) The () follows them, e.g. `%<(100)', to specify the number of columns the next placeholder takes. However, if '|' stands before (), e.g. `%>|(100)', then the number of columns is calculated so that it reaches the Nth column on screen. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- t/t4205-log-pretty-formats.sh | 122 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) (limited to 't/t4205-log-pretty-formats.sh') diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index 98a43d457a..88f2427985 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -99,4 +99,126 @@ test_expect_failure 'NUL termination with --stat' ' test_i18ncmp expected actual ' +test_expect_success 'setup more commits' ' + test_commit "message one" one one message-one && + test_commit "message two" two two message-two +' + +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 && +message two Z +message one Z +add bar Z +initial 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 + echo >>actual && + qz_to_tab_space <<\EOF >expected && +fa33ab1 message two Z +7cd6c63 message one Z +1711bf9 add bar Z +af20c06 initial 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 + echo >>actual && + cat <<\EOF >expected && +message two +message one +add bar +initial +EOF + test_cmp expected actual +' + +test_expect_success 'right alignment formatting' ' + git log --pretty="format:%>(40)%s" >actual && + # complete the incomplete line at the end + echo >>actual && + qz_to_tab_space <<\EOF >expected && +Z message two +Z message one +Z add bar +Z initial +EOF + test_cmp expected 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 +EOF + test_cmp expected actual +' + +test_expect_success 'right alignment formatting with no padding' ' + git log --pretty="format:%>(1)%s" >actual && + # complete the incomplete line at the end + echo >>actual && + cat <<\EOF >expected && +message two +message one +add bar +initial +EOF + test_cmp expected actual +' + +test_expect_success 'center alignment formatting' ' + git log --pretty="format:%><(40)%s" >actual && + # complete the incomplete line at the end + echo >>actual && + qz_to_tab_space <<\EOF >expected && +Z message two Z +Z message one Z +Z add bar Z +Z initial Z +EOF + test_cmp expected actual +' + +test_expect_success 'center alignment formatting at the nth column' ' + git log --pretty="format:%h %><|(40)%s" >actual && + # complete the incomplete line at the end + echo >>actual && + qz_to_tab_space <<\EOF >expected && +fa33ab1 message two Z +7cd6c63 message one Z +1711bf9 add bar Z +af20c06 initial Z +EOF + test_cmp expected actual +' + +test_expect_success 'center alignment formatting with no padding' ' + git log --pretty="format:%><(1)%s" >actual && + # complete the incomplete line at the end + echo >>actual && + cat <<\EOF >expected && +message two +message one +add bar +initial +EOF + test_cmp expected actual +' + test_done -- cgit v1.2.1 From a7f01c6b4ddf9f2f6bdcb23fc7afb56695807cba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Fri, 19 Apr 2013 09:08:51 +1000 Subject: pretty: support truncating in %>, %< and %>< MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit %>(N,trunc) truncates the right part after N columns and replace the last two letters with "..". ltrunc does the same on the left. mtrunc cuts the middle out. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- t/t4205-log-pretty-formats.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 't/t4205-log-pretty-formats.sh') diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index 88f2427985..b8685b97f9 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -143,6 +143,45 @@ 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 + echo >>actual && + qz_to_tab_space <<\EOF >expected && +message .. +message .. +add bar Z +initial Z +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 + echo >>actual && + qz_to_tab_space <<\EOF >expected && +..sage two +..sage one +add bar Z +initial Z +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 + echo >>actual && + qz_to_tab_space <<\EOF >expected && +mess.. two +mess.. one +add bar Z +initial Z +EOF + test_cmp expected actual +' + test_expect_success 'right alignment formatting' ' git log --pretty="format:%>(40)%s" >actual && # complete the incomplete line at the end -- cgit v1.2.1 From 1640632b4f3f69775f04e9e40dfd2fd912e0f458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Fri, 19 Apr 2013 09:08:52 +1000 Subject: pretty: support %>> that steal trailing spaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is pretty useful in `%<(100)%s%Cred%>(20)% an' where %s does not use up all 100 columns and %an needs more than 20 columns. By replacing %>(20) with %>>(20), %an can steal spaces from %s. %>> understands escape sequences, so %Cred does not stop it from stealing spaces in %<(100). Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- t/t4205-log-pretty-formats.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 't/t4205-log-pretty-formats.sh') diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index b8685b97f9..26fbfde4a3 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -260,4 +260,18 @@ EOF test_cmp expected actual ' +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 && + # complete the incomplete line at the end + echo >>actual && + cat <<\EOF >expected && +short long long long +message .. A U Thor +add bar A U Thor +initial A U Thor +EOF + test_cmp expected actual +' + test_done -- cgit v1.2.1 From a742f2a0a7e57bb7d3f55cb8312c3f4cc4dc68fb Mon Sep 17 00:00:00 2001 From: Alexey Shumkin Date: Wed, 26 Jun 2013 14:19:48 +0400 Subject: t4205 (log-pretty-formats): don't hardcode SHA-1 in expected outputs The expected SHA-1 digests are always available in variables. Use them instead of hardcoding. Signed-off-by: Alexey Shumkin Signed-off-by: Junio C Hamano --- t/t4205-log-pretty-formats.sh | 48 +++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 't/t4205-log-pretty-formats.sh') diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index 26fbfde4a3..73ba5e8f0c 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -101,7 +101,11 @@ test_expect_failure 'NUL termination with --stat' ' test_expect_success 'setup more commits' ' test_commit "message one" one one message-one && - test_commit "message two" two two message-two + test_commit "message two" two two message-two && + head1=$(git rev-parse --verify --short HEAD~0) && + head2=$(git rev-parse --verify --short HEAD~1) && + head3=$(git rev-parse --verify --short HEAD~2) && + head4=$(git rev-parse --verify --short HEAD~3) ' test_expect_success 'left alignment formatting' ' @@ -117,18 +121,18 @@ EOF test_cmp expected actual ' -test_expect_success 'left alignment formatting at the nth column' ' - git log --pretty="format:%h %<|(40)%s" >actual && +test_expect_success 'left alignment formatting at the nth column' " + git log --pretty='format:%h %<|(40)%s' >actual && # complete the incomplete line at the end echo >>actual && qz_to_tab_space <<\EOF >expected && -fa33ab1 message two Z -7cd6c63 message one Z -1711bf9 add bar Z -af20c06 initial Z +$head1 message two Z +$head2 message one Z +$head3 add bar Z +$head4 initial Z EOF test_cmp expected actual -' +" test_expect_success 'left alignment formatting with no padding' ' git log --pretty="format:%<(1)%s" >actual && @@ -195,18 +199,18 @@ EOF test_cmp expected actual ' -test_expect_success 'right alignment formatting at the nth column' ' - git log --pretty="format:%h %>|(40)%s" >actual && +test_expect_success 'right alignment formatting at the nth column' " + git log --pretty='format:%h %>|(40)%s' >actual && # complete the incomplete line at the end echo >>actual && qz_to_tab_space <<\EOF >expected && -fa33ab1 message two -7cd6c63 message one -1711bf9 add bar -af20c06 initial +$head1 message two +$head2 message one +$head3 add bar +$head4 initial EOF test_cmp expected actual -' +" test_expect_success 'right alignment formatting with no padding' ' git log --pretty="format:%>(1)%s" >actual && @@ -234,18 +238,18 @@ EOF test_cmp expected actual ' -test_expect_success 'center alignment formatting at the nth column' ' - git log --pretty="format:%h %><|(40)%s" >actual && +test_expect_success 'center alignment formatting at the nth column' " + git log --pretty='format:%h %><|(40)%s' >actual && # complete the incomplete line at the end echo >>actual && qz_to_tab_space <<\EOF >expected && -fa33ab1 message two Z -7cd6c63 message one Z -1711bf9 add bar Z -af20c06 initial Z +$head1 message two Z +$head2 message one Z +$head3 add bar Z +$head4 initial Z EOF test_cmp expected actual -' +" test_expect_success 'center alignment formatting with no padding' ' git log --pretty="format:%><(1)%s" >actual && -- cgit v1.2.1 From de6029a2d7734a93a9e27b9c4471862a47dd8123 Mon Sep 17 00:00:00 2001 From: Alexey Shumkin Date: Wed, 26 Jun 2013 14:19:49 +0400 Subject: pretty: Add failing tests: --format output should honor logOutputEncoding 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 Signed-off-by: Junio C Hamano --- t/t4205-log-pretty-formats.sh | 149 ++++++++++++++++++++++++++---------------- 1 file changed, 93 insertions(+), 56 deletions(-) (limited to 't/t4205-log-pretty-formats.sh') diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index 73ba5e8f0c..d45aa994e6 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -1,20 +1,43 @@ #!/bin/sh # # Copyright (c) 2010, Will Palmer +# Copyright (c) 2011, Alexey Shumkin (+ non-UTF-8 commit encoding tests) # test_description='Test pretty formats' . ./test-lib.sh +commit_msg () { + # String "initial. initial" partly in German (translated with Google Translate), + # encoded in UTF-8, used as a commit log message below. + msg=$(printf "initial. anf\303\244nglich") + if test -n "$1" + then + msg=$(echo $msg | iconv -f utf-8 -t $1) + fi + if test -n "$2" -a -n "$3" + then + # cut string, replace cut part with two dots + # $2 - chars count from the beginning of the string + # $3 - "trailing" chars + # LC_ALL is set to make `sed` interpret "." as a UTF-8 char not a byte + # as it does with C locale + msg=$(echo $msg | LC_ALL=en_US.UTF-8 sed -e "s/^\(.\{$2\}\)$3/\1../") + fi + echo $msg +} + test_expect_success 'set up basic repos' ' >foo && >bar && git add foo && test_tick && - git commit -m initial && + git config i18n.commitEncoding iso-8859-1 && + git commit -m "$(commit_msg iso-8859-1)" && git add bar && test_tick && - git commit -m "add bar" + git commit -m "add bar" && + git config --unset i18n.commitEncoding ' test_expect_success 'alias builtin format' ' @@ -38,6 +61,20 @@ test_expect_success 'alias user-defined format' ' test_cmp expected actual ' +test_expect_success 'alias user-defined tformat with %s (iso-8859-1 encoding)' ' + git config i18n.logOutputEncoding iso-8859-1 && + git log --oneline >expected-s && + git log --pretty="tformat:%h %s" >actual-s && + git config --unset i18n.logOutputEncoding && + test_cmp expected-s actual-s +' + +test_expect_failure 'alias user-defined tformat with %s (utf-8 encoding)' ' + git log --oneline >expected-s && + git log --pretty="tformat:%h %s" >actual-s && + test_cmp expected-s actual-s +' + test_expect_success 'alias user-defined tformat' ' git log --pretty="tformat:%h" >expected && git config pretty.test-alias "tformat:%h" && @@ -71,22 +108,22 @@ test_expect_success 'alias loop' ' test_must_fail git log --pretty=test-foo ' -test_expect_success 'NUL separation' ' - printf "add bar\0initial" >expected && +test_expect_failure 'NUL separation' ' + printf "add bar\0$(commit_msg)" >expected && git log -z --pretty="format:%s" >actual && test_cmp expected actual ' -test_expect_success 'NUL termination' ' - printf "add bar\0initial\0" >expected && +test_expect_failure 'NUL termination' ' + printf "add bar\0$(commit_msg)\0" >expected && git log -z --pretty="tformat:%s" >actual && test_cmp expected actual ' -test_expect_success 'NUL separation with --stat' ' +test_expect_failure 'NUL separation with --stat' ' stat0_part=$(git diff --stat HEAD^ HEAD) && stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) && - printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n" >expected && + printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected && git log -z --stat --pretty="format:%s" >actual && test_i18ncmp expected actual ' @@ -94,7 +131,7 @@ test_expect_success 'NUL separation with --stat' ' test_expect_failure 'NUL termination with --stat' ' stat0_part=$(git diff --stat HEAD^ HEAD) && stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) && - printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n\0" >expected && + printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n0" >expected && git log -z --stat --pretty="tformat:%s" >actual && test_i18ncmp expected actual ' @@ -108,20 +145,20 @@ test_expect_success 'setup more commits' ' head4=$(git rev-parse --verify --short HEAD~3) ' -test_expect_success 'left alignment formatting' ' - git log --pretty="format:%<(40)%s" >actual && +test_expect_failure 'left alignment formatting' " + git log --pretty='format:%<(40)%s' >actual && # complete the incomplete line at the end echo >>actual && qz_to_tab_space <<\EOF >expected && message two Z message one Z add bar Z -initial Z +$(commit_msg) Z EOF test_cmp expected actual -' +" -test_expect_success 'left alignment formatting at the nth column' " +test_expect_failure 'left alignment formatting at the nth column' " git log --pretty='format:%h %<|(40)%s' >actual && # complete the incomplete line at the end echo >>actual && @@ -129,77 +166,77 @@ test_expect_success 'left alignment formatting at the nth column' " $head1 message two Z $head2 message one Z $head3 add bar Z -$head4 initial Z +$head4 $(commit_msg) Z EOF test_cmp expected actual " -test_expect_success 'left alignment formatting with no padding' ' - git log --pretty="format:%<(1)%s" >actual && +test_expect_failure 'left alignment formatting with no padding' " + git log --pretty='format:%<(1)%s' >actual && # complete the incomplete line at the end echo >>actual && cat <<\EOF >expected && message two message one add bar -initial +$(commit_msg) EOF test_cmp expected actual -' +" -test_expect_success 'left alignment formatting with trunc' ' - git log --pretty="format:%<(10,trunc)%s" >actual && +test_expect_failure 'left alignment formatting with trunc' " + git log --pretty='format:%<(10,trunc)%s' >actual && # complete the incomplete line at the end echo >>actual && qz_to_tab_space <<\EOF >expected && message .. message .. add bar Z -initial Z +$(commit_msg "" "8" ".\+$") EOF test_cmp expected actual -' +" -test_expect_success 'left alignment formatting with ltrunc' ' - git log --pretty="format:%<(10,ltrunc)%s" >actual && +test_expect_failure 'left alignment formatting with ltrunc' " + git log --pretty='format:%<(10,ltrunc)%s' >actual && # complete the incomplete line at the end echo >>actual && qz_to_tab_space <<\EOF >expected && ..sage two ..sage one add bar Z -initial Z +$(commit_msg "" "0" ".\{11\}") EOF test_cmp expected actual -' +" -test_expect_success 'left alignment formatting with mtrunc' ' - git log --pretty="format:%<(10,mtrunc)%s" >actual && +test_expect_failure 'left alignment formatting with mtrunc' " + git log --pretty='format:%<(10,mtrunc)%s' >actual && # complete the incomplete line at the end echo >>actual && qz_to_tab_space <<\EOF >expected && mess.. two mess.. one add bar Z -initial Z +$(commit_msg "" "4" ".\{11\}") EOF test_cmp expected actual -' +" -test_expect_success 'right alignment formatting' ' - git log --pretty="format:%>(40)%s" >actual && +test_expect_failure 'right alignment formatting' " + git log --pretty='format:%>(40)%s' >actual && # complete the incomplete line at the end echo >>actual && qz_to_tab_space <<\EOF >expected && Z message two Z message one Z add bar -Z initial +Z $(commit_msg) EOF test_cmp expected actual -' +" -test_expect_success 'right alignment formatting at the nth column' " +test_expect_failure 'right alignment formatting at the nth column' " git log --pretty='format:%h %>|(40)%s' >actual && # complete the incomplete line at the end echo >>actual && @@ -207,38 +244,38 @@ test_expect_success 'right alignment formatting at the nth column' " $head1 message two $head2 message one $head3 add bar -$head4 initial +$head4 $(commit_msg) EOF test_cmp expected actual " -test_expect_success 'right alignment formatting with no padding' ' - git log --pretty="format:%>(1)%s" >actual && +test_expect_failure 'right alignment formatting with no padding' " + git log --pretty='format:%>(1)%s' >actual && # complete the incomplete line at the end echo >>actual && cat <<\EOF >expected && message two message one add bar -initial +$(commit_msg) EOF test_cmp expected actual -' +" -test_expect_success 'center alignment formatting' ' - git log --pretty="format:%><(40)%s" >actual && +test_expect_failure 'center alignment formatting' " + git log --pretty='format:%><(40)%s' >actual && # complete the incomplete line at the end echo >>actual && qz_to_tab_space <<\EOF >expected && Z message two Z Z message one Z Z add bar Z -Z initial Z +Z $(commit_msg) Z EOF test_cmp expected actual -' +" -test_expect_success 'center alignment formatting at the nth column' " +test_expect_failure 'center alignment formatting at the nth column' " git log --pretty='format:%h %><|(40)%s' >actual && # complete the incomplete line at the end echo >>actual && @@ -246,36 +283,36 @@ test_expect_success 'center alignment formatting at the nth column' " $head1 message two Z $head2 message one Z $head3 add bar Z -$head4 initial Z +$head4 $(commit_msg) Z EOF test_cmp expected actual " -test_expect_success 'center alignment formatting with no padding' ' - git log --pretty="format:%><(1)%s" >actual && +test_expect_failure 'center alignment formatting with no padding' " + git log --pretty='format:%><(1)%s' >actual && # complete the incomplete line at the end echo >>actual && cat <<\EOF >expected && message two message one add bar -initial +$(commit_msg) EOF test_cmp expected actual -' +" -test_expect_success 'left/right alignment formatting with stealing' ' - git commit --amend -m short --author "long long long " && - git log --pretty="format:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual && +test_expect_failure 'left/right alignment formatting with stealing' " + git commit --amend -m short --author 'long long long ' && + git log --pretty='format:%<(10,trunc)%s%>>(10,ltrunc)% an' >actual && # complete the incomplete line at the end echo >>actual && cat <<\EOF >expected && short long long long message .. A U Thor add bar A U Thor -initial A U Thor +$(commit_msg "" "8" ".\+$") A U Thor EOF test_cmp expected actual -' +" test_done -- cgit v1.2.1 From ecaee8050cec23eb4cf082512e907e3e52c20b57 Mon Sep 17 00:00:00 2001 From: Alexey Shumkin Date: Wed, 26 Jun 2013 14:19:50 +0400 Subject: pretty: --format output should honor logOutputEncoding 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 Signed-off-by: Junio C Hamano --- t/t4205-log-pretty-formats.sh | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 't/t4205-log-pretty-formats.sh') diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index d45aa994e6..719d132c6d 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -69,7 +69,7 @@ test_expect_success 'alias user-defined tformat with %s (iso-8859-1 encoding)' ' test_cmp expected-s actual-s ' -test_expect_failure 'alias user-defined tformat with %s (utf-8 encoding)' ' +test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' ' git log --oneline >expected-s && git log --pretty="tformat:%h %s" >actual-s && test_cmp expected-s actual-s @@ -108,19 +108,19 @@ test_expect_success 'alias loop' ' test_must_fail git log --pretty=test-foo ' -test_expect_failure 'NUL separation' ' +test_expect_success 'NUL separation' ' printf "add bar\0$(commit_msg)" >expected && git log -z --pretty="format:%s" >actual && test_cmp expected actual ' -test_expect_failure 'NUL termination' ' +test_expect_success 'NUL termination' ' printf "add bar\0$(commit_msg)\0" >expected && git log -z --pretty="tformat:%s" >actual && test_cmp expected actual ' -test_expect_failure 'NUL separation with --stat' ' +test_expect_success 'NUL separation with --stat' ' stat0_part=$(git diff --stat HEAD^ HEAD) && stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) && printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected && @@ -145,7 +145,7 @@ test_expect_success 'setup more commits' ' head4=$(git rev-parse --verify --short HEAD~3) ' -test_expect_failure 'left alignment formatting' " +test_expect_success 'left alignment formatting' " git log --pretty='format:%<(40)%s' >actual && # complete the incomplete line at the end echo >>actual && @@ -158,7 +158,7 @@ EOF test_cmp expected actual " -test_expect_failure 'left alignment formatting at the nth column' " +test_expect_success 'left alignment formatting at the nth column' " git log --pretty='format:%h %<|(40)%s' >actual && # complete the incomplete line at the end echo >>actual && @@ -171,7 +171,7 @@ EOF test_cmp expected actual " -test_expect_failure 'left alignment formatting with no padding' " +test_expect_success 'left alignment formatting with no padding' " git log --pretty='format:%<(1)%s' >actual && # complete the incomplete line at the end echo >>actual && @@ -184,7 +184,7 @@ EOF test_cmp expected actual " -test_expect_failure 'left alignment formatting with trunc' " +test_expect_success 'left alignment formatting with trunc' " git log --pretty='format:%<(10,trunc)%s' >actual && # complete the incomplete line at the end echo >>actual && @@ -197,7 +197,7 @@ EOF test_cmp expected actual " -test_expect_failure 'left alignment formatting with ltrunc' " +test_expect_success 'left alignment formatting with ltrunc' " git log --pretty='format:%<(10,ltrunc)%s' >actual && # complete the incomplete line at the end echo >>actual && @@ -210,7 +210,7 @@ EOF test_cmp expected actual " -test_expect_failure 'left alignment formatting with mtrunc' " +test_expect_success 'left alignment formatting with mtrunc' " git log --pretty='format:%<(10,mtrunc)%s' >actual && # complete the incomplete line at the end echo >>actual && @@ -223,7 +223,7 @@ EOF test_cmp expected actual " -test_expect_failure 'right alignment formatting' " +test_expect_success 'right alignment formatting' " git log --pretty='format:%>(40)%s' >actual && # complete the incomplete line at the end echo >>actual && @@ -236,7 +236,7 @@ EOF test_cmp expected actual " -test_expect_failure 'right alignment formatting at the nth column' " +test_expect_success 'right alignment formatting at the nth column' " git log --pretty='format:%h %>|(40)%s' >actual && # complete the incomplete line at the end echo >>actual && @@ -249,7 +249,7 @@ EOF test_cmp expected actual " -test_expect_failure 'right alignment formatting with no padding' " +test_expect_success 'right alignment formatting with no padding' " git log --pretty='format:%>(1)%s' >actual && # complete the incomplete line at the end echo >>actual && @@ -262,7 +262,7 @@ EOF test_cmp expected actual " -test_expect_failure 'center alignment formatting' " +test_expect_success 'center alignment formatting' " git log --pretty='format:%><(40)%s' >actual && # complete the incomplete line at the end echo >>actual && @@ -275,7 +275,7 @@ EOF test_cmp expected actual " -test_expect_failure 'center alignment formatting at the nth column' " +test_expect_success 'center alignment formatting at the nth column' " git log --pretty='format:%h %><|(40)%s' >actual && # complete the incomplete line at the end echo >>actual && @@ -288,7 +288,7 @@ EOF test_cmp expected actual " -test_expect_failure 'center alignment formatting with no padding' " +test_expect_success 'center alignment formatting with no padding' " git log --pretty='format:%><(1)%s' >actual && # complete the incomplete line at the end echo >>actual && @@ -301,7 +301,7 @@ EOF test_cmp expected actual " -test_expect_failure 'left/right alignment formatting with stealing' " +test_expect_success 'left/right alignment formatting with stealing' " git commit --amend -m short --author 'long long long ' && git log --pretty='format:%<(10,trunc)%s%>>(10,ltrunc)% an' >actual && # complete the incomplete line at the end -- cgit v1.2.1 From 7c37521487332fd700e2fa58bd2547d275e4f4d2 Mon Sep 17 00:00:00 2001 From: Brian Gernhardt Date: Mon, 1 Jul 2013 14:59:59 -0400 Subject: t4205: replace .\+ with ..* in sed commands OS X's sed only accepts basic regular expressions, which does not allow the + quantifier. However '..*' (anything, followed by zero or more anything) is the same as '.\+' (one or more anything) and valid in any regular expression language. Signed-off-by: Brian Gernhardt Signed-off-by: Junio C Hamano --- t/t4205-log-pretty-formats.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/t4205-log-pretty-formats.sh') diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index 719d132c6d..3cfb744017 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -192,7 +192,7 @@ test_expect_success 'left alignment formatting with trunc' " message .. message .. add bar Z -$(commit_msg "" "8" ".\+$") +$(commit_msg "" "8" "..*$") EOF test_cmp expected actual " @@ -310,7 +310,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 +$(commit_msg "" "8" "..*$") A U Thor EOF test_cmp expected actual " -- cgit v1.2.1 From 14332bccc1d88e89fa8950b92c034432e1585bd4 Mon Sep 17 00:00:00 2001 From: Alexey Shumkin Date: Thu, 4 Jul 2013 16:45:46 +0400 Subject: t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1 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 Reviewed-by: Johannes Sixt Signed-off-by: Junio C Hamano --- t/t4205-log-pretty-formats.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 't/t4205-log-pretty-formats.sh') diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index 3cfb744017..c2838427d3 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 && -- cgit v1.2.1 From f3445f781f95ca4a7d59028aa7b7457fa925f577 Mon Sep 17 00:00:00 2001 From: Alexey Shumkin Date: Fri, 5 Jul 2013 16:01:47 +0400 Subject: t4205 (log-pretty-formats): revert back single quotes 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 Signed-off-by: Junio C Hamano --- t/t4205-log-pretty-formats.sh | 106 +++++++++++++++++++++--------------------- 1 file changed, 53 insertions(+), 53 deletions(-) (limited to 't/t4205-log-pretty-formats.sh') diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index c2838427d3..ef9770a52b 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 two Z message one Z add bar Z $(commit_msg) Z EOF test_cmp expected actual -" +' -test_expect_success 'left alignment formatting at the nth column' " - git log --pretty='format:%h %<|(40)%s' >actual && +test_expect_success 'left alignment formatting at the nth column' ' + git log --pretty="format:%h %<|(40)%s" >actual && # complete the incomplete line at the end echo >>actual && - qz_to_tab_space <<\EOF >expected && + qz_to_tab_space <expected && $head1 message two Z $head2 message one Z $head3 add bar Z $head4 $(commit_msg) Z EOF test_cmp expected actual -" +' -test_expect_success 'left alignment formatting with no padding' " - git log --pretty='format:%<(1)%s' >actual && +test_expect_success 'left alignment formatting with no padding' ' + git log --pretty="format:%<(1)%s" >actual && # complete the incomplete line at the end echo >>actual && - cat <<\EOF >expected && + cat <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' >actual && +test_expect_success 'right alignment formatting' ' + git log --pretty="format:%>(40)%s" >actual && # complete the incomplete line at the end echo >>actual && - qz_to_tab_space <<\EOF >expected && + qz_to_tab_space <expected && Z message two Z message one Z add bar Z $(commit_msg) EOF test_cmp expected actual -" +' -test_expect_success 'right alignment formatting at the nth column' " - git log --pretty='format:%h %>|(40)%s' >actual && +test_expect_success 'right alignment formatting at the nth column' ' + git log --pretty="format:%h %>|(40)%s" >actual && # complete the incomplete line at the end echo >>actual && - qz_to_tab_space <<\EOF >expected && + qz_to_tab_space <expected && $head1 message two $head2 message one $head3 add bar $head4 $(commit_msg) EOF test_cmp expected actual -" +' -test_expect_success 'right alignment formatting with no padding' " - git log --pretty='format:%>(1)%s' >actual && +test_expect_success 'right alignment formatting with no padding' ' + git log --pretty="format:%>(1)%s" >actual && # complete the incomplete line at the end echo >>actual && - cat <<\EOF >expected && + cat <expected && message two message one add bar $(commit_msg) EOF test_cmp expected actual -" +' -test_expect_success 'center alignment formatting' " - git log --pretty='format:%><(40)%s' >actual && +test_expect_success 'center alignment formatting' ' + git log --pretty="format:%><(40)%s" >actual && # complete the incomplete line at the end echo >>actual && - qz_to_tab_space <<\EOF >expected && + qz_to_tab_space <expected && Z message two Z Z message one Z Z add bar Z Z $(commit_msg) Z EOF test_cmp expected actual -" +' -test_expect_success 'center alignment formatting at the nth column' " - git log --pretty='format:%h %><|(40)%s' >actual && +test_expect_success 'center alignment formatting at the nth column' ' + git log --pretty="format:%h %><|(40)%s" >actual && # complete the incomplete line at the end echo >>actual && - qz_to_tab_space <<\EOF >expected && + qz_to_tab_space <expected && $head1 message two Z $head2 message one Z $head3 add bar Z $head4 $(commit_msg) Z EOF test_cmp expected actual -" +' -test_expect_success 'center alignment formatting with no padding' " - git log --pretty='format:%><(1)%s' >actual && +test_expect_success 'center alignment formatting with no padding' ' + git log --pretty="format:%><(1)%s" >actual && # complete the incomplete line at the end echo >>actual && - cat <<\EOF >expected && + cat <expected && message two message one add bar $(commit_msg) EOF test_cmp expected actual -" +' -test_expect_success 'left/right alignment formatting with stealing' " - git commit --amend -m short --author 'long long long ' && - git log --pretty='format:%<(10,trunc)%s%>>(10,ltrunc)% an' >actual && +test_expect_success 'left/right alignment formatting with stealing' ' + git commit --amend -m short --author "long long long " && + git log --pretty="format:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual && # complete the incomplete line at the end echo >>actual && - cat <<\EOF >expected && + cat <expected && short long long long message .. A U Thor add bar A U Thor $(commit_msg "" "8" "..*$") A U Thor EOF test_cmp expected actual -" +' test_done -- cgit v1.2.1 From 17cc2ef1c5f160056f5ca8cf4bd795ddd9b76bd3 Mon Sep 17 00:00:00 2001 From: Alexey Shumkin Date: Fri, 5 Jul 2013 16:01:48 +0400 Subject: t4205, t6006, t7102: make functions better readable 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 Signed-off-by: Junio C Hamano --- t/t4205-log-pretty-formats.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 't/t4205-log-pretty-formats.sh') diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index ef9770a52b..2933c63709 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" -- cgit v1.2.1 From 37eb772ef3a5da0b28d3759373d714b349306ea4 Mon Sep 17 00:00:00 2001 From: Alexey Shumkin Date: Fri, 5 Jul 2013 16:01:50 +0400 Subject: t4205 (log-pretty-formats): avoid using `sed` 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(-) (limited to 't/t4205-log-pretty-formats.sh') diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index 2933c63709..fb00041139 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\n" 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../") + printf "$msg" | iconv -f utf-8 -t "$1" + else + printf "$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 ' -- cgit v1.2.1