diff options
| author | Russell Belfer <rb@github.com> | 2013-01-03 16:56:27 -0800 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2013-01-04 15:47:44 -0800 |
| commit | 817d625161f212b86c22733f7dde2f2155a65ac5 (patch) | |
| tree | 8a0c00a4048b371635b95324928bf70a867ed97b /tests-clar/checkout/index.c | |
| parent | 7fc00435829d24021a477c6d6413f3d7b3e37e27 (diff) | |
| download | libgit2-817d625161f212b86c22733f7dde2f2155a65ac5.tar.gz | |
Fix checkout of index-only dirs and prefixed paths
There are a couple of checkout bugs fixed here. One is with
untracked working directory entries that are prefixes of tree
entries but not in a meaningful way (i.e. "read" is a prefix of
"readme.txt" but doesn't interfere in any way). The second bug
is actually a redo of 07edfa0fc640f85f95507c3101e77accd7d2bf0d
where directory entries in the index that are not in the diff
were not being removed correctly. That fix remedied one case
but broke another.
Diffstat (limited to 'tests-clar/checkout/index.c')
| -rw-r--r-- | tests-clar/checkout/index.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests-clar/checkout/index.c b/tests-clar/checkout/index.c index b1778a422..fe1f6874f 100644 --- a/tests-clar/checkout/index.c +++ b/tests-clar/checkout/index.c @@ -496,3 +496,28 @@ void test_checkout_index__validates_struct_version(void) err = giterr_last(); cl_assert_equal_i(err->klass, GITERR_INVALID); } + +void test_checkout_index__can_update_prefixed_files(void) +{ + git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT; + + cl_git_mkfile("./testrepo/READ", "content\n"); + cl_git_mkfile("./testrepo/README.after", "content\n"); + cl_git_pass(p_mkdir("./testrepo/branch_file", 0777)); + cl_git_pass(p_mkdir("./testrepo/branch_file/contained_dir", 0777)); + cl_git_mkfile("./testrepo/branch_file/contained_file", "content\n"); + cl_git_pass(p_mkdir("./testrepo/branch_file.txt.after", 0777)); + + opts.checkout_strategy = GIT_CHECKOUT_FORCE | GIT_CHECKOUT_REMOVE_UNTRACKED; + + cl_git_pass(git_checkout_index(g_repo, NULL, &opts)); + + test_file_contents("./testrepo/README", "hey there\n"); + test_file_contents("./testrepo/branch_file.txt", "hi\nbye!\n"); + test_file_contents("./testrepo/new.txt", "my new file\n"); + + cl_assert(!git_path_exists("testrepo/READ")); + cl_assert(!git_path_exists("testrepo/README.after")); + cl_assert(!git_path_exists("testrepo/branch_file")); + cl_assert(!git_path_exists("testrepo/branch_file.txt.after")); +} |
