Commit 52462e1ccecdea86cceae9d25bf343265831bbaf

pontusm 2012-05-13T10:11:13

Test case to reproduce issue #690. Staged file status does not handle CRLF correctly. Ensures that the test repo has core.autocrlf=true for the test to fail.

diff --git a/tests-clar/status/worktree.c b/tests-clar/status/worktree.c
index 75975c9..d4ae48b 100644
--- a/tests-clar/status/worktree.c
+++ b/tests-clar/status/worktree.c
@@ -797,3 +797,30 @@ void test_status_worktree__interruptable_foreach(void)
 
 	cl_assert_equal_i(8, count);
 }
+
+void test_status_worktree__new_staged_file_must_handle_crlf(void)
+{
+	git_repository *repo;
+	git_index *index;
+	git_config *config;
+	unsigned int status;
+
+	cl_git_pass(git_repository_init(&repo, "getting_started", 0));
+
+	// Ensure that repo has core.autocrlf=true
+	cl_git_pass(git_repository_config(&config, repo));
+	cl_git_pass(git_config_set_bool(config, "core.autocrlf", true));
+
+	cl_git_mkfile("getting_started/testfile.txt", "content\r\n");	// Content with CRLF
+
+	cl_git_pass(git_repository_index(&index, repo));
+	cl_git_pass(git_index_add(index, "testfile.txt", 0));
+	cl_git_pass(git_index_write(index));
+
+	cl_git_pass(git_status_file(&status, repo, "testfile.txt"));
+	cl_assert_equal_i(GIT_STATUS_INDEX_NEW, status);
+
+	git_config_free(config);
+	git_index_free(index);
+	git_repository_free(repo);
+}