mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-05 20:33:41 +00:00
checkout tests: nasty symlinks
Symbolic links that abuse case insensitivity to write into .git.
This commit is contained in:
parent
b4cbd67f5f
commit
232bc89598
@ -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");
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
tests/resources/nasty/.gitted/refs/heads/symlink1
Normal file
BIN
tests/resources/nasty/.gitted/refs/heads/symlink1
Normal file
Binary file not shown.
BIN
tests/resources/nasty/.gitted/refs/heads/symlink2
Normal file
BIN
tests/resources/nasty/.gitted/refs/heads/symlink2
Normal file
Binary file not shown.
BIN
tests/resources/nasty/.gitted/refs/heads/symlink3
Normal file
BIN
tests/resources/nasty/.gitted/refs/heads/symlink3
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user