Commit 232bc895 by Edward Thomson Committed by Edward Thomson

checkout tests: nasty symlinks

Symbolic links that abuse case insensitivity to write into .git.
parent b4cbd67f
......@@ -23,7 +23,29 @@ void test_checkout_nasty__cleanup(void)
cl_git_sandbox_cleanup();
}
void test_checkout_fails(const char *refname, const char *filename)
static void test_checkout_passes(const char *refname, const char *filename)
{
git_oid commit_id;
git_commit *commit;
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
git_buf path = GIT_BUF_INIT;
cl_git_pass(git_buf_joinpath(&path, repo_name, filename));
cl_git_pass(git_reference_name_to_id(&commit_id, repo, refname));
cl_git_pass(git_commit_lookup(&commit, repo, &commit_id));
opts.checkout_strategy = GIT_CHECKOUT_FORCE |
GIT_CHECKOUT_DONT_UPDATE_INDEX;
cl_git_pass(git_checkout_tree(repo, (const git_object *)commit, &opts));
cl_assert(!git_path_exists(path.ptr));
git_commit_free(commit);
git_buf_free(&path);
}
static void test_checkout_fails(const char *refname, const char *filename)
{
git_oid commit_id;
git_commit *commit;
......@@ -323,3 +345,19 @@ void test_checkout_nasty__honors_core_protectntfs(void)
test_checkout_fails("refs/heads/dot_git_dot", ".git/foobar");
test_checkout_fails("refs/heads/git_tilde1", ".git/foobar");
}
void test_checkout_nasty__symlink1(void)
{
test_checkout_passes("refs/heads/symlink1", ".git/foobar");
}
void test_checkout_nasty__symlink2(void)
{
test_checkout_passes("refs/heads/symlink2", ".git/foobar");
}
void test_checkout_nasty__symlink3(void)
{
test_checkout_passes("refs/heads/symlink3", ".git/foobar");
}
4d83272d0d372e1232ddc4ff3260d76fdfa2015a
9d5898503adc01d763e279ac8fcefbe865b19031
cf6fcf8cdf7e8d4cda3b11b0ba02d0d5125fbbd7
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment