diff options
author | Marvin Gülker <marvin.guelker@asquera.de> | 2012-12-06 16:12:21 +0100 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-01-04 15:23:47 -0800 |
commit | d0951175d49ffff929b4ed1e08d45509360c3f13 (patch) | |
tree | 8cb73dec8cc9a405db8175393148c96801ac8402 | |
parent | 6fee906c982d001062968b4caee4f289f0c86b59 (diff) | |
download | libgit2-d0951175d49ffff929b4ed1e08d45509360c3f13.tar.gz |
Add failing test to demonstrate wrong checkout behaviour
-rw-r--r-- | tests-clar/checkout/tree.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests-clar/checkout/tree.c b/tests-clar/checkout/tree.c index 88dbe4ffc..90f215fc1 100644 --- a/tests-clar/checkout/tree.c +++ b/tests-clar/checkout/tree.c @@ -85,3 +85,23 @@ void test_checkout_tree__calls_progress_callback(void) cl_assert_equal_i(was_called, true); } + +void test_checkout_tree__doesnt_write_unrequested_files_to_worktree(void) +{ + git_oid master_oid; + git_oid chomped_oid; + git_commit* p_master_commit; + git_commit* p_chomped_commit; + git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT; + + git_oid_fromstr(&master_oid, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); + git_oid_fromstr(&chomped_oid, "e90810b8df3e80c413d903f631643c716887138d"); + cl_git_pass(git_commit_lookup(&p_master_commit, g_repo, &master_oid)); + cl_git_pass(git_commit_lookup(&p_chomped_commit, g_repo, &chomped_oid)); + + /* A GIT_CHECKOUT_DEFAULT checkout is not allowed to add any file to the + * working tree from the index as it is supposed to be a dry run. */ + opts.checkout_strategy = GIT_CHECKOUT_DEFAULT; + git_checkout_tree(g_repo, (git_object*)p_chomped_commit, &opts); + cl_assert_equal_i(false, git_path_isfile("testrepo/readme.txt")); +} |