{"thread":{"id":"22618","subject":"git-mailsplit: Show parameter '--keep-cr' in usage and documentation","startedAt":"2010-02-11T18:13:36Z","lastAt":"2010-02-11T20:36:05Z","messageCount":6,"participants":["Stefan-W. Hahn","Jakub Narebski","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"134244","messageId":"20100211181336.GB15028@scotty.home","threadId":"22618","inReplyTo":"1265911741-14840-1-git-send-email-stefan.hahn@s-hahn.de","subject":"git-mailsplit: Show parameter '--keep-cr' in usage and documentation","fromName":"Stefan-W. Hahn","fromEmail":"stefan.hahn@s-hahn.de","sentAt":"2010-02-11T18:13:36Z","receivedAt":"2010-02-11T18:13:36Z","isPatch":false,"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.rc1.50.g84249.dirty\n"},{"id":"134245","messageId":"20100211181354.GC15028@scotty.home","threadId":"22618","inReplyTo":"1265911741-14840-1-git-send-email-stefan.hahn@s-hahn.de","subject":"git-mailsplit: add `mailsplit.keep-cr` configuration variable.","fromName":"Stefan-W. Hahn","fromEmail":"stefan.hahn@s-hahn.de","sentAt":"2010-02-11T18:13:54Z","receivedAt":"2010-02-11T18:13:54Z","isPatch":false,"sender":{"key":"stefan.hahn@s-hahn.de","avatar":null},"body":"If using git-mailsplit in environments where files with dos and unix\nline ending stay in one repository mbox patches must be split with\nadditional parameter '--keep-cr', because the behaviour of\ngit-mailsplit have been changed in commit c2ca1d79.\n\nWith this patch the behaviour of git-mailsplit can be set via\nconfiguration file.\n\nSigned-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>\n---\n Documentation/config.txt |    4 ++++\n builtin-mailsplit.c      |   10 ++++++++++\n 2 files changed, 14 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 4c36aa9..3ee64a6 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1246,6 +1246,10 @@ mailmap.file::\n \tsubdirectory, or somewhere outside of the repository itself.\n \tSee linkgit:git-shortlog[1] and linkgit:git-blame[1].\n \n+mailsplit.keep-cr::\n+\tIf true git-mailsplit will not remove `\\r` from lines ending\n+\twith `\\r\\n`. See linkgit:git-mailsplit[1].\n+\n man.viewer::\n \tSpecify the programs that may be used to display help in the\n \t'man' format. See linkgit:git-help[1].\ndiff --git a/builtin-mailsplit.c b/builtin-mailsplit.c\nindex cdfc1b7..a16de52 100644\n--- a/builtin-mailsplit.c\n+++ b/builtin-mailsplit.c\n@@ -210,6 +210,15 @@ out:\n \treturn ret;\n }\n \n+static int git_mailsplit_config(const char *var, const char *value, void *cb)\n+{\n+\tif (!strcmp(var, \"mailsplit.keep-cr\")) {\n+\t\tkeep_cr = git_config_bool(var, value);\n+\t\treturn 0;\n+\t}\n+\treturn git_default_config(var, value, cb);\n+}\n+\n int cmd_mailsplit(int argc, const char **argv, const char *prefix)\n {\n \tint nr = 0, nr_prec = 4, num = 0;\n@@ -218,6 +227,7 @@ int cmd_mailsplit(int argc, const char **argv, const char *prefix)\n \tconst char **argp;\n \tstatic const char *stdin_only[] = { \"-\", NULL };\n \n+\tgit_config(git_mailsplit_config, NULL);\n \tfor (argp = argv+1; *argp; argp++) {\n \t\tconst char *arg = *argp;\n \n-- \n1.7.0.rc1.50.g84249.dirty\n"},{"id":"134246","messageId":"20100211181412.GD15028@scotty.home","threadId":"22618","inReplyTo":"1265911741-14840-1-git-send-email-stefan.hahn@s-hahn.de","subject":"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-11T18:14:12Z","receivedAt":"2010-02-11T18:14:12Z","isPatch":false,"sender":{"key":"stefan.hahn@s-hahn.de","avatar":null},"body":"If 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, which is called from git-am must be called with\n`--keep-cr` parameter since commit c2ca1d79.\n\nThis patch adds the command line parameter `--keep-cr` for git-am.\n\nSigned-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>\n---\n git-am.sh |   18 ++++++++++++++----\n 1 files changed, 14 insertions(+), 4 deletions(-)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex c8b9cbb..c3101ae 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+e,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,10 +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\tcase \"$rebasing,$keepcr\" in\n+\t\t'','')\n \t\t\tkeep_cr= ;;\n-\t\t?*)\n+\t\t'',t)\n+\t\t\tkeep_cr=--keep-cr ;;\n+\t\t?*,t)\n \t\t\tkeep_cr=--keep-cr ;;\n \t\tesac\n \t\tgit mailsplit -d\"$prec\" -o\"$dotest\" -b $keep_cr -- \"$@\" > \"$dotest/last\" ||\n@@ -290,7 +293,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@@ -347,6 +350,8 @@ do\n \t\tallow_rerere_autoupdate=\"$1\" ;;\n \t-q|--quiet)\n \t\tGIT_QUIET=t ;;\n+        -e|--keep-cr)\n+                keepcr=t ;;\n \t--)\n \t\tshift; break ;;\n \t*)\n@@ -452,6 +457,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 +501,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.rc1.50.g84249.dirty\n"},{"id":"134247","messageId":"20100211181426.GE15028@scotty.home","threadId":"22618","inReplyTo":"1265911741-14840-1-git-send-email-stefan.hahn@s-hahn.de","subject":"Adding test for `--keep-cr` for git-mailsplit and git-am.","fromName":"Stefan-W. Hahn","fromEmail":"stefan.hahn@s-hahn.de","sentAt":"2010-02-11T18:14:26Z","receivedAt":"2010-02-11T18:14:26Z","isPatch":false,"sender":{"key":"stefan.hahn@s-hahn.de","avatar":null},"body":"This test adds test for git-mailsplit using dos line endings, the\ncommand sequence 'git format-patch ... | git am ...' and the\nconfiguration variable `mailsplit.keep-cr`.\n\nSigned-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>\n---\n t/t5101-mailinfo-dos.sh |   75 +++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 75 insertions(+), 0 deletions(-)\n create mode 100644 t/t5101-mailinfo-dos.sh\n\ndiff --git a/t/t5101-mailinfo-dos.sh b/t/t5101-mailinfo-dos.sh\nnew file mode 100644\nindex 0000000..0afa713\n--- /dev/null\n+++ b/t/t5101-mailinfo-dos.sh\n@@ -0,0 +1,75 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2010 Stefan-W. Hahn\n+#\n+\n+test_description='git-mailsplit mbox with dos line ending.\n+\n+'\n+. ./test-lib.sh\n+\n+# This primes main.c file that indents without using HT at all.\n+# Various patches with HT and other spaces are attempted in the test.\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_failure '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_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 -e' '\n+        git checkout -b new2 start &&\n+\tgit format-patch -k --stdout start..master | git am -e -k -3 &&\n+        git diff master\n+'\n+\n+test_expect_success 'format-patch with dos files config.mailsplit' '\n+        git config mailsplit.keep-cr 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.rc1.50.g84249.dirty\n"},{"id":"134248","messageId":"m3k4uj8vts.fsf@localhost.localdomain","threadId":"22618","inReplyTo":"20100211181354.GC15028@scotty.home","subject":"Re: git-mailsplit: add `mailsplit.keep-cr` configuration variable.","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-02-11T18:35:54Z","receivedAt":"2010-02-11T18:35:54Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Subject should read start with '[PATCH 2/4] '.\n\n\"Stefan-W. Hahn\" <stefan.hahn@s-hahn.de> writes:\n\n> If using git-mailsplit in environments where files with dos and unix\n> line ending stay in one repository mbox patches must be split with\n> additional parameter '--keep-cr', because the behaviour of\n> git-mailsplit have been changed in commit c2ca1d79.\n> \n> With this patch the behaviour of git-mailsplit can be set via\n> configuration file.\n> \n> Signed-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>\n> ---\n[...]\n\n> +mailsplit.keep-cr::\n> +\tIf true git-mailsplit will not remove `\\r` from lines ending\n> +\twith `\\r\\n`. See linkgit:git-mailsplit[1].\n> +\n\nThe convention use by config variables is to have camelCase or\nallsmallcase name (variable name and section name are case\ninsensitive), e.g.:\n\n  transfer.unpackLimit::\n  status.showUntrackedFiles::\n  sendemail.aliasfiletype::\n  repack.usedeltabaseoffset::\n\netc., with the only outlier being add.ignore-errors.\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"134254","messageId":"7vmxzf33yi.fsf@alter.siamese.dyndns.org","threadId":"22618","inReplyTo":"m3k4uj8vts.fsf@localhost.localdomain","subject":"Re: git-mailsplit: add `mailsplit.keep-cr` configuration variable.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-02-11T20:36:05Z","receivedAt":"2010-02-11T20:36:05Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> etc., with the only outlier being add.ignore-errors.\n\nPerhaps a synonym add.ignoreErrors would help, so that later we could\ndeprecate that outlier?\n"}]}