summaryrefslogtreecommitdiff
path: root/tests-clar/index
diff options
context:
space:
mode:
authorSven Strickroth <email@cs-ware.de>2013-03-07 22:15:40 +0100
committerRussell Belfer <rb@github.com>2013-03-25 14:03:16 -0700
commitb8acb775e25c76f07dac8855ad0a88b37f7b2f17 (patch)
treef7e8d173813745f2a56c6078897fb9aeb9cad479 /tests-clar/index
parent9733e80c2ae7517f44c658cd2914d99454470dd1 (diff)
downloadlibgit2-b8acb775e25c76f07dac8855ad0a88b37f7b2f17.tar.gz
Added some tests for issue #1397
Signed-off-by: Sven Strickroth <email@cs-ware.de>
Diffstat (limited to 'tests-clar/index')
-rw-r--r--tests-clar/index/tests.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests-clar/index/tests.c b/tests-clar/index/tests.c
index 64f547ead..49defd03f 100644
--- a/tests-clar/index/tests.c
+++ b/tests-clar/index/tests.c
@@ -251,6 +251,46 @@ void test_index_tests__add(void)
git_repository_free(repo);
}
+void test_index_tests__add_issue_1397(void)
+{
+ git_index *index;
+ git_config *cfg;
+ git_repository *repo;
+ const git_index_entry *entry;
+ git_oid id1;
+
+ cl_set_cleanup(&cleanup_myrepo, NULL);
+
+ repo = cl_git_sandbox_init("issue_1397");
+
+ cl_git_pass(git_repository_config(&cfg, repo));
+ cl_git_pass(git_config_set_bool(cfg, "core.autocrlf", true));
+ git_config_free(cfg);
+
+ /* 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);
+
+ /* 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);
+
+ git_index_free(index);
+ git_repository_free(repo);
+}
+
void test_index_tests__add_bypath_to_a_bare_repository_returns_EBAREPO(void)
{
git_repository *bare_repo;