summaryrefslogtreecommitdiff
path: root/tests/checkout/tree.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2014-01-22 13:24:32 -0500
committerEdward Thomson <ethomson@microsoft.com>2014-01-22 13:26:30 -0500
commite8b81c698c52a7197c0842b6503e8b980d773c74 (patch)
tree53a1d3d414bc798e9a8b40e081be93fb8036a99b /tests/checkout/tree.c
parentec088fec9dc65621275b9f16d746820af67592de (diff)
downloadlibgit2-e8b81c698c52a7197c0842b6503e8b980d773c74.tar.gz
Preserve tree filemode in index during checkout
Don't try to determine whether the system supports file modes when putting the tree data in the index during checkout. The tree's mode is canonical and did not come from stat(2) in the first place.
Diffstat (limited to 'tests/checkout/tree.c')
-rw-r--r--tests/checkout/tree.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/checkout/tree.c b/tests/checkout/tree.c
index f0699fdb7..047c9ed98 100644
--- a/tests/checkout/tree.c
+++ b/tests/checkout/tree.c
@@ -925,3 +925,26 @@ void test_checkout_tree__fails_when_conflicts_exist_in_index(void)
git_object_free(obj);
}
+
+void test_checkout_tree__filemode_preserved_in_index(void)
+{
+ git_oid executable_oid;
+ git_commit *commit;
+ git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT;
+ git_index *index;
+ const git_index_entry *entry;
+
+ cl_git_pass(git_repository_index(&index, g_repo));
+
+ cl_git_pass(git_oid_fromstr(&executable_oid, "afe4393b2b2a965f06acf2ca9658eaa01e0cd6b6"));
+ cl_git_pass(git_commit_lookup(&commit, g_repo, &executable_oid));
+
+ opts.checkout_strategy = GIT_CHECKOUT_FORCE;
+
+ cl_git_pass(git_checkout_tree(g_repo, (const git_object *)commit, &opts));
+ cl_assert(entry = git_index_get_bypath(index, "executable.txt", 0));
+ cl_assert_equal_i(0100755, entry->mode);
+
+ git_commit_free(commit);
+ git_index_free(index);
+}