[PATCH] init-db: Store current value of autocrlf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Storing the current value of autocrlf to preserve it for this repository
even if the global setup changes is a good idea.  Changing autocrlf
later is tricky because the work tree's line endings depend on the
settings during checkout.  Therefore, it makes sense to preserve the
value of autocrlf that exists during the first checkout.  In this
regards autocrlf is different from, for example, author, because author
can be easily changed later without requiring any conversion of existing
files in the work tree.

This commit modifies the initialization of a new repository to store the
current value of autocrlf.

Signed-off-by: Steffen Prohaska <prohaska@xxxxxx>
---
 builtin-init-db.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/builtin-init-db.c b/builtin-init-db.c
index 79eaf8d..6c49a82 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -268,6 +268,22 @@ static int create_default_files(const char *git_dir, const char *template_path)
 			git_config_set("core.symlinks", "false");
 	}
 
+	/*
+	 *  Store current value of auto_crlf to preserve it for
+	 *  this repository even if the global setup changes.
+	 */
+	switch (auto_crlf) {
+	case -1:
+		git_config_set("core.autocrlf", "input");
+		break;
+	case 0:
+		git_config_set("core.autocrlf", "false");
+		break;
+	case 1:
+		git_config_set("core.autocrlf", "true");
+		break;
+	}
+
 	return reinit;
 }
 
-- 
1.5.5.rc0.21.g740fd.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux