]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t4205-log-pretty-formats.sh
t7102 (reset): don't hardcode SHA-1 in expected outputs
[thirdparty/git.git] / t / t4205-log-pretty-formats.sh
index 98a43d457a3de96fd9aa728610db7d8b3fdd241d..26fbfde4a36689a51c181c13f9d5680fd2780219 100755 (executable)
@@ -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