示例#1
0
文件: mixed.c 项目: 1336/libgit2
void test_reset_mixed__reflog_is_correct(void)
{
	git_buf buf = GIT_BUF_INIT;
	git_annotated_commit *annotated;
	const char *exp_msg = "commit: Updating test data so we can test inter-hunk-context";

	reflog_check(repo, "HEAD", 9, "*****@*****.**", exp_msg);
	reflog_check(repo, "refs/heads/master", 9, "*****@*****.**", exp_msg);

	/* Branch not moving, no reflog entry */
	cl_git_pass(git_revparse_single(&target, repo, "HEAD^{commit}"));
	cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED, NULL));
	reflog_check(repo, "HEAD", 9, "*****@*****.**", exp_msg);
	reflog_check(repo, "refs/heads/master", 9, "*****@*****.**", exp_msg);

	git_object_free(target);
	target = NULL;

	/* Moved branch, expect id in message */
	cl_git_pass(git_revparse_single(&target, repo, "HEAD~^{commit}"));
	git_buf_clear(&buf);
	cl_git_pass(git_buf_printf(&buf, "reset: moving to %s", git_oid_tostr_s(git_object_id(target))));
	cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED, NULL));
	reflog_check(repo, "HEAD", 10, NULL, git_buf_cstr(&buf));
	reflog_check(repo, "refs/heads/master", 10, NULL, git_buf_cstr(&buf));
	git_buf_free(&buf);

	/* Moved branch, expect revspec in message */
	exp_msg = "reset: moving to HEAD~^{commit}";
	cl_git_pass(git_annotated_commit_from_revspec(&annotated, repo, "HEAD~^{commit}"));
	cl_git_pass(git_reset_from_annotated(repo, annotated, GIT_RESET_MIXED, NULL));
	reflog_check(repo, "HEAD", 11, NULL, exp_msg);
	reflog_check(repo, "refs/heads/master", 11, NULL, exp_msg);
	git_annotated_commit_free(annotated);
}
示例#2
0
void test_reset_hard__reflog_is_correct(void)
{
	const char *exp_msg = "commit: Add a file which name should appear before the "
		"\"subdir/\" folder while being dealt with by the treewalker";

	reflog_check(repo, "HEAD", 3, "*****@*****.**", exp_msg);
	reflog_check(repo, "refs/heads/master", 3, "*****@*****.**", exp_msg);

	/* Branch not moving, no reflog entry */
	cl_git_pass(git_revparse_single(&target, repo, "HEAD^{commit}"));
	cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL, NULL, NULL));
	reflog_check(repo, "HEAD", 3, "*****@*****.**", exp_msg);
	reflog_check(repo, "refs/heads/master", 3, "*****@*****.**", exp_msg);

	git_object_free(target);

	/* Moved branch, expect default message */
	exp_msg = "reset: moving";
	cl_git_pass(git_revparse_single(&target, repo, "HEAD~^{commit}"));
	cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL, NULL, NULL));
	reflog_check(repo, "HEAD", 4, NULL, exp_msg);
	reflog_check(repo, "refs/heads/master", 4, NULL, exp_msg);

	git_object_free(target);

	/* Moved branch, expect custom message */
	exp_msg = "message1";
	cl_git_pass(git_revparse_single(&target, repo, "HEAD~^{commit}"));
	cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL, NULL, "message1"));
	reflog_check(repo, "HEAD", 5, NULL, exp_msg);
	reflog_check(repo, "refs/heads/master", 5, NULL, exp_msg);
}
示例#3
0
文件: hard.c 项目: jasperla/libgit2
void test_reset_hard__reflog_is_correct(void)
{
    git_buf buf = GIT_BUF_INIT;
    git_annotated_commit *annotated;
    const char *exp_msg = "commit: Add a file which name should appear before the "
                          "\"subdir/\" folder while being dealt with by the treewalker";

    reflog_check(repo, "HEAD", 3, "*****@*****.**", exp_msg);
    reflog_check(repo, "refs/heads/master", 3, "*****@*****.**", exp_msg);

    /* Branch not moving, no reflog entry */
    cl_git_pass(git_revparse_single(&target, repo, "HEAD^{commit}"));
    cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL));
    reflog_check(repo, "HEAD", 3, "*****@*****.**", exp_msg);
    reflog_check(repo, "refs/heads/master", 3, "*****@*****.**", exp_msg);

    git_object_free(target);

    /* Moved branch, expect id in message */
    cl_git_pass(git_revparse_single(&target, repo, "HEAD~^{commit}"));
    cl_git_pass(git_buf_printf(&buf, "reset: moving to %s", git_oid_tostr_s(git_object_id(target))));
    cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL));
    reflog_check(repo, "HEAD", 4, NULL, git_buf_cstr(&buf));
    reflog_check(repo, "refs/heads/master", 4, NULL, git_buf_cstr(&buf));

    git_buf_free(&buf);

    /* Moved branch, expect revspec in message */
    exp_msg = "reset: moving to HEAD~^{commit}";
    cl_git_pass(git_annotated_commit_from_revspec(&annotated, repo, "HEAD~^{commit}"));
    cl_git_pass(git_reset_from_annotated(repo, annotated, GIT_RESET_HARD, NULL));
    reflog_check(repo, "HEAD", 5, NULL, exp_msg);
    reflog_check(repo, "refs/heads/master", 5, NULL, exp_msg);

    git_annotated_commit_free(annotated);

}