Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t4213-log-tabexpand.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t4213-log-tabexpand.sh` 105 lines ยท 2195 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='log/show --expand-tabs' 4 5 . ./test-lib.sh 6 7 HT=" " 8 title='tab indent at the beginning of the title line' 9 body='tab indent on a line in the body' 10 11 # usage: count_expand $indent $numSP $numHT @format_args 12 count_expand () 13 { 14 expect= 15 count=$(( $1 + $2 )) ;# expected spaces 16 while test $count -gt 0 17 do 18 expect="$expect " 19 count=$(( $count - 1 )) 20 done 21 shift 2 22 count=$1 ;# expected tabs 23 while test $count -gt 0 24 do 25 expect="$expect$HT" 26 count=$(( $count - 1 )) 27 done 28 shift 29 30 # The remainder of the command line is "git show -s" options 31 case " $* " in 32 *' --pretty=short '*) 33 line=$title ;; 34 *) 35 line=$body ;; 36 esac 37 38 # Prefix the output with the command line arguments, and 39 # replace SP with a dot both in the expected and actual output 40 # so that test_cmp would show the difference together with the 41 # breakage in a way easier to consume by the debugging user. 42 { 43 echo "git show -s $*" 44 echo "$expect$line" 45 } | sed -e 's/ /./g' >expect 46 47 { 48 echo "git show -s $*" 49 git show -s "$@" | 50 sed -n -e "/$line\$/p" 51 } | sed -e 's/ /./g' >actual 52 53 test_cmp expect actual 54 } 55 56 test_expand () 57 { 58 fmt=$1 59 case "$fmt" in 60 *=raw | *=short | *=email) 61 default="0 1" ;; 62 *) 63 default="8 0" ;; 64 esac 65 case "$fmt" in 66 *=email) 67 in=0 ;; 68 *) 69 in=4 ;; 70 esac 71 test_expect_success "expand/no-expand${fmt:+ for $fmt}" ' 72 count_expand $in $default $fmt && 73 count_expand $in 8 0 $fmt --expand-tabs && 74 count_expand $in 8 0 --expand-tabs $fmt && 75 count_expand $in 8 0 $fmt --expand-tabs=8 && 76 count_expand $in 8 0 --expand-tabs=8 $fmt && 77 count_expand $in 0 1 $fmt --no-expand-tabs && 78 count_expand $in 0 1 --no-expand-tabs $fmt && 79 count_expand $in 0 1 $fmt --expand-tabs=0 && 80 count_expand $in 0 1 --expand-tabs=0 $fmt && 81 count_expand $in 4 0 $fmt --expand-tabs=4 && 82 count_expand $in 4 0 --expand-tabs=4 $fmt 83 ' 84 } 85 86 test_expect_success 'setup' ' 87 test_tick && 88 sed -e "s/Q/$HT/g" <<-EOF >msg && 89 Q$title 90 91 Q$body 92 EOF 93 git commit --allow-empty -F msg 94 ' 95 96 test_expand "" 97 test_expand --pretty 98 test_expand --pretty=short 99 test_expand --pretty=medium 100 test_expand --pretty=full 101 test_expand --pretty=fuller 102 test_expand --pretty=raw 103 test_expand --pretty=email 104 105 test_done