Git 2.46-rc0
[git/gitster.git] / t / t3417-rebase-whitespace-fix.sh
blob22ee3a204598cfed88dead7f00f7de548c94cb85
1 #!/bin/sh
3 test_description='git rebase --whitespace=fix
5 This test runs git rebase --whitespace=fix and make sure that it works.
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
11 # prepare initial revision of "file" with a blank line at the end
12 cat >file <<EOF
17 EOF
19 # expected contents in "file" after rebase
20 cat >expect-first <<EOF
24 EOF
26 # prepare second revision of "file"
27 cat >second <<EOF
39 EOF
41 # expected contents in second revision after rebase
42 cat >expect-second <<EOF
50 EOF
52 test_expect_success 'blank line at end of file; extend at end of file' '
53 git commit --allow-empty -m "Initial empty commit" &&
54 git add file && git commit -m first &&
55 mv second file &&
56 git add file && git commit -m second &&
57 git rebase --whitespace=fix HEAD^^ &&
58 git diff --exit-code HEAD^:file expect-first &&
59 test_cmp expect-second file
62 # prepare third revision of "file"
63 sed -e's/Z//' >third <<EOF
78 EOF
80 sed -e's/ //g' <third >expect-third
82 test_expect_success 'two blanks line at end of file; extend at end of file' '
83 cp third file && git add file && git commit -m third &&
84 git rebase --whitespace=fix HEAD^^ &&
85 git diff --exit-code HEAD^:file expect-second &&
86 test_cmp expect-third file
89 test_expect_success 'same, but do not remove trailing spaces' '
90 git config core.whitespace "-blank-at-eol" &&
91 git reset --hard HEAD^ &&
92 cp third file && git add file && git commit -m third &&
93 git rebase --whitespace=fix HEAD^^ &&
94 git diff --exit-code HEAD^:file expect-second &&
95 test_cmp file third
98 sed -e's/Z//' >beginning <<EOF
104 cat >expect-beginning <<EOF
115 test_expect_success 'at beginning of file' '
116 git config core.whitespace "blank-at-eol" &&
117 cp beginning file &&
118 git commit -m beginning file &&
119 test_write_lines 1 2 3 4 5 >>file &&
120 git commit -m more file &&
121 git rebase --whitespace=fix HEAD^^ &&
122 test_cmp expect-beginning file
125 test_done