Skip to content

Commit

Permalink
checkout tests: nasty symlinks
Browse files Browse the repository at this point in the history
Symbolic links that abuse case insensitivity to write into .git.
  • Loading branch information
ethomson committed Jan 16, 2015
1 parent 629a579 commit dd3c53f
Show file tree
Hide file tree
Showing 18 changed files with 50 additions and 3 deletions.
40 changes: 39 additions & 1 deletion tests/checkout/nasty.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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.

This file was deleted.

@@ -0,0 +1,2 @@
x��K
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.
@@ -0,0 +1,4 @@
x�O[� ��S�4 R
Ic��z
۴�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
0O��u�y�$>��F�
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,2 @@
x��]
�0�}�)�J�m���� ����`ӕQooo���70�x�9@%7e%k�h0���QAG�i�5�F�^����+�î��/0R�u�o�s;�y�E��ö������Bֈ�+;���9-��u���oG�
Expand Down
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions tests/resources/nasty/.gitted/refs/heads/symlink1
@@ -0,0 +1 @@
4d83272d0d372e1232ddc4ff3260d76fdfa2015a
1 change: 1 addition & 0 deletions tests/resources/nasty/.gitted/refs/heads/symlink2
@@ -0,0 +1 @@
9d5898503adc01d763e279ac8fcefbe865b19031
1 change: 1 addition & 0 deletions tests/resources/nasty/.gitted/refs/heads/symlink3
@@ -0,0 +1 @@
cf6fcf8cdf7e8d4cda3b11b0ba02d0d5125fbbd7

0 comments on commit dd3c53f

Please sign in to comment.