{"thread":{"id":"22644","subject":"[PATCHv3 0/3] Using git-mailsplit in mixed line ending environment","startedAt":"2010-02-13T16:59:20Z","lastAt":"2010-02-28T21:18:07Z","messageCount":15,"participants":["Stefan-W. Hahn","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"134449","messageId":"1266080362-24760-2-git-send-email-stefan.hahn@s-hahn.de","threadId":"22644","inReplyTo":"1266080362-24760-1-git-send-email-stefan.hahn@s-hahn.de","subject":"[PATCH 1/3] git-mailsplit: Show parameter '--keep-cr' in usage and documentation","fromName":"Stefan-W. Hahn","fromEmail":"stefan.hahn@s-hahn.de","sentAt":"2010-02-13T16:59:20Z","receivedAt":"2010-02-13T16:59:20Z","isPatch":true,"sender":{"key":"stefan.hahn@s-hahn.de","avatar":null},"body":"Signed-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>\n---\n Documentation/git-mailsplit.txt |    5 ++++-\n builtin-mailsplit.c             |    2 +-\n 2 files changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-mailsplit.txt b/Documentation/git-mailsplit.txt\nindex 5cc94ec..a634485 100644\n--- a/Documentation/git-mailsplit.txt\n+++ b/Documentation/git-mailsplit.txt\n@@ -7,7 +7,7 @@ git-mailsplit - Simple UNIX mbox splitter program\n \n SYNOPSIS\n --------\n-'git mailsplit' [-b] [-f<nn>] [-d<prec>] -o<directory> [--] [<mbox>|<Maildir>...]\n+'git mailsplit' [-b] [-f<nn>] [-d<prec>] [--keep-cr] -o<directory> [--] [<mbox>|<Maildir>...]\n \n DESCRIPTION\n -----------\n@@ -43,6 +43,9 @@ OPTIONS\n \tSkip the first <nn> numbers, for example if -f3 is specified,\n \tstart the numbering with 0004.\n \n+--keep-cr::\n+\tDo not remove `\\r` from lines ending with `\\r\\n`.\n+\n Author\n ------\n Written by Linus Torvalds <torvalds@osdl.org>\ndiff --git a/builtin-mailsplit.c b/builtin-mailsplit.c\nindex 207e358..cdfc1b7 100644\n--- a/builtin-mailsplit.c\n+++ b/builtin-mailsplit.c\n@@ -10,7 +10,7 @@\n #include \"strbuf.h\"\n \n static const char git_mailsplit_usage[] =\n-\"git mailsplit [-d<prec>] [-f<n>] [-b] -o<directory> [<mbox>|<Maildir>...]\";\n+\"git mailsplit [-d<prec>] [-f<n>] [-b] [--keep-cr] -o<directory> [<mbox>|<Maildir>...]\";\n \n static int is_from_line(const char *line, int len)\n {\n-- \n1.7.0.rc2.31.g49e2a\n"},{"id":"134451","messageId":"1266080362-24760-3-git-send-email-stefan.hahn@s-hahn.de","threadId":"22644","inReplyTo":"1266080362-24760-1-git-send-email-stefan.hahn@s-hahn.de","subject":"[PATCH 2/3] git-am: Add command line parameter `--keep-cr` passing it to git-mailsplit.","fromName":"Stefan-W. Hahn","fromEmail":"stefan.hahn@s-hahn.de","sentAt":"2010-02-13T16:59:21Z","receivedAt":"2010-02-13T16:59:21Z","isPatch":true,"sender":{"key":"stefan.hahn@s-hahn.de","avatar":null},"body":"The behaviour of git-mailsplit, which is called from git-am for\npatches in mbox format, has been changed in commit c2ca1d79. The new\ndefault behaviour will remove `\\r` from line endings with `\\r\\n`.\n\nIf applying patches with the following command sequence\n\n   git format-patch --stdout ... | git am ...\n\nin repositories having files with dos and unix line endings,\ngit-mailsplit must be called with `--keep-cr` parameter.\n\nThis patch adds the command line parameter `--keep-cr` for git-am and\nthe configuration `am.keepcr`.\n\nSigned-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>\n---\n Documentation/config.txt |    6 ++++++\n git-am.sh                |   27 ++++++++++++++++++++-------\n 2 files changed, 26 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 4c36aa9..aa452f3 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -550,6 +550,12 @@ it will be treated as a shell command.  For example, defining\n executed from the top-level directory of a repository, which may\n not necessarily be the current directory.\n \n+am.keepcr::\n+\tIf true, git-am will call git-mailsplit for patches in mbox format \n+\twith parameter '--keep-cr'. In this case git-mailsplit will\n+\tnot remove `\\r` from lines ending with `\\r\\n`. \n+\tSee linkgit:git-am[1], linkgit:git-mailsplit[1].\n+\n apply.ignorewhitespace::\n \tWhen set to 'change', tells 'git apply' to ignore changes in\n \twhitespace, in the same way as the '--ignore-space-change'\ndiff --git a/git-am.sh b/git-am.sh\nindex c8b9cbb..3057a83 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -15,6 +15,7 @@ q,quiet         be quiet\n s,signoff       add a Signed-off-by line to the commit message\n u,utf8          recode into utf8 (default)\n k,keep          pass -k flag to git-mailinfo\n+keep-cr         pass --keep-cr flag to git-mailsplit for mbox format\n c,scissors      strip everything before a scissors line\n whitespace=     pass it through git-apply\n ignore-space-change pass it through git-apply\n@@ -216,12 +217,12 @@ check_patch_format () {\n split_patches () {\n \tcase \"$patch_format\" in\n \tmbox)\n-\t\tcase \"$rebasing\" in\n-\t\t'')\n-\t\t\tkeep_cr= ;;\n-\t\t?*)\n-\t\t\tkeep_cr=--keep-cr ;;\n-\t\tesac\n+\t\tif test -n \"$rebasing$keepcr\"\n+\t\tthen\n+                    keep_cr=--keep-cr\n+\t\telse\n+                    keep_cr=\n+\t\tfi\n \t\tgit mailsplit -d\"$prec\" -o\"$dotest\" -b $keep_cr -- \"$@\" > \"$dotest/last\" ||\n \t\tclean_abort\n \t\t;;\n@@ -290,13 +291,18 @@ split_patches () {\n \n prec=4\n dotest=\"$GIT_DIR/rebase-apply\"\n-sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=\n+sign= utf8=t keep= keepcr= skip= interactive= resolved= rebasing= abort=\n resolvemsg= resume= scissors= no_inbody_headers=\n git_apply_opt=\n committer_date_is_author_date=\n ignore_date=\n allow_rerere_autoupdate=\n \n+if test \"$(git config --bool --get am.keepcr)\" = true\n+then \n+    keepcr=t\n+fi\n+\n while test $# != 0\n do\n \tcase \"$1\" in\n@@ -347,6 +353,8 @@ do\n \t\tallow_rerere_autoupdate=\"$1\" ;;\n \t-q|--quiet)\n \t\tGIT_QUIET=t ;;\n+\t--keep-cr)\n+\t\tkeepcr=t ;;\n \t--)\n \t\tshift; break ;;\n \t*)\n@@ -452,6 +460,7 @@ else\n \techo \"$sign\" >\"$dotest/sign\"\n \techo \"$utf8\" >\"$dotest/utf8\"\n \techo \"$keep\" >\"$dotest/keep\"\n+\techo \"$keepcr\" >\"$dotest/keepcr\"\n \techo \"$scissors\" >\"$dotest/scissors\"\n \techo \"$no_inbody_headers\" >\"$dotest/no_inbody_headers\"\n \techo \"$GIT_QUIET\" >\"$dotest/quiet\"\n@@ -495,6 +504,10 @@ if test \"$(cat \"$dotest/keep\")\" = t\n then\n \tkeep=-k\n fi\n+if test \"$(cat \"$dotest/keepcr\")\" = t\n+then\n+\tkeepcr=--keep-cr\n+fi\n case \"$(cat \"$dotest/scissors\")\" in\n t)\n \tscissors=--scissors ;;\n-- \n1.7.0.rc2.31.g49e2a\n"},{"id":"134450","messageId":"1266080362-24760-4-git-send-email-stefan.hahn@s-hahn.de","threadId":"22644","inReplyTo":"1266080362-24760-1-git-send-email-stefan.hahn@s-hahn.de","subject":"[PATCH 3/3] Adding test for `--keep-cr` for git-am.","fromName":"Stefan-W. Hahn","fromEmail":"stefan.hahn@s-hahn.de","sentAt":"2010-02-13T16:59:22Z","receivedAt":"2010-02-13T16:59:22Z","isPatch":true,"sender":{"key":"stefan.hahn@s-hahn.de","avatar":null},"body":"This test adds test for git-am dos line endings, the command sequence\n'git format-patch ... | git am ...' and the configuration variable\n`am.keepcr`.\n\nSigned-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>\n---\n t/t4253-am-keep-cr-dos.sh |   68 +++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 68 insertions(+), 0 deletions(-)\n create mode 100644 t/t4253-am-keep-cr-dos.sh\n\ndiff --git a/t/t4253-am-keep-cr-dos.sh b/t/t4253-am-keep-cr-dos.sh\nnew file mode 100644\nindex 0000000..a4f5f80\n--- /dev/null\n+++ b/t/t4253-am-keep-cr-dos.sh\n@@ -0,0 +1,68 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2010 Stefan-W. Hahn\n+#\n+\n+test_description='git-am mbox with dos line ending.\n+\n+'\n+. ./test-lib.sh\n+\n+# Three patches which will be added as files with dos line ending.\n+\n+cat > file1 <<\\EOF\n+line 1\n+EOF\n+\n+cat > file2 <<\\EOF\n+line 1\n+line 2\n+EOF\n+\n+cat > file3 <<\\EOF\n+line 1\n+line 2\n+line 3\n+EOF\n+\n+test_expect_success 'setup repository with dos files' '\n+        append_cr <file1 >file\n+        git add file &&\n+        git commit -m Initial &&\n+        git tag start &&\n+        append_cr <file2 >file\n+        git commit -a -m Second &&\n+        git tag start2 &&\n+        append_cr <file3 >file\n+        git commit -a -m Third &&\n+\tgit format-patch -k --stdout start.. > format-patch.diff\n+'\n+\n+test_expect_success 'mailsplit format-patch of dos files' '\n+        mkdir split &&\n+        git mailsplit -osplit format-patch.diff &&\n+        cat split/0001 split/0002 > mailsplit.diff &&\n+        test_must_fail test_cmp format-patch.diff mailsplit.diff\n+'\n+\n+test_expect_success 'mailsplit --keep-cr format-patch of dos files' '\n+        mkdir split2 &&\n+        git mailsplit --keep-cr -osplit2 format-patch.diff &&\n+        cat split2/0001 split2/0002 > mailsplit2.diff &&\n+        test_cmp format-patch.diff mailsplit2.diff\n+'\n+\n+test_expect_success 'format-patch with dos files --keep-cr' '\n+        git checkout -b new start &&\n+\tgit format-patch -k --stdout start..master | git am --keep-cr -k -3 &&\n+        git diff master\n+'\n+\n+test_expect_success 'format-patch with dos files config.mailsplit' '\n+        git config am.keepcr 1 &&\n+        git checkout -b new3 start &&\n+\tgit format-patch -k --stdout start..master | git am -k -3 &&\n+        git diff master\n+'\n+\n+test_done\n-- \n1.7.0.rc2.31.g49e2a\n"},{"id":"134445","messageId":"1266080362-24760-1-git-send-email-stefan.hahn@s-hahn.de","threadId":"22644","inReplyTo":"1266080362-24760-1-git-send-email-stefan.hahn@s-hahn.de","subject":"[PATCHv3 0/3] Using git-mailsplit in mixed line ending environment","fromName":"Stefan-W. Hahn","fromEmail":"stefan.hahn@s-hahn.de","sentAt":"2010-02-13T17:09:54Z","receivedAt":"2010-02-13T17:09:54Z","isPatch":false,"sender":{"key":"stefan.hahn@s-hahn.de","avatar":null},"body":"Hello,\n\nI'm using git in environments with files having dos or unix line\nending. I apply patches using 'git format-patch ... | git am ...'.\nA change in git-mailsplit in commit c2ca1d79 introduced a change in\nthe default behaviour of git-mailsplit when splitting mbox patches. It\nmakes dos line endings to unix line endings. With this behaviour it is\nimpossible to apply patches.\n\nThe following patches introduce the '--kepp-cr' parameter to git-am an\nan additional possibility to set '--keep-cr' via configuration for\ngit-am. Also I added missing description for '--keep-cr' of\ngit-mailsplit.\n\nSecond round:\nI changed 'mailsplit.keep-cr' to 'mailsplit.keepcr' as suggested by Jakub\nand comment in the testcase.\n\nThird round:\nI moved configuration 'mailsplit.keepcr' to 'am.keepcr' because\ngit-mailsplit can be used outside a git repository (thx Junio).\n\nStefan\n\nStefan-W. Hahn (3):\n      git-mailsplit: Show parameter '--keep-cr' in usage and documentation\n      git-am: Add command line parameter `--keep-cr` passing it to git-mailsplit.\n      Adding test for `--keep-cr` for git-am.\n\n Documentation/config.txt        |    6 +++\n Documentation/git-mailsplit.txt |    5 ++-\n builtin-mailsplit.c             |    2 +-\n git-am.sh                       |   27 +++++++++++----\n t/t4253-am-keep-cr-dos.sh       |   68 +++++++++++++++++++++++++++++++++++++++\n 5 files changed, 99 insertions(+), 9 deletions(-)\n"},{"id":"134446","messageId":"20100213171121.GA14754@scotty.home","threadId":"22644","inReplyTo":"1266080362-24760-1-git-send-email-stefan.hahn@s-hahn.de","subject":"[PATCH 1/3] git-mailsplit: Show parameter '--keep-cr' in usage and documentation","fromName":"Stefan-W. Hahn","fromEmail":"stefan.hahn@s-hahn.de","sentAt":"2010-02-13T17:11:21Z","receivedAt":"2010-02-13T17:11:21Z","isPatch":true,"sender":{"key":"stefan.hahn@s-hahn.de","avatar":null},"body":"Signed-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>\n---\n Documentation/git-mailsplit.txt |    5 ++++-\n builtin-mailsplit.c             |    2 +-\n 2 files changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-mailsplit.txt b/Documentation/git-mailsplit.txt\nindex 5cc94ec..a634485 100644\n--- a/Documentation/git-mailsplit.txt\n+++ b/Documentation/git-mailsplit.txt\n@@ -7,7 +7,7 @@ git-mailsplit - Simple UNIX mbox splitter program\n \n SYNOPSIS\n --------\n-'git mailsplit' [-b] [-f<nn>] [-d<prec>] -o<directory> [--] [<mbox>|<Maildir>...]\n+'git mailsplit' [-b] [-f<nn>] [-d<prec>] [--keep-cr] -o<directory> [--] [<mbox>|<Maildir>...]\n \n DESCRIPTION\n -----------\n@@ -43,6 +43,9 @@ OPTIONS\n \tSkip the first <nn> numbers, for example if -f3 is specified,\n \tstart the numbering with 0004.\n \n+--keep-cr::\n+\tDo not remove `\\r` from lines ending with `\\r\\n`.\n+\n Author\n ------\n Written by Linus Torvalds <torvalds@osdl.org>\ndiff --git a/builtin-mailsplit.c b/builtin-mailsplit.c\nindex 207e358..cdfc1b7 100644\n--- a/builtin-mailsplit.c\n+++ b/builtin-mailsplit.c\n@@ -10,7 +10,7 @@\n #include \"strbuf.h\"\n \n static const char git_mailsplit_usage[] =\n-\"git mailsplit [-d<prec>] [-f<n>] [-b] -o<directory> [<mbox>|<Maildir>...]\";\n+\"git mailsplit [-d<prec>] [-f<n>] [-b] [--keep-cr] -o<directory> [<mbox>|<Maildir>...]\";\n \n static int is_from_line(const char *line, int len)\n {\n-- \n1.7.0.rc2.31.g49e2a\n"},{"id":"134448","messageId":"20100213171127.GB14754@scotty.home","threadId":"22644","inReplyTo":"1266080362-24760-1-git-send-email-stefan.hahn@s-hahn.de","subject":"[PATCH 2/3] git-am: Add command line parameter `--keep-cr` passing it to git-mailsplit.","fromName":"Stefan-W. Hahn","fromEmail":"stefan.hahn@s-hahn.de","sentAt":"2010-02-13T17:11:27Z","receivedAt":"2010-02-13T17:11:27Z","isPatch":true,"sender":{"key":"stefan.hahn@s-hahn.de","avatar":null},"body":"The behaviour of git-mailsplit, which is called from git-am for\npatches in mbox format, has been changed in commit c2ca1d79. The new\ndefault behaviour will remove `\\r` from line endings with `\\r\\n`.\n\nIf applying patches with the following command sequence\n\n   git format-patch --stdout ... | git am ...\n\nin repositories having files with dos and unix line endings,\ngit-mailsplit must be called with `--keep-cr` parameter.\n\nThis patch adds the command line parameter `--keep-cr` for git-am and\nthe configuration `am.keepcr`.\n\nSigned-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>\n---\n Documentation/config.txt |    6 ++++++\n git-am.sh                |   27 ++++++++++++++++++++-------\n 2 files changed, 26 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 4c36aa9..aa452f3 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -550,6 +550,12 @@ it will be treated as a shell command.  For example, defining\n executed from the top-level directory of a repository, which may\n not necessarily be the current directory.\n \n+am.keepcr::\n+\tIf true, git-am will call git-mailsplit for patches in mbox format \n+\twith parameter '--keep-cr'. In this case git-mailsplit will\n+\tnot remove `\\r` from lines ending with `\\r\\n`. \n+\tSee linkgit:git-am[1], linkgit:git-mailsplit[1].\n+\n apply.ignorewhitespace::\n \tWhen set to 'change', tells 'git apply' to ignore changes in\n \twhitespace, in the same way as the '--ignore-space-change'\ndiff --git a/git-am.sh b/git-am.sh\nindex c8b9cbb..3057a83 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -15,6 +15,7 @@ q,quiet         be quiet\n s,signoff       add a Signed-off-by line to the commit message\n u,utf8          recode into utf8 (default)\n k,keep          pass -k flag to git-mailinfo\n+keep-cr         pass --keep-cr flag to git-mailsplit for mbox format\n c,scissors      strip everything before a scissors line\n whitespace=     pass it through git-apply\n ignore-space-change pass it through git-apply\n@@ -216,12 +217,12 @@ check_patch_format () {\n split_patches () {\n \tcase \"$patch_format\" in\n \tmbox)\n-\t\tcase \"$rebasing\" in\n-\t\t'')\n-\t\t\tkeep_cr= ;;\n-\t\t?*)\n-\t\t\tkeep_cr=--keep-cr ;;\n-\t\tesac\n+\t\tif test -n \"$rebasing$keepcr\"\n+\t\tthen\n+                    keep_cr=--keep-cr\n+\t\telse\n+                    keep_cr=\n+\t\tfi\n \t\tgit mailsplit -d\"$prec\" -o\"$dotest\" -b $keep_cr -- \"$@\" > \"$dotest/last\" ||\n \t\tclean_abort\n \t\t;;\n@@ -290,13 +291,18 @@ split_patches () {\n \n prec=4\n dotest=\"$GIT_DIR/rebase-apply\"\n-sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=\n+sign= utf8=t keep= keepcr= skip= interactive= resolved= rebasing= abort=\n resolvemsg= resume= scissors= no_inbody_headers=\n git_apply_opt=\n committer_date_is_author_date=\n ignore_date=\n allow_rerere_autoupdate=\n \n+if test \"$(git config --bool --get am.keepcr)\" = true\n+then \n+    keepcr=t\n+fi\n+\n while test $# != 0\n do\n \tcase \"$1\" in\n@@ -347,6 +353,8 @@ do\n \t\tallow_rerere_autoupdate=\"$1\" ;;\n \t-q|--quiet)\n \t\tGIT_QUIET=t ;;\n+\t--keep-cr)\n+\t\tkeepcr=t ;;\n \t--)\n \t\tshift; break ;;\n \t*)\n@@ -452,6 +460,7 @@ else\n \techo \"$sign\" >\"$dotest/sign\"\n \techo \"$utf8\" >\"$dotest/utf8\"\n \techo \"$keep\" >\"$dotest/keep\"\n+\techo \"$keepcr\" >\"$dotest/keepcr\"\n \techo \"$scissors\" >\"$dotest/scissors\"\n \techo \"$no_inbody_headers\" >\"$dotest/no_inbody_headers\"\n \techo \"$GIT_QUIET\" >\"$dotest/quiet\"\n@@ -495,6 +504,10 @@ if test \"$(cat \"$dotest/keep\")\" = t\n then\n \tkeep=-k\n fi\n+if test \"$(cat \"$dotest/keepcr\")\" = t\n+then\n+\tkeepcr=--keep-cr\n+fi\n case \"$(cat \"$dotest/scissors\")\" in\n t)\n \tscissors=--scissors ;;\n-- \n1.7.0.rc2.31.g49e2a\n"},{"id":"134447","messageId":"20100213171132.GC14754@scotty.home","threadId":"22644","inReplyTo":"1266080362-24760-1-git-send-email-stefan.hahn@s-hahn.de","subject":"[PATCH 3/3] Adding test for `--keep-cr` for git-am.","fromName":"Stefan-W. Hahn","fromEmail":"stefan.hahn@s-hahn.de","sentAt":"2010-02-13T17:11:32Z","receivedAt":"2010-02-13T17:11:32Z","isPatch":true,"sender":{"key":"stefan.hahn@s-hahn.de","avatar":null},"body":"This test adds test for git-am dos line endings, the command sequence\n'git format-patch ... | git am ...' and the configuration variable\n`am.keepcr`.\n\nSigned-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>\n---\n t/t4253-am-keep-cr-dos.sh |   68 +++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 68 insertions(+), 0 deletions(-)\n create mode 100644 t/t4253-am-keep-cr-dos.sh\n\ndiff --git a/t/t4253-am-keep-cr-dos.sh b/t/t4253-am-keep-cr-dos.sh\nnew file mode 100644\nindex 0000000..a4f5f80\n--- /dev/null\n+++ b/t/t4253-am-keep-cr-dos.sh\n@@ -0,0 +1,68 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2010 Stefan-W. Hahn\n+#\n+\n+test_description='git-am mbox with dos line ending.\n+\n+'\n+. ./test-lib.sh\n+\n+# Three patches which will be added as files with dos line ending.\n+\n+cat > file1 <<\\EOF\n+line 1\n+EOF\n+\n+cat > file2 <<\\EOF\n+line 1\n+line 2\n+EOF\n+\n+cat > file3 <<\\EOF\n+line 1\n+line 2\n+line 3\n+EOF\n+\n+test_expect_success 'setup repository with dos files' '\n+        append_cr <file1 >file\n+        git add file &&\n+        git commit -m Initial &&\n+        git tag start &&\n+        append_cr <file2 >file\n+        git commit -a -m Second &&\n+        git tag start2 &&\n+        append_cr <file3 >file\n+        git commit -a -m Third &&\n+\tgit format-patch -k --stdout start.. > format-patch.diff\n+'\n+\n+test_expect_success 'mailsplit format-patch of dos files' '\n+        mkdir split &&\n+        git mailsplit -osplit format-patch.diff &&\n+        cat split/0001 split/0002 > mailsplit.diff &&\n+        test_must_fail test_cmp format-patch.diff mailsplit.diff\n+'\n+\n+test_expect_success 'mailsplit --keep-cr format-patch of dos files' '\n+        mkdir split2 &&\n+        git mailsplit --keep-cr -osplit2 format-patch.diff &&\n+        cat split2/0001 split2/0002 > mailsplit2.diff &&\n+        test_cmp format-patch.diff mailsplit2.diff\n+'\n+\n+test_expect_success 'format-patch with dos files --keep-cr' '\n+        git checkout -b new start &&\n+\tgit format-patch -k --stdout start..master | git am --keep-cr -k -3 &&\n+        git diff master\n+'\n+\n+test_expect_success 'format-patch with dos files config.mailsplit' '\n+        git config am.keepcr 1 &&\n+        git checkout -b new3 start &&\n+\tgit format-patch -k --stdout start..master | git am -k -3 &&\n+        git diff master\n+'\n+\n+test_done\n-- \n1.7.0.rc2.31.g49e2a\n"},{"id":"135342","messageId":"7v635p9dss.fsf@alter.siamese.dyndns.org","threadId":"22644","inReplyTo":"20100213171127.GB14754@scotty.home","subject":"Re: [PATCH 2/3] git-am: Add command line parameter `--keep-cr` passing it to git-mailsplit.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-02-22T21:10:59Z","receivedAt":"2010-02-22T21:10:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Stefan-W. Hahn\" <stefan.hahn@s-hahn.de> writes:\n\n> The behaviour of git-mailsplit, which is called from git-am for\n> patches in mbox format, has been changed in commit c2ca1d79. The new\n> default behaviour will remove `\\r` from line endings with `\\r\\n`.\n\nThis might offend people who caused c2ca1d7 (Allow mailsplit (and hence\ngit-am) to handle mails with CRLF line-endings, 2009-08-04) to come into\nexistence in the first place, as their argument was that \"git am\" not\nreading from the output from their MUA's save-as (Thunderbird I think it\nwas but I may be mistaken) was a _bug_.  I personally didn't like that\nbugfix very much and we could have added --strip-cr to help them back\nthen, but that is not what happened.\n\nPerhaps this would be a more agreeable description of the backstory?\n\n    c2ca1d7 (Allow mailsplit (and hence git-am) to handle mails with CRLF\n    line-endings, 2009-08-04) fixed \"git mailsplit\" to help people with\n    MUA whose output from save-as command uses CRLF as line terminators by\n    stripping CR at the end of lines.\n\n    However, when you know you are feeding output from \"git format-patch\"\n    directly to \"git am\", and especially when your contents have CR at the\n    end of line, such stripping is undesirable.  To help such a use case,\n    teach --keep-cr option to \"git am\" and pass that to \"git mailinfo\".\n\n> This patch adds the command line parameter `--keep-cr` for git-am and\n> the configuration `am.keepcr`.\n\nIf one sets am.keepcr (because he regularly runs format-patch piped to am\nby hand), but occasionally wants to apply an e-mailed patch out of his MUA\nthat happens to write things out with CRLF, how would one do so, without\ntouching the configuration (and not forgetting to revert the change after\ndoing so)?\n\nAs a general rule, if you introduce a new configuration, you need to make\nsure that the configuration can be overriden per invocation if necessary,\nand it is usually done from the command line, i.e. \"--no-keep-cr\".\n\nI have to warn you that it would be a lot more work that needs careful\nthinking than adding a command line option alone, so you may want to split\nthis [PATCH 2/3] into two, one to add command line option, and the other\nto add configuration.\n\n> diff --git a/Documentation/config.txt b/Documentation/config.txt\n> index 4c36aa9..aa452f3 100644\n> --- a/Documentation/config.txt\n> +++ b/Documentation/config.txt\n> @@ -550,6 +550,12 @@ it will be treated as a shell command.  For example, defining\n>  executed from the top-level directory of a repository, which may\n>  not necessarily be the current directory.\n>  \n> +am.keepcr::\n> +\tIf true, git-am will call git-mailsplit for patches in mbox format \n> +\twith parameter '--keep-cr'. In this case git-mailsplit will\n> +\tnot remove `\\r` from lines ending with `\\r\\n`. \n\nHence you would need something like:\n\n    s/$/  Can be overriden by giving --no-keep-cr from the command line./\n\nAlso Documentation/git-am.txt would need something like:\n\n--keep-cr::\n--no-keep-cr::\n\tWith --keep-cr, call git-mailsplit with the same option, to\n        prevent it from stripping CR at the end of lines.  `am.keepcr`\n        configuration variable can be used to specify the default\n\tbehaviour.  --no-keep-cr is useful to override `am.keepcr`.\n\n> diff --git a/git-am.sh b/git-am.sh\n> index c8b9cbb..3057a83 100755\n> --- a/git-am.sh\n> +++ b/git-am.sh\n> @@ -347,6 +353,8 @@ do\n>  \t\tallow_rerere_autoupdate=\"$1\" ;;\n>  \t-q|--quiet)\n>  \t\tGIT_QUIET=t ;;\n> +\t--keep-cr)\n> +\t\tkeepcr=t ;;\n>  \t--)\n>  \t\tshift; break ;;\n>  \t*)\n\nAnd you obviously need to have \"--no-keep-cr\" here...\n\n> @@ -452,6 +460,7 @@ else\n>  \techo \"$sign\" >\"$dotest/sign\"\n>  \techo \"$utf8\" >\"$dotest/utf8\"\n>  \techo \"$keep\" >\"$dotest/keep\"\n> +\techo \"$keepcr\" >\"$dotest/keepcr\"\n>  \techo \"$scissors\" >\"$dotest/scissors\"\n>  \techo \"$no_inbody_headers\" >\"$dotest/no_inbody_headers\"\n>  \techo \"$GIT_QUIET\" >\"$dotest/quiet\"\n> @@ -495,6 +504,10 @@ if test \"$(cat \"$dotest/keep\")\" = t\n>  then\n>  \tkeep=-k\n>  fi\n> +if test \"$(cat \"$dotest/keepcr\")\" = t\n> +then\n> +\tkeepcr=--keep-cr\n> +fi\n\nAlso you may have to set keepcr to --no-keep-cr or something (I won't do\nthe necessary thinking for you while writing this message), to deal with a\ncase where:\n\n - The user has am.keepcr set to true;\n\n - This particular invocation was made with --no-keep-cr from the command\n   line;\n\n - It stopped due to unappliable patch in the series and $dotest/keepcr\n   became empty;\n\n - The user dealt with the stoppage and restarted the command; we read\n   empty from $dotest/keepcr.\n\nIf I am reading your patch correctly, I think the restarted command will\nuse keepcr=t that was set by reading from the configuration at the\nbeginning?\n"},{"id":"135343","messageId":"7v1vgd9d5c.fsf@alter.siamese.dyndns.org","threadId":"22644","inReplyTo":"20100213171132.GC14754@scotty.home","subject":"Re: [PATCH 3/3] Adding test for `--keep-cr` for git-am.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-02-22T21:25:03Z","receivedAt":"2010-02-22T21:25:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Stefan-W. Hahn\" <stefan.hahn@s-hahn.de> writes:\n\n> This test adds test for git-am dos line endings, the command sequence\n> 'git format-patch ... | git am ...' and the configuration variable\n> `am.keepcr`.\n>\n> Signed-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>\n> ---\n>  t/t4253-am-keep-cr-dos.sh |   68 +++++++++++++++++++++++++++++++++++++++++++++\n>  1 files changed, 68 insertions(+), 0 deletions(-)\n>  create mode 100644 t/t4253-am-keep-cr-dos.sh\n>\n> diff --git a/t/t4253-am-keep-cr-dos.sh b/t/t4253-am-keep-cr-dos.sh\n> new file mode 100644\n\nThis should be 100755, if this need to be a new separate test.\n\n> index 0000000..a4f5f80\n> --- /dev/null\n> +++ b/t/t4253-am-keep-cr-dos.sh\n> @@ -0,0 +1,68 @@\n> +#!/bin/sh\n> +#\n> +# Copyright (c) 2010 Stefan-W. Hahn\n> +#\n> +\n> +test_description='git-am mbox with dos line ending.\n> +\n> +'\n> +. ./test-lib.sh\n> +\n> +# Three patches which will be added as files with dos line ending.\n> +\n> +cat > file1 <<\\EOF\n> +line 1\n> +EOF\n> +\n> +cat > file2 <<\\EOF\n> +line 1\n> +line 2\n> +EOF\n> +\n> +cat > file3 <<\\EOF\n> +line 1\n> +line 2\n> +line 3\n> +EOF\n> +\n> +test_expect_success 'setup repository with dos files' '\n> +        append_cr <file1 >file\n> +        git add file &&\n> +        git commit -m Initial &&\n> +        git tag start &&\n> +        append_cr <file2 >file\n> +        git commit -a -m Second &&\n> +        git tag start2 &&\n> +        append_cr <file3 >file\n> +        git commit -a -m Third &&\n> +\tgit format-patch -k --stdout start.. > format-patch.diff\n> +'\n\nHmm, do I see a mixed indentation here?\n\n> +test_expect_success 'mailsplit format-patch of dos files' '\n> +        mkdir split &&\n> +        git mailsplit -osplit format-patch.diff &&\n> +        cat split/0001 split/0002 > mailsplit.diff &&\n> +        test_must_fail test_cmp format-patch.diff mailsplit.diff\n> +'\n> +\n> +test_expect_success 'mailsplit --keep-cr format-patch of dos files' '\n> +        mkdir split2 &&\n> +        git mailsplit --keep-cr -osplit2 format-patch.diff &&\n> +        cat split2/0001 split2/0002 > mailsplit2.diff &&\n> +        test_cmp format-patch.diff mailsplit2.diff\n> +'\n\nThese seem to be mailsplit test; are they necessary?  mailsplit is an\ninternal implementation detail of am, and we might later want to change\nwhat it does as long as the change does not affect what the calling am\nends up doing, but even with benign change the above two test would fail.\n\n> +test_expect_success 'format-patch with dos files --keep-cr' '\n> +        git checkout -b new start &&\n> +\tgit format-patch -k --stdout start..master | git am --keep-cr -k -3 &&\n\nIf a long line bothers you, you can split the line at pipe like this:\n\n\tgit format-patch -k --stdout start..master |\n\tgit am --keep-cr -k -3 &&\n\nBecause the shell knows that you haven't finished your sentence yet when\nit sees the pipe at the end of line, you do not need a backslash at the\nend (the same goes for the && at the end).\n\n> +        git diff master\n> +'\n\n\"git diff\" by default does not report presense or absense of difference\nwith its exit code.  A traditional way to check this is\n\n\ttest -z \"$(git diff master)\"\n\nYou can choose to use a more modern\n\n\tgit diff --exit-code master\n\n> +test_expect_success 'format-patch with dos files config.mailsplit' '\n> +        git config am.keepcr 1 &&\n> +        git checkout -b new3 start &&\n> +\tgit format-patch -k --stdout start..master | git am -k -3 &&\n> +        git diff master\n> +'\n\nTwo tests are lacking.\n\n - test that \"git am\" fails without --keep-cr nor configuration when fed a\n   history with CRLF.\n\n - test that \"am.keepcr\" can be countermanded per \"git am\" invocation;\n\nAlso I think t4252 needs to be taught about this new option, as I think\nyou would want the second ('please continue') invocation in this sequence\n\n\t$ git am --keep-cr mbox\n        ... oops, one does not apply\n        ... goes to fix\n        $ git am\n\nto keep your CR in the payload.\n"},{"id":"135839","messageId":"1267280428-18223-1-git-send-email-stefan.hahn@s-hahn.de","threadId":"22644","inReplyTo":"1266080362-24760-1-git-send-email-stefan.hahn@s-hahn.de","subject":"[PATCHv4 0/4] Using git-mailsplit in mixed line ending environment","fromName":"Stefan-W. Hahn","fromEmail":"stefan.hahn@s-hahn.de","sentAt":"2010-02-27T14:20:24Z","receivedAt":"2010-02-27T14:20:24Z","isPatch":false,"sender":{"key":"stefan.hahn@s-hahn.de","avatar":null},"body":"Hello,\n\nI'm using git in environments with files having dos or unix line\nending. I apply patches using 'git format-patch ... | git am ...'.\nA change in git-mailsplit in commit c2ca1d79 introduced a change in\nthe default behaviour of git-mailsplit when splitting mbox patches. It\nmakes dos line endings to unix line endings. With this behaviour it is\nimpossible to apply patches.\n\nThe following patches introduce the '--kepp-cr', '--no-keep-cr'\nparameter to git-am an an additional possibility to set '--keep-cr'\nvia configuration for git-am. Also I added missing description for\n'--keep-cr' of git-mailsplit.\n\nSecond round:\nI changed 'mailsplit.keep-cr' to 'mailsplit.keepcr' as suggested by Jakub\nand comment in the testcase.\n\nThird round:\nI moved configuration 'mailsplit.keepcr' to 'am.keepcr' because\ngit-mailsplit can be used outside a git repository (thx Junio).\n\nFourth round:\nI considered the replies from Junio and split up the patch introducing \nconfiguration am.keepcr in two. I introduced an '--no-keep-cr' to overwrite\nconfiguration. I removed git-mailsplit tests from the test suite, they only \nshowed the behaviour when using dos line ending.\nI added some tests to show the correct behaviour in different situations\nusing the new parameters and configuration.\n\n\nStefan\n\n[PATCH 1/4] git-mailsplit: Show parameter '--keep-cr' in usage and documentation\n[PATCH 2/4] git-am: Add command line parameter `--keep-cr` passing it to git-mailsplit.\n[PATCH 3/4] git-am: Add configuration am.keepcr and parameter --no-keep-cr to override configuration.\n[PATCH 4/4] git-am: Adding tests for `--keep-cr`, `--no-keep-cr` and `am.keepcr`.\n \nDocumentation/config.txt        |    7 +++\nDocumentation/git-am.txt        |    9 +++-\nDocumentation/git-mailsplit.txt |    5 ++-\nbuiltin-mailsplit.c             |    2 +-\ngit-am.sh                       |   32 ++++++++++---\nt/t4253-am-keep-cr-dos.sh       |   96 +++++++++++++++++++++++++++++++++++++++\n6 files changed, 141 insertions(+), 10 deletions(-)\n"},{"id":"135837","messageId":"1267280428-18223-2-git-send-email-stefan.hahn@s-hahn.de","threadId":"22644","inReplyTo":"1266080362-24760-1-git-send-email-stefan.hahn@s-hahn.de","subject":"[PATCH 1/4] git-mailsplit: Show parameter '--keep-cr' in usage and documentation","fromName":"Stefan-W. Hahn","fromEmail":"stefan.hahn@s-hahn.de","sentAt":"2010-02-27T14:20:25Z","receivedAt":"2010-02-27T14:20:25Z","isPatch":true,"sender":{"key":"stefan.hahn@s-hahn.de","avatar":null},"body":"Signed-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>\n---\n Documentation/git-mailsplit.txt |    5 ++++-\n builtin-mailsplit.c             |    2 +-\n 2 files changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-mailsplit.txt b/Documentation/git-mailsplit.txt\nindex 5cc94ec..a634485 100644\n--- a/Documentation/git-mailsplit.txt\n+++ b/Documentation/git-mailsplit.txt\n@@ -7,7 +7,7 @@ git-mailsplit - Simple UNIX mbox splitter program\n \n SYNOPSIS\n --------\n-'git mailsplit' [-b] [-f<nn>] [-d<prec>] -o<directory> [--] [<mbox>|<Maildir>...]\n+'git mailsplit' [-b] [-f<nn>] [-d<prec>] [--keep-cr] -o<directory> [--] [<mbox>|<Maildir>...]\n \n DESCRIPTION\n -----------\n@@ -43,6 +43,9 @@ OPTIONS\n \tSkip the first <nn> numbers, for example if -f3 is specified,\n \tstart the numbering with 0004.\n \n+--keep-cr::\n+\tDo not remove `\\r` from lines ending with `\\r\\n`.\n+\n Author\n ------\n Written by Linus Torvalds <torvalds@osdl.org>\ndiff --git a/builtin-mailsplit.c b/builtin-mailsplit.c\nindex 207e358..cdfc1b7 100644\n--- a/builtin-mailsplit.c\n+++ b/builtin-mailsplit.c\n@@ -10,7 +10,7 @@\n #include \"strbuf.h\"\n \n static const char git_mailsplit_usage[] =\n-\"git mailsplit [-d<prec>] [-f<n>] [-b] -o<directory> [<mbox>|<Maildir>...]\";\n+\"git mailsplit [-d<prec>] [-f<n>] [-b] [--keep-cr] -o<directory> [<mbox>|<Maildir>...]\";\n \n static int is_from_line(const char *line, int len)\n {\n-- \n1.7.0.98.g42448\n"},{"id":"135840","messageId":"1267280428-18223-3-git-send-email-stefan.hahn@s-hahn.de","threadId":"22644","inReplyTo":"1266080362-24760-1-git-send-email-stefan.hahn@s-hahn.de","subject":"[PATCH 2/4] git-am: Add command line parameter `--keep-cr` passing it to git-mailsplit.","fromName":"Stefan-W. Hahn","fromEmail":"stefan.hahn@s-hahn.de","sentAt":"2010-02-27T14:20:26Z","receivedAt":"2010-02-27T14:20:26Z","isPatch":true,"sender":{"key":"stefan.hahn@s-hahn.de","avatar":null},"body":"c2ca1d7 (Allow mailsplit (and hence git-am) to handle mails with CRLF\nline-endings, 2009-08-04) fixed \"git mailsplit\" to help people with\nMUA whose output from save-as command uses CRLF as line terminators by\nstripping CR at the end of lines.\n\nHowever, when you know you are feeding output from \"git format-patch\"\ndirectly to \"git am\", and especially when your contents have CR at the\nend of line, such stripping is undesirable.  To help such a use case,\nteach --keep-cr option to \"git am\" and pass that to \"git mailinfo\".\n\nSigned-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>\n---\n Documentation/git-am.txt |    7 ++++++-\n git-am.sh                |   22 +++++++++++++++-------\n 2 files changed, 21 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/git-am.txt b/Documentation/git-am.txt\nindex c66c565..df3c6d6 100644\n--- a/Documentation/git-am.txt\n+++ b/Documentation/git-am.txt\n@@ -9,7 +9,7 @@ git-am - Apply a series of patches from a mailbox\n SYNOPSIS\n --------\n [verse]\n-'git am' [--signoff] [--keep] [--utf8 | --no-utf8]\n+'git am' [--signoff] [--keep] [--keep-cr] [--utf8 | --no-utf8]\n \t [--3way] [--interactive] [--committer-date-is-author-date]\n \t [--ignore-date] [--ignore-space-change | --ignore-whitespace]\n \t [--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]\n@@ -39,6 +39,11 @@ OPTIONS\n --keep::\n \tPass `-k` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]).\n \n+--keep-cr::\n+\tWith `--keep-cr`, call 'git mailsplit' (see linkgit:git-mailsplit[1])\n+\twith the same option, to prevent it from stripping CR at the end of \n+\tlines.\n+\n -c::\n --scissors::\n \tRemove everything in body before a scissors line (see\ndiff --git a/git-am.sh b/git-am.sh\nindex ebfbee5..7563609 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -15,6 +15,7 @@ q,quiet         be quiet\n s,signoff       add a Signed-off-by line to the commit message\n u,utf8          recode into utf8 (default)\n k,keep          pass -k flag to git-mailinfo\n+keep-cr         pass --keep-cr flag to git-mailsplit for mbox format\n c,scissors      strip everything before a scissors line\n whitespace=     pass it through git-apply\n ignore-space-change pass it through git-apply\n@@ -217,12 +218,12 @@ check_patch_format () {\n split_patches () {\n \tcase \"$patch_format\" in\n \tmbox)\n-\t\tcase \"$rebasing\" in\n-\t\t'')\n-\t\t\tkeep_cr= ;;\n-\t\t?*)\n-\t\t\tkeep_cr=--keep-cr ;;\n-\t\tesac\n+\t\tif test -n \"$rebasing$keepcr\"\n+\t\tthen\n+                    keep_cr=--keep-cr\n+\t\telse\n+                    keep_cr=\n+\t\tfi\n \t\tgit mailsplit -d\"$prec\" -o\"$dotest\" -b $keep_cr -- \"$@\" > \"$dotest/last\" ||\n \t\tclean_abort\n \t\t;;\n@@ -291,7 +292,7 @@ split_patches () {\n \n prec=4\n dotest=\"$GIT_DIR/rebase-apply\"\n-sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=\n+sign= utf8=t keep= keepcr= skip= interactive= resolved= rebasing= abort=\n resolvemsg= resume= scissors= no_inbody_headers=\n git_apply_opt=\n committer_date_is_author_date=\n@@ -348,6 +349,8 @@ do\n \t\tallow_rerere_autoupdate=\"$1\" ;;\n \t-q|--quiet)\n \t\tGIT_QUIET=t ;;\n+\t--keep-cr)\n+\t\tkeepcr=t ;;\n \t--)\n \t\tshift; break ;;\n \t*)\n@@ -453,6 +456,7 @@ else\n \techo \"$sign\" >\"$dotest/sign\"\n \techo \"$utf8\" >\"$dotest/utf8\"\n \techo \"$keep\" >\"$dotest/keep\"\n+\techo \"$keepcr\" >\"$dotest/keepcr\"\n \techo \"$scissors\" >\"$dotest/scissors\"\n \techo \"$no_inbody_headers\" >\"$dotest/no_inbody_headers\"\n \techo \"$GIT_QUIET\" >\"$dotest/quiet\"\n@@ -496,6 +500,10 @@ if test \"$(cat \"$dotest/keep\")\" = t\n then\n \tkeep=-k\n fi\n+if test \"$(cat \"$dotest/keepcr\")\" = t\n+then\n+\tkeepcr=--keep-cr\n+fi\n case \"$(cat \"$dotest/scissors\")\" in\n t)\n \tscissors=--scissors ;;\n-- \n1.7.0.98.g42448\n"},{"id":"135841","messageId":"1267280428-18223-4-git-send-email-stefan.hahn@s-hahn.de","threadId":"22644","inReplyTo":"1266080362-24760-1-git-send-email-stefan.hahn@s-hahn.de","subject":"[PATCH 3/4] git-am: Add configuration am.keepcr and parameter --no-keep-cr to override configuration.","fromName":"Stefan-W. Hahn","fromEmail":"stefan.hahn@s-hahn.de","sentAt":"2010-02-27T14:20:27Z","receivedAt":"2010-02-27T14:20:27Z","isPatch":true,"sender":{"key":"stefan.hahn@s-hahn.de","avatar":null},"body":"This patch adds the configuration `am.keepcr` for git-am. It also adds\n`--no-keep-cr` parameter for git-am to give the possibility to\noverride configuration from command line.\n\nSigned-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>\n---\n Documentation/config.txt |    7 +++++++\n Documentation/git-am.txt |    6 ++++--\n git-am.sh                |   20 +++++++++++++++-----\n 3 files changed, 26 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 664de6b..403c392 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -555,6 +555,13 @@ it will be treated as a shell command.  For example, defining\n executed from the top-level directory of a repository, which may\n not necessarily be the current directory.\n \n+am.keepcr::\n+\tIf true, git-am will call git-mailsplit for patches in mbox format \n+\twith parameter '--keep-cr'. In this case git-mailsplit will\n+\tnot remove `\\r` from lines ending with `\\r\\n`. Can be overrriden\n+\tby giving '--no-keep-cr' from the command line.\n+\tSee linkgit:git-am[1], linkgit:git-mailsplit[1].\n+\n apply.ignorewhitespace::\n \tWhen set to 'change', tells 'git apply' to ignore changes in\n \twhitespace, in the same way as the '--ignore-space-change'\ndiff --git a/Documentation/git-am.txt b/Documentation/git-am.txt\nindex df3c6d6..aef2b86 100644\n--- a/Documentation/git-am.txt\n+++ b/Documentation/git-am.txt\n@@ -9,7 +9,7 @@ git-am - Apply a series of patches from a mailbox\n SYNOPSIS\n --------\n [verse]\n-'git am' [--signoff] [--keep] [--keep-cr] [--utf8 | --no-utf8]\n+'git am' [--signoff] [--keep] [--keep-cr | --no-keep-cr] [--utf8 | --no-utf8]\n \t [--3way] [--interactive] [--committer-date-is-author-date]\n \t [--ignore-date] [--ignore-space-change | --ignore-whitespace]\n \t [--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]\n@@ -40,9 +40,11 @@ OPTIONS\n \tPass `-k` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]).\n \n --keep-cr::\n+--no-keep-cr::\n \tWith `--keep-cr`, call 'git mailsplit' (see linkgit:git-mailsplit[1])\n \twith the same option, to prevent it from stripping CR at the end of \n-\tlines.\n+\tlines. `am.keepcr` configuration variable can be used to specify the \n+\tdefault behaviour.  `--no-keep-cr` is useful to override `am.keepcr`.\n \n -c::\n --scissors::\ndiff --git a/git-am.sh b/git-am.sh\nindex 7563609..ed42df0 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -16,6 +16,7 @@ s,signoff       add a Signed-off-by line to the commit message\n u,utf8          recode into utf8 (default)\n k,keep          pass -k flag to git-mailinfo\n keep-cr         pass --keep-cr flag to git-mailsplit for mbox format\n+no-keep-cr      do not pass --keep-cr flag to git-mailsplit independent of am.keepcr\n c,scissors      strip everything before a scissors line\n whitespace=     pass it through git-apply\n ignore-space-change pass it through git-apply\n@@ -218,7 +219,7 @@ check_patch_format () {\n split_patches () {\n \tcase \"$patch_format\" in\n \tmbox)\n-\t\tif test -n \"$rebasing$keepcr\"\n+\t\tif test -n \"$rebasing\" -o \"$keepcr\" = t\n \t\tthen\n                     keep_cr=--keep-cr\n \t\telse\n@@ -299,6 +300,11 @@ committer_date_is_author_date=\n ignore_date=\n allow_rerere_autoupdate=\n \n+if test \"$(git config --bool --get am.keepcr)\" = true\n+then \n+    keepcr=t\n+fi\n+\n while test $# != 0\n do\n \tcase \"$1\" in\n@@ -351,6 +357,8 @@ do\n \t\tGIT_QUIET=t ;;\n \t--keep-cr)\n \t\tkeepcr=t ;;\n+\t--no-keep-cr)\n+\t\tkeepcr=f ;;\n \t--)\n \t\tshift; break ;;\n \t*)\n@@ -500,10 +508,12 @@ if test \"$(cat \"$dotest/keep\")\" = t\n then\n \tkeep=-k\n fi\n-if test \"$(cat \"$dotest/keepcr\")\" = t\n-then\n-\tkeepcr=--keep-cr\n-fi\n+case \"$(cat \"$dotest/keepcr\")\" in\n+t)\n+\tkeepcr=--keep-cr ;;\n+f)\n+\tkeepcr=--no-keep-cr ;;\n+esac\n case \"$(cat \"$dotest/scissors\")\" in\n t)\n \tscissors=--scissors ;;\n-- \n1.7.0.98.g42448\n"},{"id":"135838","messageId":"1267280428-18223-5-git-send-email-stefan.hahn@s-hahn.de","threadId":"22644","inReplyTo":"1266080362-24760-1-git-send-email-stefan.hahn@s-hahn.de","subject":"[PATCH 4/4] git-am: Adding tests for `--keep-cr`, `--no-keep-cr` and `am.keepcr`.","fromName":"Stefan-W. Hahn","fromEmail":"stefan.hahn@s-hahn.de","sentAt":"2010-02-27T14:20:28Z","receivedAt":"2010-02-27T14:20:28Z","isPatch":true,"sender":{"key":"stefan.hahn@s-hahn.de","avatar":null},"body":"This test adds tests for git-am using files with dos line endings for\nvarious combinations of `--keep-cr`, `--no-keep-cr` and `am.keepcr`.\n\nSigned-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>\n---\n t/t4253-am-keep-cr-dos.sh |   96 +++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 96 insertions(+), 0 deletions(-)\n create mode 100755 t/t4253-am-keep-cr-dos.sh\n\ndiff --git a/t/t4253-am-keep-cr-dos.sh b/t/t4253-am-keep-cr-dos.sh\nnew file mode 100755\nindex 0000000..6c4cb35\n--- /dev/null\n+++ b/t/t4253-am-keep-cr-dos.sh\n@@ -0,0 +1,96 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2010 Stefan-W. Hahn\n+#\n+\n+test_description='git-am mbox with dos line ending.\n+\n+'\n+. ./test-lib.sh\n+\n+# Three patches which will be added as files with dos line ending.\n+\n+cat > file1 <<\\EOF\n+line 1\n+EOF\n+\n+cat > file1a <<\\EOF\n+line 1\n+line 4\n+EOF\n+\n+cat > file2 <<\\EOF\n+line 1\n+line 2\n+EOF\n+\n+cat > file3 <<\\EOF\n+line 1\n+line 2\n+line 3\n+EOF\n+\n+test_expect_success 'setup repository with dos files' '\n+        append_cr <file1 >file &&\n+        git add file &&\n+        git commit -m Initial &&\n+        git tag initial &&\n+        append_cr <file2 >file &&\n+        git commit -a -m Second &&\n+        append_cr <file3 >file &&\n+        git commit -a -m Third\n+'\n+\n+test_expect_success 'am with dos files without --keep-cr' '\n+        git checkout -b dosfiles initial &&\n+        git format-patch -k initial..master &&\n+        test_must_fail git am -k -3 000*.patch &&\n+        git am --abort &&\n+        rm -rf .git/rebase-apply 000*.patch\n+'\n+\n+test_expect_success 'am with dos files with --keep-cr' '\n+        git checkout -b dosfiles-keep-cr initial &&\n+        git format-patch -k --stdout initial..master | git am --keep-cr -k -3 &&\n+        git diff --exit-code master\n+'\n+\n+test_expect_success 'am with dos files config am.keepcr' '\n+        git config am.keepcr 1 &&\n+        git checkout -b dosfiles-conf-keepcr initial &&\n+        git format-patch -k --stdout initial..master | git am -k -3 &&\n+        git diff --exit-code master\n+'\n+\n+test_expect_success 'am with dos files config am.keepcr overriden by --no-keep-cr' '\n+        git config am.keepcr 1 &&\n+        git checkout -b dosfiles-conf-keepcr-override initial &&\n+        git format-patch -k initial..master &&\n+        test_must_fail git am -k -3 --no-keep-cr 000*.patch &&\n+        git am --abort &&\n+        rm -rf .git/rebase-apply 000*.patch\n+'\n+\n+test_expect_success 'am with dos files with --keep-cr continue' '\n+        git checkout -b dosfiles-keep-cr-continue initial &&\n+        git format-patch -k initial..master &&\n+        append_cr <file1a >file &&\n+        git commit -m \"different patch\" file &&\n+        test_must_fail git am --keep-cr -k -3 000*.patch &&\n+        append_cr <file2 >file &&\n+        git add file &&\n+        git am -3 --resolved &&\n+        git diff --exit-code master\n+'\n+\n+test_expect_success 'am with unix files config am.keepcr overriden by --no-keep-cr' '\n+        git config am.keepcr 1 &&\n+        git checkout -b unixfiles-conf-keepcr-override initial &&\n+        cp -f file1 file &&\n+        git commit -m \"line ending to unix\" file &&\n+        git format-patch -k initial..master &&\n+        git am -k -3 --no-keep-cr 000*.patch &&\n+        git diff --exit-code -w master\n+'\n+\n+test_done\n-- \n1.7.0.98.g42448\n"},{"id":"135900","messageId":"7vvddhukj4.fsf@alter.siamese.dyndns.org","threadId":"22644","inReplyTo":"1267280428-18223-1-git-send-email-stefan.hahn@s-hahn.de","subject":"Re: [PATCHv4 0/4] Using git-mailsplit in mixed line ending environment","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-02-28T21:18:07Z","receivedAt":"2010-02-28T21:18:07Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks, will queue.\n"}]}