git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git-mailsplit: add `mailsplit.keep-cr` configuration variable.

From
SHStefan-W. Hahn <stefan.hahn@s-hahn.de>
Date
Feb 11, 2010, 18:13 UTC
Message-ID
<20100211181354.GC15028@scotty.home>
In-Reply-To
<1265911741-14840-1-git-send-email-stefan.hahn@s-hahn.de>

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
Previous: Stefan-W. HahnNext: Jakub Narebski
Message 2 of 6 in “git-mailsplit: Show parameter '--keep-cr' in usage and documentation”
  1. Stefan-W. HahnFeb 11, 2010
  2. git-mailsplit: add `mailsplit.keep-cr` configuration variable.Stefan-W. Hahn, Feb 11, 2010
  3. Jakub NarebskiFeb 11, 2010
  4. Junio C HamanoFeb 11, 2010
  5. git-am: Add command line parameter `--keep-cr` passing it to git-mailsplit.Stefan-W. Hahn, Feb 11, 2010
  6. Adding test for `--keep-cr` for git-mailsplit and git-am.Stefan-W. Hahn, Feb 11, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.