Stefan-W. Hahn | 6d8d8e0 | 2010-02-27 15:20:28 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2010 Stefan-W. Hahn |
| 4 | # |
| 5 | |
| 6 | test_description='git-am mbox with dos line ending. |
| 7 | |
| 8 | ' |
Johannes Schindelin | 8f37854 | 2020-11-18 23:44:27 +0000 | [diff] [blame] | 9 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
Johannes Schindelin | 334afbc | 2020-11-18 23:44:19 +0000 | [diff] [blame] | 10 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
| 11 | |
Stefan-W. Hahn | 6d8d8e0 | 2010-02-27 15:20:28 +0100 | [diff] [blame] | 12 | . ./test-lib.sh |
| 13 | |
| 14 | # Three patches which will be added as files with dos line ending. |
| 15 | |
| 16 | cat >file1 <<\EOF |
| 17 | line 1 |
| 18 | EOF |
| 19 | |
| 20 | cat >file1a <<\EOF |
| 21 | line 1 |
| 22 | line 4 |
| 23 | EOF |
| 24 | |
| 25 | cat >file2 <<\EOF |
| 26 | line 1 |
| 27 | line 2 |
| 28 | EOF |
| 29 | |
| 30 | cat >file3 <<\EOF |
| 31 | line 1 |
| 32 | line 2 |
| 33 | line 3 |
| 34 | EOF |
| 35 | |
| 36 | test_expect_success 'setup repository with dos files' ' |
| 37 | append_cr <file1 >file && |
| 38 | git add file && |
| 39 | git commit -m Initial && |
| 40 | git tag initial && |
| 41 | append_cr <file2 >file && |
| 42 | git commit -a -m Second && |
| 43 | append_cr <file3 >file && |
| 44 | git commit -a -m Third |
| 45 | ' |
| 46 | |
| 47 | test_expect_success 'am with dos files without --keep-cr' ' |
| 48 | git checkout -b dosfiles initial && |
Johannes Schindelin | 8f37854 | 2020-11-18 23:44:27 +0000 | [diff] [blame] | 49 | git format-patch -k initial..main && |
Stefan-W. Hahn | 6d8d8e0 | 2010-02-27 15:20:28 +0100 | [diff] [blame] | 50 | test_must_fail git am -k -3 000*.patch && |
| 51 | git am --abort && |
| 52 | rm -rf .git/rebase-apply 000*.patch |
| 53 | ' |
| 54 | |
| 55 | test_expect_success 'am with dos files with --keep-cr' ' |
| 56 | git checkout -b dosfiles-keep-cr initial && |
Johannes Schindelin | 8f37854 | 2020-11-18 23:44:27 +0000 | [diff] [blame] | 57 | git format-patch -k --stdout initial..main >output && |
Boxuan Li | ce4c7bf | 2019-05-05 16:16:33 +0800 | [diff] [blame] | 58 | git am --keep-cr -k -3 output && |
Johannes Schindelin | 8f37854 | 2020-11-18 23:44:27 +0000 | [diff] [blame] | 59 | git diff --exit-code main |
Stefan-W. Hahn | 6d8d8e0 | 2010-02-27 15:20:28 +0100 | [diff] [blame] | 60 | ' |
| 61 | |
| 62 | test_expect_success 'am with dos files config am.keepcr' ' |
| 63 | git config am.keepcr 1 && |
| 64 | git checkout -b dosfiles-conf-keepcr initial && |
Johannes Schindelin | 8f37854 | 2020-11-18 23:44:27 +0000 | [diff] [blame] | 65 | git format-patch -k --stdout initial..main >output && |
Boxuan Li | ce4c7bf | 2019-05-05 16:16:33 +0800 | [diff] [blame] | 66 | git am -k -3 output && |
Johannes Schindelin | 8f37854 | 2020-11-18 23:44:27 +0000 | [diff] [blame] | 67 | git diff --exit-code main |
Stefan-W. Hahn | 6d8d8e0 | 2010-02-27 15:20:28 +0100 | [diff] [blame] | 68 | ' |
| 69 | |
Leila Muhtasib | 8d8136c | 2012-06-22 16:03:01 -0400 | [diff] [blame] | 70 | test_expect_success 'am with dos files config am.keepcr overridden by --no-keep-cr' ' |
Stefan-W. Hahn | 6d8d8e0 | 2010-02-27 15:20:28 +0100 | [diff] [blame] | 71 | git config am.keepcr 1 && |
| 72 | git checkout -b dosfiles-conf-keepcr-override initial && |
Johannes Schindelin | 8f37854 | 2020-11-18 23:44:27 +0000 | [diff] [blame] | 73 | git format-patch -k initial..main && |
Stefan-W. Hahn | 6d8d8e0 | 2010-02-27 15:20:28 +0100 | [diff] [blame] | 74 | test_must_fail git am -k -3 --no-keep-cr 000*.patch && |
| 75 | git am --abort && |
| 76 | rm -rf .git/rebase-apply 000*.patch |
| 77 | ' |
| 78 | |
| 79 | test_expect_success 'am with dos files with --keep-cr continue' ' |
| 80 | git checkout -b dosfiles-keep-cr-continue initial && |
Johannes Schindelin | 8f37854 | 2020-11-18 23:44:27 +0000 | [diff] [blame] | 81 | git format-patch -k initial..main && |
Stefan-W. Hahn | 6d8d8e0 | 2010-02-27 15:20:28 +0100 | [diff] [blame] | 82 | append_cr <file1a >file && |
| 83 | git commit -m "different patch" file && |
| 84 | test_must_fail git am --keep-cr -k -3 000*.patch && |
| 85 | append_cr <file2 >file && |
| 86 | git add file && |
| 87 | git am -3 --resolved && |
Johannes Schindelin | 8f37854 | 2020-11-18 23:44:27 +0000 | [diff] [blame] | 88 | git diff --exit-code main |
Stefan-W. Hahn | 6d8d8e0 | 2010-02-27 15:20:28 +0100 | [diff] [blame] | 89 | ' |
| 90 | |
Leila Muhtasib | 8d8136c | 2012-06-22 16:03:01 -0400 | [diff] [blame] | 91 | test_expect_success 'am with unix files config am.keepcr overridden by --no-keep-cr' ' |
Stefan-W. Hahn | 6d8d8e0 | 2010-02-27 15:20:28 +0100 | [diff] [blame] | 92 | git config am.keepcr 1 && |
| 93 | git checkout -b unixfiles-conf-keepcr-override initial && |
| 94 | cp -f file1 file && |
| 95 | git commit -m "line ending to unix" file && |
Johannes Schindelin | 8f37854 | 2020-11-18 23:44:27 +0000 | [diff] [blame] | 96 | git format-patch -k initial..main && |
Stefan-W. Hahn | 6d8d8e0 | 2010-02-27 15:20:28 +0100 | [diff] [blame] | 97 | git am -k -3 --no-keep-cr 000*.patch && |
Johannes Schindelin | 8f37854 | 2020-11-18 23:44:27 +0000 | [diff] [blame] | 98 | git diff --exit-code -w main |
Stefan-W. Hahn | 6d8d8e0 | 2010-02-27 15:20:28 +0100 | [diff] [blame] | 99 | ' |
| 100 | |
| 101 | test_done |