1#!/bin/sh 2 3test_description='git rebase --whitespace=fix 4 5This test runs git rebase --whitespace=fix and make sure that it works. 6' 7 8. ./test-lib.sh 9 10# prepare initial revision of "file" with a blank line at the end 11cat >file <<EOF 12a 13b 14c 15 16EOF 17 18# expected contents in "file" after rebase 19cat >expect-first <<EOF 20a 21b 22c 23EOF 24 25# prepare second revision of "file" 26cat >second <<EOF 27a 28b 29c 30 31d 32e 33f 34 35 36 37 38EOF 39 40# expected contents in second revision after rebase 41cat >expect-second <<EOF 42a 43b 44c 45 46d 47e 48f 49EOF 50 51test_expect_success 'blank line at end of file; extend at end of file' ' 52 git commit --allow-empty -m "Initial empty commit" && 53 git add file && git commit -m first && 54 mv second file && 55 git add file && git commit -m second && 56 git rebase --whitespace=fix HEAD^^ && 57 git diff --exit-code HEAD^:file expect-first && 58 test_cmp expect-second file 59' 60 61# prepare third revision of "file" 62sed -e's/Z//' >third <<EOF 63a 64b 65c 66 67d 68e 69f 70 Z 71 Z 72h 73i 74j 75k 76l 77EOF 78 79sed -e's/ //g' <third >expect-third 80 81test_expect_success 'two blanks line at end of file; extend at end of file' ' 82 cp third file && git add file && git commit -m third && 83 git rebase --whitespace=fix HEAD^^ && 84 git diff --exit-code HEAD^:file expect-second && 85 test_cmp expect-third file 86' 87 88test_expect_success 'same, but do not remove trailing spaces' ' 89 git config core.whitespace "-blank-at-eol" && 90 git reset --hard HEAD^ && 91 cp third file && git add file && git commit -m third && 92 git rebase --whitespace=fix HEAD^^ && 93 git diff --exit-code HEAD^:file expect-second && 94 test_cmp file third 95' 96 97sed -e's/Z//' >beginning <<EOF 98a 99 Z 100 Z 101EOF 102 103cat >expect-beginning <<EOF 104a 105 106 1071 1082 1093 1104 1115 112EOF 113 114test_expect_success 'at beginning of file' ' 115 git config core.whitespace "blank-at-eol" && 116 cp beginning file && 117 git commit -m beginning file && 118 for i in 1 2 3 4 5; do 119 echo $i 120 done >> file && 121 git commit -m more file && 122 git rebase --whitespace=fix HEAD^^ && 123 test_cmp expect-beginning file 124' 125 126test_done 127