diff options
author | Edward Thomson <ethomson@microsoft.com> | 2015-09-29 14:16:51 -0400 |
---|---|---|
committer | Edward Thomson <ethomson@microsoft.com> | 2015-09-29 14:16:51 -0400 |
commit | 10df661b8cd2a7e4751f8344633825dfc88be169 (patch) | |
tree | 92c82c78b34432f3666416e9e5bcdca8d59db6b0 /tests/index/bypath.c | |
parent | fc3ef147ec592ddcd83c9fd817ef74f0e2d72ec3 (diff) | |
download | libgit2-10df661b8cd2a7e4751f8344633825dfc88be169.tar.gz |
index: test that add_bypath preserves mode
Diffstat (limited to 'tests/index/bypath.c')
-rw-r--r-- | tests/index/bypath.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/index/bypath.c b/tests/index/bypath.c index b152b0917..d26273f76 100644 --- a/tests/index/bypath.c +++ b/tests/index/bypath.c @@ -240,3 +240,26 @@ void test_index_bypath__add_honors_existing_case_4(void) cl_assert_equal_s("just_a_dir/a/b/Z/y/X/foo.txt", entry->path); } +void test_index_bypath__add_honors_mode(void) +{ + git_index_entry *entry, new_entry; + + cl_assert((entry = git_index_get_bypath(g_idx, "README.txt", 0)) != NULL); + + memcpy(&new_entry, entry, sizeof(git_index_entry)); + new_entry.path = "README.txt"; + new_entry.mode = GIT_FILEMODE_BLOB_EXECUTABLE; + + cl_must_pass(p_chmod("submod2/README.txt", GIT_FILEMODE_BLOB_EXECUTABLE)); + + cl_git_pass(git_index_add(g_idx, &new_entry)); + cl_git_pass(git_index_write(g_idx)); + + cl_git_rewritefile("submod2/README.txt", "Modified but still executable"); + + cl_git_pass(git_index_add_bypath(g_idx, "README.txt")); + cl_git_pass(git_index_write(g_idx)); + + cl_assert((entry = git_index_get_bypath(g_idx, "README.txt", 0)) != NULL); + cl_assert_equal_i(GIT_FILEMODE_BLOB_EXECUTABLE, entry->mode); +} |