8000 checkout tests: nasty symlinks · libgit2/libgit2@43ddf51 · GitHub
[go: up one dir, main page]

Skip to content

Commit 43ddf51

Browse files
ethomsonEdward Thomson
authored andcommitted
checkout tests: nasty symlinks
Symbolic links that abuse case insensitivity to write into .git.
1 parent 8d97f70 commit 43ddf51

18 files changed

+50
-3
lines changed

tests/checkout/nasty.c

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,29 @@ void test_checkout_nasty__cleanup(void)
2323
cl_git_sandbox_cleanup();
2424
}
2525

26-
void test_checkout_fails(const char *refname, const char *filename)
26+
static void test_checkout_passes(const char *refname, const char *filename)
27+
{
28+
git_oid commit_id;
29+
git_commit *commit;
30+
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
31+
git_buf path = GIT_BUF_INIT;
32+
33+
cl_git_pass(git_buf_joinpath(&path, repo_name, filename));
34+
35+
cl_git_pass(git_reference_name_to_id(&commit_id, repo, refname));
36+
cl_git_pass(git_commit_lookup(&commit, repo, &commit_id));
37+
38+
opts.checkout_strategy = GIT_CHECKOUT_FORCE |
39+
GIT_CHECKOUT_DONT_UPDATE_INDEX;
40+
41+
cl_git_pass(git_checkout_tree(repo, (const git_object *)commit, &opts));
42+
cl_assert(!git_path_exists(path.ptr));
43+
44+
git_commit_free(commit);
45+
git_buf_free(&path);
46+
}
47+
48+
static void test_checkout_fails(const char *refname, const char *filename)
2749
{
2850
git_oid commit_id;
2951
git_commit *commit;
@@ -323,3 +345,19 @@ void test_checkout_nasty__honors_core_protectntfs(void)
323345
test_checkout_fails("refs/heads/dot_git_dot", ".git/foobar");
324346
test_checkout_fails("refs/heads/git_tilde1", ".git/foobar");
325347
}
348+
349+
void test_checkout_nasty__symlink1(void)
350+
{
351+
test_checkout_passes("refs/heads/symlink1", ".git/foobar");
352+
}
353+
354+
void test_checkout_nasty__symlink2(void)
355+
{
356+
test_checkout_passes("refs/heads/symlink2", ".git/foobar");
357+
}
358+
359+
void test_checkout_nasty__symlink3(void)
360+
{
361+
test_checkout_passes("refs/heads/symlink3", ".git/foobar");
362+
}
363+
Binary file not shown.
Binary file not shown.

tests/resources/nasty/.gitted/objects/1b/31d55e0c53efbea6c670ece9057b76b5822eea

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
x��K
2+
1D]�}���D�x/�O� NH"2�wo��=��5�e�@}�L<%�AD�̄V�I:%Ir�IDP��s̵�-�|Kp�k���v�IW��_;Ś/��@�-WGT�l����?gX�}lз�DX��`oԙD�
Binary file not shown.
Binary file not shown.

tests/resources/nasty/.gitted/objects/9d/5898503adc01d763e279ac8fcefbe865b19031

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
x�O[� ��S�4 R
2+
Ic��z
3+
۴�tb��K�7�k^�L&pJS%qS2�T�=5�1vo�4�5�t���z��u��QF�p�O�#\FNw^����H��v���V�����QT����F�ߩ�y
4+
0O��u�y�$>��F�
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)
0