#!/bin/sh # # Copyright (c) 2010, Will Palmer # Copyright (c) 2011, Alexey Shumkin (+ non-UTF-8 commit encoding tests) # global test_description := ''Test pretty formats'' source ./test-lib.sh # Tested non-UTF-8 encoding global test_encoding := '"ISO8859-1'" global sample_utf8_part := $[printf "f\303\244ng] proc commit_msg { # String "initial. initial" partly in German # (translated with Google Translate), # encoded in UTF-8, used as a commit log message below. global msg := ""initial. an$(sample_utf8_part)lich"\n" if test -n $1 { printf $msg | iconv -f utf-8 -t $1 } else { printf $msg } } test_expect_success 'set up basic repos' ' >foo && >bar && git add foo && test_tick && git config i18n.commitEncoding $test_encoding && commit_msg $test_encoding | git commit -F - && git add bar && test_tick && git commit -m "add bar" && git config --unset i18n.commitEncoding ' test_expect_success 'alias builtin format' ' git log --pretty=oneline >expected && git config pretty.test-alias oneline && git log --pretty=test-alias >actual && test_cmp expected actual ' test_expect_success 'alias masking builtin format' ' git log --pretty=oneline >expected && git config pretty.oneline "%H" && git log --pretty=oneline >actual && test_cmp expected actual ' test_expect_success 'alias user-defined format' ' git log --pretty="format:%h" >expected && git config pretty.test-alias "format:%h" && git log --pretty=test-alias >actual && test_cmp expected actual ' 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 && test_cmp expected-s actual-s ' test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' ' git log --oneline >expected-s && git log --pretty="tformat:%h %s" >actual-s && test_cmp expected-s actual-s ' test_expect_success 'alias user-defined tformat' ' git log --pretty="tformat:%h" >expected && git config pretty.test-alias "tformat:%h" && git log --pretty=test-alias >actual && test_cmp expected actual ' test_expect_success 'alias non-existent format' ' git config pretty.test-alias format-that-will-never-exist && test_must_fail git log --pretty=test-alias ' test_expect_success 'alias of an alias' ' git log --pretty="tformat:%h" >expected && git config pretty.test-foo "tformat:%h" && git config pretty.test-bar test-foo && git log --pretty=test-bar >actual && test_cmp expected actual ' test_expect_success 'alias masking an alias' ' git log --pretty=format:"Two %H" >expected && git config pretty.duplicate "format:One %H" && git config --add pretty.duplicate "format:Two %H" && git log --pretty=duplicate >actual && test_cmp expected actual ' test_expect_success 'alias loop' ' git config pretty.test-foo test-bar && git config pretty.test-bar test-foo && test_must_fail git log --pretty=test-foo ' 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_success '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' ' 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 && git log -z --stat --pretty="format:%s" >actual && test_i18ncmp expected actual ' test_expect_failure 'NUL termination with --stat' ' stat0_part=$(git diff --stat HEAD^ HEAD) && stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) && printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n0" >expected && git log -z --stat --pretty="tformat:%s" >actual && 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 && 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' ' git log --pretty="tformat:%<(40)%s" >actual && qz_to_tab_space <<-EOF >expected && message two Z message one Z add bar Z $(commit_msg) Z EOF test_cmp expected actual ' test_expect_success 'left alignment formatting. i18n.logOutputEncoding' ' git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(40)%s" >actual && qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >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="tformat:%h %<|(40)%s" >actual && qz_to_tab_space <<-EOF >expected && $head1 message two Z $head2 message one Z $head3 add bar Z $head4 $(commit_msg) Z EOF test_cmp expected actual ' test_expect_success 'left alignment formatting at the nth column' ' COLUMNS=50 git log --pretty="tformat:%h %<|(-10)%s" >actual && qz_to_tab_space <<-EOF >expected && $head1 message two Z $head2 message one Z $head3 add bar Z $head4 $(commit_msg) Z EOF test_cmp expected actual ' test_expect_success 'left alignment formatting at the nth column. i18n.logOutputEncoding' ' git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %<|(40)%s" >actual && qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >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="tformat:%<(1)%s" >actual && cat <<-EOF >expected && message two message one add bar $(commit_msg) 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 <<-EOF | iconv -f utf-8 -t $test_encoding >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 <<-\EOF >expected && message .. message .. add bar Z initial... EOF test_cmp expected actual ' 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 <<-\EOF | iconv -f utf-8 -t $test_encoding >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 <<-EOF >expected && ..sage two ..sage one add bar Z ..${sample_utf8_part}lich EOF test_cmp expected actual ' 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 <<-EOF | iconv -f utf-8 -t $test_encoding >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 <<-\EOF >expected && mess.. two mess.. one add bar Z init..lich EOF test_cmp expected actual ' 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 <<-\EOF | iconv -f utf-8 -t $test_encoding >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_to_tab_space <<-EOF >expected && Z message two Z message one Z add bar Z $(commit_msg) EOF test_cmp expected actual ' test_expect_success 'right alignment formatting. i18n.logOutputEncoding' ' git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%>(40)%s" >actual && qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >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="tformat:%h %>|(40)%s" >actual && qz_to_tab_space <<-EOF >expected && $head1 message two $head2 message one $head3 add bar $head4 $(commit_msg) EOF test_cmp expected actual ' test_expect_success 'right alignment formatting at the nth column' ' COLUMNS=50 git log --pretty="tformat:%h %>|(-10)%s" >actual && qz_to_tab_space <<-EOF >expected && $head1 message two $head2 message one $head3 add bar $head4 $(commit_msg) EOF test_cmp expected actual ' test_expect_success 'right alignment formatting at the nth column. i18n.logOutputEncoding' ' git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %>|(40)%s" >actual && qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected && $head1 message two $head2 message one $head3 add bar $head4 $(commit_msg) EOF test_cmp expected actual ' # Note: Space between 'message' and 'two' should be in the same column # as in previous test. test_expect_success 'right alignment formatting at the nth column with --graph. i18n.logOutputEncoding' ' git -c i18n.logOutputEncoding=$test_encoding log --graph --pretty="tformat:%h %>|(40)%s" >actual && iconv -f utf-8 -t $test_encoding >expected <<-EOF && * $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="tformat:%>(1)%s" >actual && cat <<-EOF >expected && message two message one add bar $(commit_msg) EOF test_cmp expected actual ' test_expect_success 'right alignment formatting with no padding and with --graph' ' git log --graph --pretty="tformat:%>(1)%s" >actual && cat <<-EOF >expected && * message two * message one * add bar * $(commit_msg) EOF test_cmp expected actual ' test_expect_success 'right alignment formatting with no padding. i18n.logOutputEncoding' ' git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%>(1)%s" >actual && cat <<-EOF | iconv -f utf-8 -t $test_encoding >expected && message two message one add bar $(commit_msg) EOF test_cmp expected actual ' test_expect_success 'center alignment formatting' ' git log --pretty="tformat:%><(40)%s" >actual && qz_to_tab_space <<-EOF >expected && Z message two Z Z message one Z Z add bar Z Z $(commit_msg) Z EOF test_cmp expected actual ' test_expect_success 'center alignment formatting. i18n.logOutputEncoding' ' git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%><(40)%s" >actual && qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >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="tformat:%h %><|(40)%s" >actual && qz_to_tab_space <<-EOF >expected && $head1 message two Z $head2 message one Z $head3 add bar Z $head4 $(commit_msg) Z EOF test_cmp expected actual ' test_expect_success 'center alignment formatting at the nth column' ' COLUMNS=70 git log --pretty="tformat:%h %><|(-30)%s" >actual && qz_to_tab_space <<-EOF >expected && $head1 message two Z $head2 message one Z $head3 add bar Z $head4 $(commit_msg) Z EOF test_cmp expected actual ' test_expect_success 'center alignment formatting at the nth column. i18n.logOutputEncoding' ' git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %><|(40)%s" >actual && qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >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="tformat:%><(1)%s" >actual && cat <<-EOF >expected && message two message one add bar $(commit_msg) 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 global old_head1 := $[git rev-parse --verify HEAD~0] test_expect_success 'center alignment formatting with no padding. i18n.logOutputEncoding' ' git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%><(1)%s" >actual && cat <<-EOF | iconv -f utf-8 -t $test_encoding >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="tformat:%<(10,trunc)%s%>>(10,ltrunc)% an" >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_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 <<-\EOF | iconv -f utf-8 -t $test_encoding >expected && short long long long message .. A U Thor add bar A U Thor initial... A U Thor EOF test_cmp expected actual ' test_expect_success 'strbuf_utf8_replace() not producing NUL' ' git log --color --pretty="tformat:%<(10,trunc)%s%>>(10,ltrunc)%C(auto)%d" | test_decode_color | nul_to_q >actual && ! grep Q actual ' # ISO strict date format test_expect_success 'ISO and ISO-strict date formats display the same values' ' git log --format=%ai%n%ci | sed -e "s/ /T/; s/ //; s/..\$/:&/" >expected && git log --format=%aI%n%cI >actual && test_cmp expected actual ' # get new digests (with no abbreviations) test_expect_success 'set up log decoration tests' ' 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 && git tag -d tag1 && git commit --amend -m shorter && git log --no-walk --tags --pretty="%H %d" --decorate=full >actual && cat <<-EOF >expected && $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 ' test_expect_success 'clean log decoration' ' git log --no-walk --tags --pretty="%H %D" --decorate=full >actual && cat >expected <<-EOF && $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 ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"Test pretty formats">)} spids: [16] ) ] spids: [16] ) (C {(.)} {(./test-lib.sh)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_encoding) op: Equal rhs: {(DQ (ISO8859-1))} spids: [29] ) ] spids: [29] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:sample_utf8_part) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(printf)} { (DQ (f) (EscapedLiteralPart token:) (03) (EscapedLiteralPart token: ) (44ng) ) } ) ] ) left_token: spids: [36 46] ) } spids: [35] ) ] spids: [35] ) (FuncDef name: commit_msg body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:msg) op: Equal rhs: { (DQ ("initial. an") (${ VSub_Name sample_utf8_part) (lich) (EscapedLiteralPart token:) ) } spids: [69] ) ] spids: [69] ) (If arms: [ (if_arm cond: [(C {(test)} {(-n)} {(DQ ($ VSub_Number "$1"))})] action: [ (Pipeline children: [ (C {(printf)} {(DQ ($ VSub_Name "$msg"))}) (C {(iconv)} {(-f)} {(utf-8)} {(-t)} {(DQ ($ VSub_Number "$1"))}) ] negated: False ) ] spids: [-1 91] ) ] else_action: [(C {(printf)} {(DQ ($ VSub_Name "$msg"))})] spids: [115 125] ) ] spids: [54] ) spids: [49 53] ) (C {(test_expect_success)} {(SQ <"set up basic repos">)} { (SQ <"\n"> <"\t>foo &&\n"> <"\t>bar &&\n"> <"\tgit add foo &&\n"> <"\ttest_tick &&\n"> <"\tgit config i18n.commitEncoding $test_encoding &&\n"> <"\tcommit_msg $test_encoding | git commit -F - &&\n"> <"\tgit add bar &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m \"add bar\" &&\n"> <"\tgit config --unset i18n.commitEncoding\n"> ) } ) (C {(test_expect_success)} {(SQ <"alias builtin format">)} { (SQ <"\n"> <"\tgit log --pretty=oneline >expected &&\n"> <"\tgit config pretty.test-alias oneline &&\n"> <"\tgit log --pretty=test-alias >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"alias masking builtin format">)} { (SQ <"\n"> <"\tgit log --pretty=oneline >expected &&\n"> <"\tgit config pretty.oneline \"%H\" &&\n"> <"\tgit log --pretty=oneline >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"alias user-defined format">)} { (SQ <"\n"> <"\tgit log --pretty=\"format:%h\" >expected &&\n"> <"\tgit config pretty.test-alias \"format:%h\" &&\n"> <"\tgit log --pretty=test-alias >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"alias user-defined tformat with %s (ISO8859-1 encoding)">)} { (SQ <"\n"> <"\tgit config i18n.logOutputEncoding $test_encoding &&\n"> <"\tgit log --oneline >expected-s &&\n"> <"\tgit log --pretty=\"tformat:%h %s\" >actual-s &&\n"> <"\tgit config --unset i18n.logOutputEncoding &&\n"> <"\ttest_cmp expected-s actual-s\n"> ) } ) (C {(test_expect_success)} {(SQ <"alias user-defined tformat with %s (utf-8 encoding)">)} { (SQ <"\n"> <"\tgit log --oneline >expected-s &&\n"> <"\tgit log --pretty=\"tformat:%h %s\" >actual-s &&\n"> <"\ttest_cmp expected-s actual-s\n"> ) } ) (C {(test_expect_success)} {(SQ <"alias user-defined tformat">)} { (SQ <"\n"> <"\tgit log --pretty=\"tformat:%h\" >expected &&\n"> <"\tgit config pretty.test-alias \"tformat:%h\" &&\n"> <"\tgit log --pretty=test-alias >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"alias non-existent format">)} { (SQ <"\n"> <"\tgit config pretty.test-alias format-that-will-never-exist &&\n"> <"\ttest_must_fail git log --pretty=test-alias\n"> ) } ) (C {(test_expect_success)} {(SQ <"alias of an alias">)} { (SQ <"\n"> <"\tgit log --pretty=\"tformat:%h\" >expected &&\n"> <"\tgit config pretty.test-foo \"tformat:%h\" &&\n"> <"\tgit config pretty.test-bar test-foo &&\n"> <"\tgit log --pretty=test-bar >actual && test_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"alias masking an alias">)} { (SQ <"\n"> <"\tgit log --pretty=format:\"Two %H\" >expected &&\n"> <"\tgit config pretty.duplicate \"format:One %H\" &&\n"> <"\tgit config --add pretty.duplicate \"format:Two %H\" &&\n"> <"\tgit log --pretty=duplicate >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"alias loop">)} { (SQ <"\n"> <"\tgit config pretty.test-foo test-bar &&\n"> <"\tgit config pretty.test-bar test-foo &&\n"> <"\ttest_must_fail git log --pretty=test-foo\n"> ) } ) (C {(test_expect_success)} {(SQ <"NUL separation">)} { (SQ <"\n"> <"\tprintf \"add bar\\0$(commit_msg)\" >expected &&\n"> <"\tgit log -z --pretty=\"format:%s\" >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"NUL termination">)} { (SQ <"\n"> <"\tprintf \"add bar\\0$(commit_msg)\\0\" >expected &&\n"> <"\tgit log -z --pretty=\"tformat:%s\" >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"NUL separation with --stat">)} { (SQ <"\n"> <"\tstat0_part=$(git diff --stat HEAD^ HEAD) &&\n"> <"\tstat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&\n"> <"\tprintf \"add bar\\n$stat0_part\\n\\0$(commit_msg)\\n$stat1_part\\n\" >expected &&\n"> <"\tgit log -z --stat --pretty=\"format:%s\" >actual &&\n"> <"\ttest_i18ncmp expected actual\n"> ) } ) (C {(test_expect_failure)} {(SQ <"NUL termination with --stat">)} { (SQ <"\n"> <"\tstat0_part=$(git diff --stat HEAD^ HEAD) &&\n"> <"\tstat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&\n"> <"\tprintf \"add bar\\n$stat0_part\\n\\0$(commit_msg)\\n$stat1_part\\n0\" >expected &&\n"> <"\tgit log -z --stat --pretty=\"tformat:%s\" >actual &&\n"> <"\ttest_i18ncmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup more commits">)} { (SQ <"\n"> <"\ttest_commit \"message one\" one one message-one &&\n"> <"\ttest_commit \"message two\" two two message-two &&\n"> <"\thead1=$(git rev-parse --verify --short HEAD~0) &&\n"> <"\thead2=$(git rev-parse --verify --short HEAD~1) &&\n"> <"\thead3=$(git rev-parse --verify --short HEAD~2) &&\n"> <"\thead4=$(git rev-parse --verify --short HEAD~3)\n"> ) } ) (C {(test_expect_success)} {(SQ <"left alignment formatting">)} { (SQ <"\n"> <"\tgit log --pretty=\"tformat:%<(40)%s\" >actual &&\n"> <"\tqz_to_tab_space <<-EOF >expected &&\n"> <"\tmessage two Z\n"> <"\tmessage one Z\n"> <"\tadd bar Z\n"> <"\t$(commit_msg) Z\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"left alignment formatting. i18n.logOutputEncoding">)} { (SQ <"\n"> < "\tgit -c i18n.logOutputEncoding=$test_encoding log --pretty=\"tformat:%<(40)%s\" >actual &&\n" > <"\tqz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&\n"> <"\tmessage two Z\n"> <"\tmessage one Z\n"> <"\tadd bar Z\n"> <"\t$(commit_msg) Z\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"left alignment formatting at the nth column">)} { (SQ <"\n"> <"\tgit log --pretty=\"tformat:%h %<|(40)%s\" >actual &&\n"> <"\tqz_to_tab_space <<-EOF >expected &&\n"> <"\t$head1 message two Z\n"> <"\t$head2 message one Z\n"> <"\t$head3 add bar Z\n"> <"\t$head4 $(commit_msg) Z\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"left alignment formatting at the nth column">)} { (SQ <"\n"> <"\tCOLUMNS=50 git log --pretty=\"tformat:%h %<|(-10)%s\" >actual &&\n"> <"\tqz_to_tab_space <<-EOF >expected &&\n"> <"\t$head1 message two Z\n"> <"\t$head2 message one Z\n"> <"\t$head3 add bar Z\n"> <"\t$head4 $(commit_msg) Z\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"left alignment formatting at the nth column. i18n.logOutputEncoding">)} { (SQ <"\n"> < "\tgit -c i18n.logOutputEncoding=$test_encoding log --pretty=\"tformat:%h %<|(40)%s\" >actual &&\n" > <"\tqz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&\n"> <"\t$head1 message two Z\n"> <"\t$head2 message one Z\n"> <"\t$head3 add bar Z\n"> <"\t$head4 $(commit_msg) Z\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"left alignment formatting with no padding">)} { (SQ <"\n"> <"\tgit log --pretty=\"tformat:%<(1)%s\" >actual &&\n"> <"\tcat <<-EOF >expected &&\n"> <"\tmessage two\n"> <"\tmessage one\n"> <"\tadd bar\n"> <"\t$(commit_msg)\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"left alignment formatting with no padding. i18n.logOutputEncoding">)} { (SQ <"\n"> < "\tgit -c i18n.logOutputEncoding=$test_encoding log --pretty=\"tformat:%<(1)%s\" >actual &&\n" > <"\tcat <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&\n"> <"\tmessage two\n"> <"\tmessage one\n"> <"\tadd bar\n"> <"\t$(commit_msg)\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"left alignment formatting with trunc">)} { (SQ <"\n"> <"\tgit log --pretty=\"tformat:%<(10,trunc)%s\" >actual &&\n"> <"\tqz_to_tab_space <<-\\EOF >expected &&\n"> <"\tmessage ..\n"> <"\tmessage ..\n"> <"\tadd bar Z\n"> <"\tinitial...\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"left alignment formatting with trunc. i18n.logOutputEncoding">)} { (SQ <"\n"> < "\tgit -c i18n.logOutputEncoding=$test_encoding log --pretty=\"tformat:%<(10,trunc)%s\" >actual &&\n" > <"\tqz_to_tab_space <<-\\EOF | iconv -f utf-8 -t $test_encoding >expected &&\n"> <"\tmessage ..\n"> <"\tmessage ..\n"> <"\tadd bar Z\n"> <"\tinitial...\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"left alignment formatting with ltrunc">)} { (SQ <"\n"> <"\tgit log --pretty=\"tformat:%<(10,ltrunc)%s\" >actual &&\n"> <"\tqz_to_tab_space <<-EOF >expected &&\n"> <"\t..sage two\n"> <"\t..sage one\n"> <"\tadd bar Z\n"> <"\t..${sample_utf8_part}lich\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"left alignment formatting with ltrunc. i18n.logOutputEncoding">)} { (SQ <"\n"> < "\tgit -c i18n.logOutputEncoding=$test_encoding log --pretty=\"tformat:%<(10,ltrunc)%s\" >actual &&\n" > <"\tqz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&\n"> <"\t..sage two\n"> <"\t..sage one\n"> <"\tadd bar Z\n"> <"\t..${sample_utf8_part}lich\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"left alignment formatting with mtrunc">)} { (SQ <"\n"> <"\tgit log --pretty=\"tformat:%<(10,mtrunc)%s\" >actual &&\n"> <"\tqz_to_tab_space <<-\\EOF >expected &&\n"> <"\tmess.. two\n"> <"\tmess.. one\n"> <"\tadd bar Z\n"> <"\tinit..lich\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"left alignment formatting with mtrunc. i18n.logOutputEncoding">)} { (SQ <"\n"> < "\tgit -c i18n.logOutputEncoding=$test_encoding log --pretty=\"tformat:%<(10,mtrunc)%s\" >actual &&\n" > <"\tqz_to_tab_space <<-\\EOF | iconv -f utf-8 -t $test_encoding >expected &&\n"> <"\tmess.. two\n"> <"\tmess.. one\n"> <"\tadd bar Z\n"> <"\tinit..lich\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"right alignment formatting">)} { (SQ <"\n"> <"\tgit log --pretty=\"tformat:%>(40)%s\" >actual &&\n"> <"\tqz_to_tab_space <<-EOF >expected &&\n"> <"\tZ message two\n"> <"\tZ message one\n"> <"\tZ add bar\n"> <"\tZ $(commit_msg)\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"right alignment formatting. i18n.logOutputEncoding">)} { (SQ <"\n"> < "\tgit -c i18n.logOutputEncoding=$test_encoding log --pretty=\"tformat:%>(40)%s\" >actual &&\n" > <"\tqz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&\n"> <"\tZ message two\n"> <"\tZ message one\n"> <"\tZ add bar\n"> <"\tZ $(commit_msg)\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"right alignment formatting at the nth column">)} { (SQ <"\n"> <"\tgit log --pretty=\"tformat:%h %>|(40)%s\" >actual &&\n"> <"\tqz_to_tab_space <<-EOF >expected &&\n"> <"\t$head1 message two\n"> <"\t$head2 message one\n"> <"\t$head3 add bar\n"> <"\t$head4 $(commit_msg)\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"right alignment formatting at the nth column">)} { (SQ <"\n"> <"\tCOLUMNS=50 git log --pretty=\"tformat:%h %>|(-10)%s\" >actual &&\n"> <"\tqz_to_tab_space <<-EOF >expected &&\n"> <"\t$head1 message two\n"> <"\t$head2 message one\n"> <"\t$head3 add bar\n"> <"\t$head4 $(commit_msg)\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"right alignment formatting at the nth column. i18n.logOutputEncoding">)} { (SQ <"\n"> < "\tgit -c i18n.logOutputEncoding=$test_encoding log --pretty=\"tformat:%h %>|(40)%s\" >actual &&\n" > <"\tqz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&\n"> <"\t$head1 message two\n"> <"\t$head2 message one\n"> <"\t$head3 add bar\n"> <"\t$head4 $(commit_msg)\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"right alignment formatting at the nth column with --graph. i18n.logOutputEncoding">)} { (SQ <"\n"> < "\tgit -c i18n.logOutputEncoding=$test_encoding log --graph --pretty=\"tformat:%h %>|(40)%s\" >actual &&\n" > <"\ticonv -f utf-8 -t $test_encoding >expected <<-EOF &&\n"> <"\t* $head1 message two\n"> <"\t* $head2 message one\n"> <"\t* $head3 add bar\n"> <"\t* $head4 $(commit_msg)\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"right alignment formatting with no padding">)} { (SQ <"\n"> <"\tgit log --pretty=\"tformat:%>(1)%s\" >actual &&\n"> <"\tcat <<-EOF >expected &&\n"> <"\tmessage two\n"> <"\tmessage one\n"> <"\tadd bar\n"> <"\t$(commit_msg)\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"right alignment formatting with no padding and with --graph">)} { (SQ <"\n"> <"\tgit log --graph --pretty=\"tformat:%>(1)%s\" >actual &&\n"> <"\tcat <<-EOF >expected &&\n"> <"\t* message two\n"> <"\t* message one\n"> <"\t* add bar\n"> <"\t* $(commit_msg)\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"right alignment formatting with no padding. i18n.logOutputEncoding">)} { (SQ <"\n"> < "\tgit -c i18n.logOutputEncoding=$test_encoding log --pretty=\"tformat:%>(1)%s\" >actual &&\n" > <"\tcat <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&\n"> <"\tmessage two\n"> <"\tmessage one\n"> <"\tadd bar\n"> <"\t$(commit_msg)\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"center alignment formatting">)} { (SQ <"\n"> <"\tgit log --pretty=\"tformat:%><(40)%s\" >actual &&\n"> <"\tqz_to_tab_space <<-EOF >expected &&\n"> <"\tZ message two Z\n"> <"\tZ message one Z\n"> <"\tZ add bar Z\n"> <"\tZ $(commit_msg) Z\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"center alignment formatting. i18n.logOutputEncoding">)} { (SQ <"\n"> < "\tgit -c i18n.logOutputEncoding=$test_encoding log --pretty=\"tformat:%><(40)%s\" >actual &&\n" > <"\tqz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&\n"> <"\tZ message two Z\n"> <"\tZ message one Z\n"> <"\tZ add bar Z\n"> <"\tZ $(commit_msg) Z\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"center alignment formatting at the nth column">)} { (SQ <"\n"> <"\tgit log --pretty=\"tformat:%h %><|(40)%s\" >actual &&\n"> <"\tqz_to_tab_space <<-EOF >expected &&\n"> <"\t$head1 message two Z\n"> <"\t$head2 message one Z\n"> <"\t$head3 add bar Z\n"> <"\t$head4 $(commit_msg) Z\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"center alignment formatting at the nth column">)} { (SQ <"\n"> <"\tCOLUMNS=70 git log --pretty=\"tformat:%h %><|(-30)%s\" >actual &&\n"> <"\tqz_to_tab_space <<-EOF >expected &&\n"> <"\t$head1 message two Z\n"> <"\t$head2 message one Z\n"> <"\t$head3 add bar Z\n"> <"\t$head4 $(commit_msg) Z\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"center alignment formatting at the nth column. i18n.logOutputEncoding">)} { (SQ <"\n"> < "\tgit -c i18n.logOutputEncoding=$test_encoding log --pretty=\"tformat:%h %><|(40)%s\" >actual &&\n" > <"\tqz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&\n"> <"\t$head1 message two Z\n"> <"\t$head2 message one Z\n"> <"\t$head3 add bar Z\n"> <"\t$head4 $(commit_msg) Z\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"center alignment formatting with no padding">)} { (SQ <"\n"> <"\tgit log --pretty=\"tformat:%><(1)%s\" >actual &&\n"> <"\tcat <<-EOF >expected &&\n"> <"\tmessage two\n"> <"\tmessage one\n"> <"\tadd bar\n"> <"\t$(commit_msg)\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:old_head1) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(git)} {(rev-parse)} {(--verify)} {(HEAD) (Lit_Tilde "~") (0)})] ) left_token: spids: [920 930] ) } spids: [919] ) ] spids: [919] ) (C {(test_expect_success)} {(SQ <"center alignment formatting with no padding. i18n.logOutputEncoding">)} { (SQ <"\n"> < "\tgit -c i18n.logOutputEncoding=$test_encoding log --pretty=\"tformat:%><(1)%s\" >actual &&\n" > <"\tcat <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&\n"> <"\tmessage two\n"> <"\tmessage one\n"> <"\tadd bar\n"> <"\t$(commit_msg)\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"left/right alignment formatting with stealing">)} { (SQ <"\n"> <"\tgit commit --amend -m short --author \"long long long \" &&\n"> <"\tgit log --pretty=\"tformat:%<(10,trunc)%s%>>(10,ltrunc)% an\" >actual &&\n"> <"\tcat <<-\\EOF >expected &&\n"> <"\tshort long long long\n"> <"\tmessage .. A U Thor\n"> <"\tadd bar A U Thor\n"> <"\tinitial... A U Thor\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"left/right alignment formatting with stealing. i18n.logOutputEncoding">)} { (SQ <"\n"> < "\tgit -c i18n.logOutputEncoding=$test_encoding log --pretty=\"tformat:%<(10,trunc)%s%>>(10,ltrunc)% an\" >actual &&\n" > <"\tcat <<-\\EOF | iconv -f utf-8 -t $test_encoding >expected &&\n"> <"\tshort long long long\n"> <"\tmessage .. A U Thor\n"> <"\tadd bar A U Thor\n"> <"\tinitial... A U Thor\n"> <"\tEOF\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"strbuf_utf8_replace() not producing NUL">)} { (SQ <"\n"> <"\tgit log --color --pretty=\"tformat:%<(10,trunc)%s%>>(10,ltrunc)%C(auto)%d\" |\n"> <"\t\ttest_decode_color |\n"> <"\t\tnul_to_q >actual &&\n"> <"\t! grep Q actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"ISO and ISO-strict date formats display the same values">)} { (SQ <"\n"> <"\tgit log --format=%ai%n%ci |\n"> <"\tsed -e \"s/ /T/; s/ //; s/..\\$/:&/\" >expected &&\n"> <"\tgit log --format=%aI%n%cI >actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"set up log decoration tests">)} { (SQ <"\n"> <"\thead1=$(git rev-parse --verify HEAD~0) &&\n"> <"\thead2=$(git rev-parse --verify HEAD~1)\n"> ) } ) (C {(test_expect_success)} {(SQ <"log decoration properly follows tag chain">)} { (SQ <"\n"> <"\tgit tag -a tag1 -m tag1 &&\n"> <"\tgit tag -a tag2 -m tag2 tag1 &&\n"> <"\tgit tag -d tag1 &&\n"> <"\tgit commit --amend -m shorter &&\n"> <"\tgit log --no-walk --tags --pretty=\"%H %d\" --decorate=full >actual &&\n"> <"\tcat <<-EOF >expected &&\n"> <"\t$head1 (tag: refs/tags/tag2)\n"> <"\t$head2 (tag: refs/tags/message-one)\n"> <"\t$old_head1 (tag: refs/tags/message-two)\n"> <"\tEOF\n"> <"\tsort actual >actual1 &&\n"> <"\ttest_cmp expected actual1\n"> ) } ) (C {(test_expect_success)} {(SQ <"clean log decoration">)} { (SQ <"\n"> <"\tgit log --no-walk --tags --pretty=\"%H %D\" --decorate=full >actual &&\n"> <"\tcat >expected <<-EOF &&\n"> <"\t$head1 tag: refs/tags/tag2\n"> <"\t$head2 tag: refs/tags/message-one\n"> <"\t$old_head1 tag: refs/tags/message-two\n"> <"\tEOF\n"> <"\tsort actual >actual1 &&\n"> <"\ttest_cmp expected actual1\n"> ) } ) (C {(test_done)}) ] )