list.c 1.19 KB
Newer Older
Ben Straub committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#include "clar_libgit2.h"

#include "repository.h"
#include "git2/reflog.h"
#include "reflog.h"

static git_repository *g_repo;



void test_refs_list__initialize(void)
{
   g_repo = cl_git_sandbox_init("testrepo");
}

void test_refs_list__cleanup(void)
{
   cl_git_sandbox_cleanup();
}



void test_refs_list__all(void)
{
   // try to list all the references in our test repo
	git_strarray ref_list;

28
	cl_git_pass(git_reference_list(&ref_list, g_repo));
Ben Straub committed
29 30 31 32 33 34 35

	/*{
		unsigned short i;
		for (i = 0; i < ref_list.count; ++i)
			printf("# %s\n", ref_list.strings[i]);
	}*/

36
	/* We have exactly 12 refs in total if we include the packed ones:
Ben Straub committed
37 38
	 * there is a reference that exists both in the packfile and as
	 * loose, but we only list it once */
39
	cl_assert_equal_i((int)ref_list.count, 14);
Ben Straub committed
40 41 42 43

	git_strarray_free(&ref_list);
}

44 45 46 47 48 49 50 51 52
void test_refs_list__do_not_retrieve_references_which_name_end_with_a_lock_extension(void)
{
	git_strarray ref_list;

	/* Create a fake locked reference */
	cl_git_mkfile(
		"./testrepo/.git/refs/heads/hanwen.lock",
		"144344043ba4d4a405da03de3844aa829ae8be0e\n");

53
	cl_git_pass(git_reference_list(&ref_list, g_repo));
54
	cl_assert_equal_i((int)ref_list.count, 14);
55 56 57

	git_strarray_free(&ref_list);
}