diff options
author | Vicent Martà <vicent@github.com> | 2013-03-25 14:42:53 -0700 |
---|---|---|
committer | Vicent Martà <vicent@github.com> | 2013-03-25 14:42:53 -0700 |
commit | f17951d6ea4ba18c68716a89d7b7464e40ec98f7 (patch) | |
tree | 468b0ba5739118b56d1961063655ffbbf95d8a12 /tests-clar/index/tests.c | |
parent | 13640d1bb8376e3f07f66498a5b9bdde9ff3d7d6 (diff) | |
parent | 3658e81e3499f874dc9f323d4d9127df7e219e12 (diff) | |
download | libgit2-f17951d6ea4ba18c68716a89d7b7464e40ec98f7.tar.gz |
Merge pull request #1431 from libgit2/autocrlf-fixes
Fix crlf handling, particularly when autocrlf=true
Diffstat (limited to 'tests-clar/index/tests.c')
-rw-r--r-- | tests-clar/index/tests.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests-clar/index/tests.c b/tests-clar/index/tests.c index 64f547ead..88e374e6e 100644 --- a/tests-clar/index/tests.c +++ b/tests-clar/index/tests.c @@ -251,6 +251,48 @@ void test_index_tests__add(void) git_repository_free(repo); } +static void cleanup_1397(void *opaque) +{ + GIT_UNUSED(opaque); + cl_git_sandbox_cleanup(); +} + +void test_index_tests__add_issue_1397(void) +{ + git_index *index; + git_repository *repo; + const git_index_entry *entry; + git_oid id1; + + cl_set_cleanup(&cleanup_1397, NULL); + + repo = cl_git_sandbox_init("issue_1397"); + + cl_repo_set_bool(repo, "core.autocrlf", true); + + /* Ensure we're the only guy in the room */ + cl_git_pass(git_repository_index(&index, repo)); + + /* Store the expected hash of the file/blob + * This has been generated by executing the following + * $ git hash-object crlf_file.txt + */ + cl_git_pass(git_oid_fromstr(&id1, "8312e0889a9cbab77c732b6bc39b51a683e3a318")); + + /* Make sure the initial SHA-1 is correct */ + cl_assert((entry = git_index_get_bypath(index, "crlf_file.txt", 0)) != NULL); + cl_assert_(git_oid_cmp(&id1, &entry->oid) == 0, "first oid check"); + + /* Update the index */ + cl_git_pass(git_index_add_bypath(index, "crlf_file.txt")); + + /* Check the new SHA-1 */ + cl_assert((entry = git_index_get_bypath(index, "crlf_file.txt", 0)) != NULL); + cl_assert_(git_oid_cmp(&id1, &entry->oid) == 0, "second oid check"); + + git_index_free(index); +} + void test_index_tests__add_bypath_to_a_bare_repository_returns_EBAREPO(void) { git_repository *bare_repo; |