]> git.proxmox.com Git - libgit2.git/blobdiff - tests/checkout/head.c
New upstream version 1.1.0+dfsg.1
[libgit2.git] / tests / checkout / head.c
index 99061466f10c87a46343a18b5df59468f238e7f6..5b3a034e77a18cd59ecccb2cb59f5a5dc899681f 100644 (file)
@@ -2,7 +2,7 @@
 #include "refs.h"
 #include "repo/repo_helpers.h"
 #include "path.h"
-#include "fileops.h"
+#include "futils.h"
 
 static git_repository *g_repo;
 
@@ -109,6 +109,32 @@ void test_checkout_head__do_not_remove_untracked_file_in_subdir(void)
        cl_assert(git_path_isfile("testrepo/tracked/subdir/untracked"));
 }
 
+void test_checkout_head__do_remove_untracked_paths(void)
+{
+       git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
+       git_index *index;
+       char *paths[] = {"tracked/untracked"};
+
+       cl_git_pass(p_mkdir("testrepo/tracked", 0755));
+       cl_git_pass(p_mkdir("testrepo/tracked/subdir", 0755));
+       cl_git_mkfile("testrepo/tracked/tracked", "tracked\n");
+       cl_git_mkfile("testrepo/tracked/untracked", "untracked\n");
+
+       cl_git_pass(git_repository_index(&index, g_repo));
+       cl_git_pass(git_index_add_bypath(index, "tracked/tracked"));
+       cl_git_pass(git_index_write(index));
+
+       git_index_free(index);
+
+       opts.checkout_strategy = GIT_CHECKOUT_FORCE | GIT_CHECKOUT_REMOVE_UNTRACKED;
+       opts.paths.strings = paths;
+       opts.paths.count = 1;
+       cl_git_pass(git_checkout_head(g_repo, &opts));
+
+       cl_assert(git_path_isfile("testrepo/tracked/tracked"));
+       cl_assert(!git_path_isfile("testrepo/tracked/untracked"));
+}
+
 void test_checkout_head__do_remove_tracked_subdir(void)
 {
        git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;