summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-04-23 18:22:48 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-04-23 18:22:48 (GMT)
commite52e6f79ccc372825313890b96007985b8aa6e9c (patch)
tree10fe499658d1df9c12c1658c1bf0e28d32b8ad8d /t
parent7093d2c0dd986c70a98b712440b34f98599b3539 (diff)
parent1640632b4f3f69775f04e9e40dfd2fd912e0f458 (diff)
downloadgit-e52e6f79ccc372825313890b96007985b8aa6e9c.zip
git-e52e6f79ccc372825313890b96007985b8aa6e9c.tar.gz
git-e52e6f79ccc372825313890b96007985b8aa6e9c.tar.bz2
Merge branch 'nd/pretty-formats'
pretty-printing body of the commit that is stored in non UTF-8 encoding did not work well. The early part of this series fixes it. And then it adds %C(auto) specifier that turns the coloring on when we are emitting to the terminal, and adds column-aligning format directives. * nd/pretty-formats: pretty: support %>> that steal trailing spaces pretty: support truncating in %>, %< and %>< pretty: support padding placeholders, %< %> and %>< pretty: add %C(auto) for auto-coloring pretty: split color parsing into a separate function pretty: two phase conversion for non utf-8 commits utf8.c: add reencode_string_len() that can handle NULs in string utf8.c: add utf8_strnwidth() with the ability to skip ansi sequences utf8.c: move display_mode_esc_sequence_len() for use by other functions pretty: share code between format_decoration and show_decorations pretty-formats.txt: wrap long lines pretty: get the correct encoding for --pretty:format=%e pretty: save commit encoding from logmsg_reencode if the caller needs it
Diffstat (limited to 't')
-rwxr-xr-xt/t4205-log-pretty-formats.sh175
-rwxr-xr-xt/t4207-log-decoration-colors.sh8
-rwxr-xr-xt/t6006-rev-list-format.sh12
3 files changed, 185 insertions, 10 deletions
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 98a43d4..26fbfde 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -99,4 +99,179 @@ 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 '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
+ 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_expect_success 'left/right alignment formatting with stealing' '
+ git commit --amend -m short --author "long long long <long@me.com>" &&
+ git log --pretty="format:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
+ # complete the incomplete line at the end
+ echo >>actual &&
+ cat <<\EOF >expected &&
+short long long long
+message .. A U Thor
+add bar A U Thor
+initial A U Thor
+EOF
+ test_cmp expected actual
+'
+
test_done
diff --git a/t/t4207-log-decoration-colors.sh b/t/t4207-log-decoration-colors.sh
index bbde31b..925f577 100755
--- a/t/t4207-log-decoration-colors.sh
+++ b/t/t4207-log-decoration-colors.sh
@@ -44,15 +44,15 @@ test_expect_success setup '
'
cat >expected <<EOF
-${c_commit}COMMIT_ID (${c_HEAD}HEAD${c_reset}${c_commit},\
+${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_HEAD}HEAD${c_reset}${c_commit},\
${c_tag}tag: v1.0${c_reset}${c_commit},\
${c_tag}tag: B${c_reset}${c_commit},\
${c_branch}master${c_reset}${c_commit})${c_reset} B
-${c_commit}COMMIT_ID (${c_tag}tag: A1${c_reset}${c_commit},\
+${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_tag}tag: A1${c_reset}${c_commit},\
${c_remoteBranch}other/master${c_reset}${c_commit})${c_reset} A1
-${c_commit}COMMIT_ID (${c_stash}refs/stash${c_reset}${c_commit})${c_reset}\
+${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_stash}refs/stash${c_reset}${c_commit})${c_reset}\
On master: Changes to A.t
-${c_commit}COMMIT_ID (${c_tag}tag: A${c_reset}${c_commit})${c_reset} A
+${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_tag}tag: A${c_reset}${c_commit})${c_reset} A
EOF
# We want log to show all, but the second parent to refs/stash is irrelevant
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 3fc3b74..0393c9f 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -184,7 +184,7 @@ Test printing of complex bodies
This commit message is much longer than the others,
and it will be encoded in iso8859-1. We should therefore
-include an iso8859 character: ¡bueno!
+include an iso8859 character: ¡bueno!
EOF
test_expect_success 'setup complex body' '
git config i18n.commitencoding iso8859-1 &&
@@ -192,14 +192,14 @@ git config i18n.commitencoding iso8859-1 &&
'
test_format complex-encoding %e <<'EOF'
-commit f58db70b055c5718631e5c61528b28b12090cdea
+commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
iso8859-1
commit 131a310eb913d107dd3c09a65d1651175898735d
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
EOF
test_format complex-subject %s <<'EOF'
-commit f58db70b055c5718631e5c61528b28b12090cdea
+commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
Test printing of complex bodies
commit 131a310eb913d107dd3c09a65d1651175898735d
changed foo
@@ -208,17 +208,17 @@ added foo
EOF
test_format complex-body %b <<'EOF'
-commit f58db70b055c5718631e5c61528b28b12090cdea
+commit 1ed88da4a5b5ed8c449114ac131efc62178734c3
This commit message is much longer than the others,
and it will be encoded in iso8859-1. We should therefore
-include an iso8859 character: ¡bueno!
+include an iso8859 character: ¡bueno!
commit 131a310eb913d107dd3c09a65d1651175898735d
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
EOF
test_expect_success '%x00 shows NUL' '
- echo >expect commit f58db70b055c5718631e5c61528b28b12090cdea &&
+ echo >expect commit 1ed88da4a5b5ed8c449114ac131efc62178734c3 &&
echo >>expect fooQbar &&
git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
nul_to_q <actual.nul >actual &&