コード例 #1
0
ファイル: drop.c プロジェクト: 0CV0/libgit2
static void push_three_states(void)
{
	git_oid oid;
	git_index *index;

	cl_git_mkfile("stash/zero.txt", "content\n");
	cl_git_pass(git_repository_index(&index, repo));
	cl_git_pass(git_index_add_bypath(index, "zero.txt"));
	commit_staged_files(&oid, index, signature);
	cl_assert(git_path_exists("stash/zero.txt"));

	cl_git_mkfile("stash/one.txt", "content\n");
	cl_git_pass(git_stash_save(&oid, repo, signature, "First", GIT_STASH_INCLUDE_UNTRACKED));
	cl_assert(!git_path_exists("stash/one.txt"));
	cl_assert(git_path_exists("stash/zero.txt"));

	cl_git_mkfile("stash/two.txt", "content\n");
	cl_git_pass(git_stash_save(&oid, repo, signature, "Second", GIT_STASH_INCLUDE_UNTRACKED));
	cl_assert(!git_path_exists("stash/two.txt"));
	cl_assert(git_path_exists("stash/zero.txt"));

	cl_git_mkfile("stash/three.txt", "content\n");
	cl_git_pass(git_stash_save(&oid, repo, signature, "Third", GIT_STASH_INCLUDE_UNTRACKED));
	cl_assert(!git_path_exists("stash/three.txt"));
	cl_assert(git_path_exists("stash/zero.txt"));

	git_index_free(index);
}
コード例 #2
0
ファイル: save.c プロジェクト: ralpheav/PM_GIT
void test_stash_save__cannot_stash_when_there_are_no_local_change(void)
{
	git_index *index;
	git_oid commit_oid, stash_tip_oid;

	cl_git_pass(git_repository_index(&index, repo));

	/*
	 * 'what' and 'who' are being committed.
	 * 'when' remain untracked.
	 */
	cl_git_pass(git_index_add_from_workdir(index, "what"));
	cl_git_pass(git_index_add_from_workdir(index, "who"));
	cl_git_pass(git_index_write(index));
	commit_staged_files(&commit_oid, index, signature);
	git_index_free(index);

	cl_assert_equal_i(GIT_ENOTFOUND,
		git_stash_save(&stash_tip_oid, repo, signature, NULL, GIT_STASH_DEFAULT));

	p_unlink("stash/when");
	cl_assert_equal_i(GIT_ENOTFOUND,
		git_stash_save(&stash_tip_oid, repo, signature, NULL, GIT_STASH_INCLUDE_UNTRACKED));
}