* git-mailsplit: Show parameter '--keep-cr' in usage and documentation
[not found] <1265911741-14840-1-git-send-email-stefan.hahn@s-hahn.de>
@ 2010-02-11 18:13 ` Stefan-W. Hahn
2010-02-11 18:13 ` git-mailsplit: add `mailsplit.keep-cr` configuration variable Stefan-W. Hahn
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Stefan-W. Hahn @ 2010-02-11 18:13 UTC (permalink / raw)
To: git
Signed-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>
---
Documentation/git-mailsplit.txt | 5 ++++-
builtin-mailsplit.c | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-mailsplit.txt b/Documentation/git-mailsplit.txt
index 5cc94ec..a634485 100644
--- a/Documentation/git-mailsplit.txt
+++ b/Documentation/git-mailsplit.txt
@@ -7,7 +7,7 @@ git-mailsplit - Simple UNIX mbox splitter program
SYNOPSIS
--------
-'git mailsplit' [-b] [-f<nn>] [-d<prec>] -o<directory> [--] [<mbox>|<Maildir>...]
+'git mailsplit' [-b] [-f<nn>] [-d<prec>] [--keep-cr] -o<directory> [--] [<mbox>|<Maildir>...]
DESCRIPTION
-----------
@@ -43,6 +43,9 @@ OPTIONS
Skip the first <nn> numbers, for example if -f3 is specified,
start the numbering with 0004.
+--keep-cr::
+ Do not remove `\r` from lines ending with `\r\n`.
+
Author
------
Written by Linus Torvalds <torvalds@osdl.org>
diff --git a/builtin-mailsplit.c b/builtin-mailsplit.c
index 207e358..cdfc1b7 100644
--- a/builtin-mailsplit.c
+++ b/builtin-mailsplit.c
@@ -10,7 +10,7 @@
#include "strbuf.h"
static const char git_mailsplit_usage[] =
-"git mailsplit [-d<prec>] [-f<n>] [-b] -o<directory> [<mbox>|<Maildir>...]";
+"git mailsplit [-d<prec>] [-f<n>] [-b] [--keep-cr] -o<directory> [<mbox>|<Maildir>...]";
static int is_from_line(const char *line, int len)
{
--
1.7.0.rc1.50.g84249.dirty
^ permalink raw reply related [flat|nested] 6+ messages in thread
* git-mailsplit: add `mailsplit.keep-cr` configuration variable.
[not found] <1265911741-14840-1-git-send-email-stefan.hahn@s-hahn.de>
2010-02-11 18:13 ` git-mailsplit: Show parameter '--keep-cr' in usage and documentation Stefan-W. Hahn
@ 2010-02-11 18:13 ` Stefan-W. Hahn
2010-02-11 18:35 ` Jakub Narebski
2010-02-11 18:14 ` git-am: Add command line parameter `--keep-cr` passing it to git-mailsplit Stefan-W. Hahn
2010-02-11 18:14 ` Adding test for `--keep-cr` for git-mailsplit and git-am Stefan-W. Hahn
3 siblings, 1 reply; 6+ messages in thread
From: Stefan-W. Hahn @ 2010-02-11 18:13 UTC (permalink / raw)
To: git
If using git-mailsplit in environments where files with dos and unix
line ending stay in one repository mbox patches must be split with
additional parameter '--keep-cr', because the behaviour of
git-mailsplit have been changed in commit c2ca1d79.
With this patch the behaviour of git-mailsplit can be set via
configuration file.
Signed-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>
---
Documentation/config.txt | 4 ++++
builtin-mailsplit.c | 10 ++++++++++
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 4c36aa9..3ee64a6 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1246,6 +1246,10 @@ mailmap.file::
subdirectory, or somewhere outside of the repository itself.
See linkgit:git-shortlog[1] and linkgit:git-blame[1].
+mailsplit.keep-cr::
+ If true git-mailsplit will not remove `\r` from lines ending
+ with `\r\n`. See linkgit:git-mailsplit[1].
+
man.viewer::
Specify the programs that may be used to display help in the
'man' format. See linkgit:git-help[1].
diff --git a/builtin-mailsplit.c b/builtin-mailsplit.c
index cdfc1b7..a16de52 100644
--- a/builtin-mailsplit.c
+++ b/builtin-mailsplit.c
@@ -210,6 +210,15 @@ out:
return ret;
}
+static int git_mailsplit_config(const char *var, const char *value, void *cb)
+{
+ if (!strcmp(var, "mailsplit.keep-cr")) {
+ keep_cr = git_config_bool(var, value);
+ return 0;
+ }
+ return git_default_config(var, value, cb);
+}
+
int cmd_mailsplit(int argc, const char **argv, const char *prefix)
{
int nr = 0, nr_prec = 4, num = 0;
@@ -218,6 +227,7 @@ int cmd_mailsplit(int argc, const char **argv, const char *prefix)
const char **argp;
static const char *stdin_only[] = { "-", NULL };
+ git_config(git_mailsplit_config, NULL);
for (argp = argv+1; *argp; argp++) {
const char *arg = *argp;
--
1.7.0.rc1.50.g84249.dirty
^ permalink raw reply related [flat|nested] 6+ messages in thread
* git-am: Add command line parameter `--keep-cr` passing it to git-mailsplit.
[not found] <1265911741-14840-1-git-send-email-stefan.hahn@s-hahn.de>
2010-02-11 18:13 ` git-mailsplit: Show parameter '--keep-cr' in usage and documentation Stefan-W. Hahn
2010-02-11 18:13 ` git-mailsplit: add `mailsplit.keep-cr` configuration variable Stefan-W. Hahn
@ 2010-02-11 18:14 ` Stefan-W. Hahn
2010-02-11 18:14 ` Adding test for `--keep-cr` for git-mailsplit and git-am Stefan-W. Hahn
3 siblings, 0 replies; 6+ messages in thread
From: Stefan-W. Hahn @ 2010-02-11 18:14 UTC (permalink / raw)
To: git
If applying patches with the following command sequence
git format-patch --stdout ... | git am ...
in repositories having files with dos and unix line endings
git-mailsplit, which is called from git-am must be called with
`--keep-cr` parameter since commit c2ca1d79.
This patch adds the command line parameter `--keep-cr` for git-am.
Signed-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>
---
git-am.sh | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/git-am.sh b/git-am.sh
index c8b9cbb..c3101ae 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -15,6 +15,7 @@ q,quiet be quiet
s,signoff add a Signed-off-by line to the commit message
u,utf8 recode into utf8 (default)
k,keep pass -k flag to git-mailinfo
+e,keep-cr pass --keep-cr flag to git-mailsplit for mbox format
c,scissors strip everything before a scissors line
whitespace= pass it through git-apply
ignore-space-change pass it through git-apply
@@ -216,10 +217,12 @@ check_patch_format () {
split_patches () {
case "$patch_format" in
mbox)
- case "$rebasing" in
- '')
+ case "$rebasing,$keepcr" in
+ '','')
keep_cr= ;;
- ?*)
+ '',t)
+ keep_cr=--keep-cr ;;
+ ?*,t)
keep_cr=--keep-cr ;;
esac
git mailsplit -d"$prec" -o"$dotest" -b $keep_cr -- "$@" > "$dotest/last" ||
@@ -290,7 +293,7 @@ split_patches () {
prec=4
dotest="$GIT_DIR/rebase-apply"
-sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=
+sign= utf8=t keep= keepcr= skip= interactive= resolved= rebasing= abort=
resolvemsg= resume= scissors= no_inbody_headers=
git_apply_opt=
committer_date_is_author_date=
@@ -347,6 +350,8 @@ do
allow_rerere_autoupdate="$1" ;;
-q|--quiet)
GIT_QUIET=t ;;
+ -e|--keep-cr)
+ keepcr=t ;;
--)
shift; break ;;
*)
@@ -452,6 +457,7 @@ else
echo "$sign" >"$dotest/sign"
echo "$utf8" >"$dotest/utf8"
echo "$keep" >"$dotest/keep"
+ echo "$keepcr" >"$dotest/keepcr"
echo "$scissors" >"$dotest/scissors"
echo "$no_inbody_headers" >"$dotest/no_inbody_headers"
echo "$GIT_QUIET" >"$dotest/quiet"
@@ -495,6 +501,10 @@ if test "$(cat "$dotest/keep")" = t
then
keep=-k
fi
+if test "$(cat "$dotest/keepcr")" = t
+then
+ keepcr=--keep-cr
+fi
case "$(cat "$dotest/scissors")" in
t)
scissors=--scissors ;;
--
1.7.0.rc1.50.g84249.dirty
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Adding test for `--keep-cr` for git-mailsplit and git-am.
[not found] <1265911741-14840-1-git-send-email-stefan.hahn@s-hahn.de>
` (2 preceding siblings ...)
2010-02-11 18:14 ` git-am: Add command line parameter `--keep-cr` passing it to git-mailsplit Stefan-W. Hahn
@ 2010-02-11 18:14 ` Stefan-W. Hahn
3 siblings, 0 replies; 6+ messages in thread
From: Stefan-W. Hahn @ 2010-02-11 18:14 UTC (permalink / raw)
To: git
This test adds test for git-mailsplit using dos line endings, the
command sequence 'git format-patch ... | git am ...' and the
configuration variable `mailsplit.keep-cr`.
Signed-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>
---
t/t5101-mailinfo-dos.sh | 75 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 75 insertions(+), 0 deletions(-)
create mode 100644 t/t5101-mailinfo-dos.sh
diff --git a/t/t5101-mailinfo-dos.sh b/t/t5101-mailinfo-dos.sh
new file mode 100644
index 0000000..0afa713
--- /dev/null
+++ b/t/t5101-mailinfo-dos.sh
@@ -0,0 +1,75 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Stefan-W. Hahn
+#
+
+test_description='git-mailsplit mbox with dos line ending.
+
+'
+. ./test-lib.sh
+
+# This primes main.c file that indents without using HT at all.
+# Various patches with HT and other spaces are attempted in the test.
+
+cat > file1 <<\EOF
+line 1
+EOF
+
+cat > file2 <<\EOF
+line 1
+line 2
+EOF
+
+cat > file3 <<\EOF
+line 1
+line 2
+line 3
+EOF
+
+test_expect_success 'setup repository with dos files' '
+ append_cr <file1 >file
+ git add file &&
+ git commit -m Initial &&
+ git tag start &&
+ append_cr <file2 >file
+ git commit -a -m Second &&
+ git tag start2 &&
+ append_cr <file3 >file
+ git commit -a -m Third &&
+ git format-patch -k --stdout start.. > format-patch.diff
+'
+
+test_expect_failure 'mailsplit format-patch of dos files' '
+ mkdir split &&
+ git mailsplit -osplit format-patch.diff &&
+ cat split/0001 split/0002 > mailsplit.diff &&
+ test_cmp format-patch.diff mailsplit.diff
+'
+
+test_expect_success 'mailsplit --keep-cr format-patch of dos files' '
+ mkdir split2 &&
+ git mailsplit --keep-cr -osplit2 format-patch.diff &&
+ cat split2/0001 split2/0002 > mailsplit2.diff &&
+ test_cmp format-patch.diff mailsplit2.diff
+'
+
+test_expect_success 'format-patch with dos files --keep-cr' '
+ git checkout -b new start &&
+ git format-patch -k --stdout start..master | git am --keep-cr -k -3 &&
+ git diff master
+'
+
+test_expect_success 'format-patch with dos files -e' '
+ git checkout -b new2 start &&
+ git format-patch -k --stdout start..master | git am -e -k -3 &&
+ git diff master
+'
+
+test_expect_success 'format-patch with dos files config.mailsplit' '
+ git config mailsplit.keep-cr 1 &&
+ git checkout -b new3 start &&
+ git format-patch -k --stdout start..master | git am -k -3 &&
+ git diff master
+'
+
+test_done
--
1.7.0.rc1.50.g84249.dirty
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: git-mailsplit: add `mailsplit.keep-cr` configuration variable.
2010-02-11 18:13 ` git-mailsplit: add `mailsplit.keep-cr` configuration variable Stefan-W. Hahn
@ 2010-02-11 18:35 ` Jakub Narebski
2010-02-11 20:36 ` Junio C Hamano
0 siblings, 1 reply; 6+ messages in thread
From: Jakub Narebski @ 2010-02-11 18:35 UTC (permalink / raw)
To: Stefan-W. Hahn; +Cc: git
Subject should read start with '[PATCH 2/4] '.
"Stefan-W. Hahn" <stefan.hahn@s-hahn.de> writes:
> If using git-mailsplit in environments where files with dos and unix
> line ending stay in one repository mbox patches must be split with
> additional parameter '--keep-cr', because the behaviour of
> git-mailsplit have been changed in commit c2ca1d79.
>
> With this patch the behaviour of git-mailsplit can be set via
> configuration file.
>
> Signed-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de>
> ---
[...]
> +mailsplit.keep-cr::
> + If true git-mailsplit will not remove `\r` from lines ending
> + with `\r\n`. See linkgit:git-mailsplit[1].
> +
The convention use by config variables is to have camelCase or
allsmallcase name (variable name and section name are case
insensitive), e.g.:
transfer.unpackLimit::
status.showUntrackedFiles::
sendemail.aliasfiletype::
repack.usedeltabaseoffset::
etc., with the only outlier being add.ignore-errors.
--
Jakub Narebski
Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: git-mailsplit: add `mailsplit.keep-cr` configuration variable.
2010-02-11 18:35 ` Jakub Narebski
@ 2010-02-11 20:36 ` Junio C Hamano
0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2010-02-11 20:36 UTC (permalink / raw)
To: Jakub Narebski; +Cc: Stefan-W. Hahn, git
Jakub Narebski <jnareb@gmail.com> writes:
> etc., with the only outlier being add.ignore-errors.
Perhaps a synonym add.ignoreErrors would help, so that later we could
deprecate that outlier?
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-02-11 20:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1265911741-14840-1-git-send-email-stefan.hahn@s-hahn.de>
2010-02-11 18:13 ` git-mailsplit: Show parameter '--keep-cr' in usage and documentation Stefan-W. Hahn
2010-02-11 18:13 ` git-mailsplit: add `mailsplit.keep-cr` configuration variable Stefan-W. Hahn
2010-02-11 18:35 ` Jakub Narebski
2010-02-11 20:36 ` Junio C Hamano
2010-02-11 18:14 ` git-am: Add command line parameter `--keep-cr` passing it to git-mailsplit Stefan-W. Hahn
2010-02-11 18:14 ` Adding test for `--keep-cr` for git-mailsplit and git-am Stefan-W. Hahn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).