diff options
author | Edward Thomson <ethomson@microsoft.com> | 2015-11-03 19:27:31 +0300 |
---|---|---|
committer | Edward Thomson <ethomson@microsoft.com> | 2015-11-03 20:07:03 +0300 |
commit | 6cc5023bfdb5eea30728aadce92612e01834415f (patch) | |
tree | 5b8b932bf3acd12c96303135005e575380f6e48a /tests/index | |
parent | 6b0fc6abc159c6f15f49bf5ab40b1152d8c6165f (diff) |
index: test that add_bypath preserves symlinks
Test that on platforms without `core.symlinks`, we preserve symlinks
in `git_index_add_bypath`. (Users should correct the actual index
entry's mode to change a link to a regular file.)
Diffstat (limited to 'tests/index')
-rw-r--r-- | tests/index/bypath.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/index/bypath.c b/tests/index/bypath.c index 0c10cfe4c..88a76178a 100644 --- a/tests/index/bypath.c +++ b/tests/index/bypath.c @@ -328,3 +328,32 @@ void test_index_bypath__add_honors_conflict_case(void) cl_assert((entry = git_index_get_bypath(g_idx, "README.txt", 0)) != NULL); cl_assert_equal_i(GIT_FILEMODE_BLOB_EXECUTABLE, entry->mode); } + +void test_index_bypath__add_honors_symlink(void) +{ + const git_index_entry *entry; + git_index_entry new_entry; + int symlinks; + + cl_git_pass(git_repository__cvar(&symlinks, g_repo, GIT_CVAR_SYMLINKS)); + + if (symlinks) + cl_skip(); + + 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_LINK; + + 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 a (fake) symlink"); + + 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_LINK, entry->mode); +} |