mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-07 10:31:01 +00:00
Add test for blob/tree name collisions in index
This commit is contained in:
parent
66af84494c
commit
95fbedcd8e
42
tests/index/collision.c
Normal file
42
tests/index/collision.c
Normal file
@ -0,0 +1,42 @@
|
||||
#include "clar_libgit2.h"
|
||||
#include "git2/repository.h"
|
||||
#include "git2/index.h"
|
||||
|
||||
git_repository *repo = NULL;
|
||||
|
||||
void test_index_collision__cleanup(void)
|
||||
{
|
||||
cl_git_sandbox_cleanup();
|
||||
repo = NULL;
|
||||
}
|
||||
|
||||
void test_index_collision__add(void)
|
||||
{
|
||||
git_index *index;
|
||||
git_index_entry entry;
|
||||
git_oid tree_id;
|
||||
git_tree *tree;
|
||||
|
||||
repo = cl_git_sandbox_init("empty_standard_repo");
|
||||
cl_git_pass(git_repository_index(&index, repo));
|
||||
|
||||
memset(&entry, 0, sizeof(entry));
|
||||
entry.ctime.seconds = 12346789;
|
||||
entry.mtime.seconds = 12346789;
|
||||
entry.mode = 0100644;
|
||||
entry.file_size = 0;
|
||||
git_oid_fromstr(&entry.id, "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391");
|
||||
|
||||
entry.path = "a/b";
|
||||
cl_git_pass(git_index_add(index, &entry));
|
||||
|
||||
/* create a tree/blob collision */
|
||||
entry.path = "a/b/c";
|
||||
cl_git_fail(git_index_add(index, &entry));
|
||||
|
||||
cl_git_pass(git_index_write_tree(&tree_id, index));
|
||||
cl_git_pass(git_tree_lookup(&tree, repo, &tree_id));
|
||||
|
||||
git_tree_free(tree);
|
||||
git_index_free(index);
|
||||
}
|
Loading…
Reference in New Issue
Block a user