int git_futils_mv_withpath(const char *from, const char *to) { if (git_futils_mkpath2file(to) < GIT_SUCCESS) return GIT_EOSERR; /* The callee already takes care of setting the correct error message. */ return git_futils_mv_atomic(from, to); /* The callee already takes care of setting the correct error message. */ }
/** * Initializer * * This method is called once before starting each * test, and will load the required fixtures */ void test_status_worktree__initialize(void) { /* * Sandbox the `status/` repository from our Fixtures. * This will copy the whole folder to our sandbox, * so now it can be accessed with `./status` */ cl_fixture_sandbox("status"); /* * Rename `status/.gitted` to `status/.git` * We do this because we cannot store a folder named `.git` * inside the fixtures folder in our libgit2 repo. */ cl_git_pass( git_futils_mv_atomic("status/.gitted", "status/.git") ); /* * Open the sandboxed "status" repository */ cl_git_pass(git_repository_open(&_repository, "status/.git")); }
GIT_STATUS_WT_DELETED, GIT_STATUS_WT_DELETED, GIT_STATUS_WT_DELETED, }; #define ENTRY_COUNT3 22 BEGIN_TEST(statuscb3, "test retrieving status for a worktree where a file and a subdir have been renamed and some files have been added") git_repository *repo; struct status_entry_counts counts; must_pass(copydir_recurs(STATUS_WORKDIR_FOLDER, TEMP_REPO_FOLDER)); must_pass(git_futils_mv_atomic(STATUS_REPOSITORY_TEMP_FOLDER, TEST_STD_REPO_FOLDER)); must_pass(git_repository_open(&repo, TEST_STD_REPO_FOLDER)); must_pass(git_futils_mv_atomic(TEMP_REPO_FOLDER "current_file", TEMP_REPO_FOLDER "swap")); must_pass(git_futils_mv_atomic(TEMP_REPO_FOLDER "subdir", TEMP_REPO_FOLDER "current_file")); must_pass(git_futils_mv_atomic(TEMP_REPO_FOLDER "swap", TEMP_REPO_FOLDER "subdir")); must_pass(file_create(TEMP_REPO_FOLDER ".HEADER", "dummy")); must_pass(file_create(TEMP_REPO_FOLDER "42-is-not-prime.sigh", "dummy")); must_pass(file_create(TEMP_REPO_FOLDER "README.md", "dummy")); memset(&counts, 0x0, sizeof(struct status_entry_counts)); counts.expected_entry_count = ENTRY_COUNT3; counts.expected_paths = entry_paths3; counts.expected_statuses = entry_statuses3; must_pass(git_status_foreach(repo, status_cb, &counts)); must_be_true(counts.entry_count == counts.expected_entry_count); must_be_true(counts.wrong_status_flags_count == 0);