From eaf0d68830cc8fc56c92733a550ea5f6bc15101d Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Tue, 17 Mar 2015 17:53:07 -0400 Subject: rebase: block rebase_commit with unstaged changes --- tests/rebase/merge.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'tests/rebase') diff --git a/tests/rebase/merge.c b/tests/rebase/merge.c index e9390567e..02c39609e 100644 --- a/tests/rebase/merge.c +++ b/tests/rebase/merge.c @@ -264,6 +264,41 @@ void test_rebase_merge__commit(void) git_rebase_free(rebase); } +void test_rebase_merge__blocked_when_dirty(void) +{ + git_rebase *rebase; + git_reference *branch_ref, *upstream_ref; + git_annotated_commit *branch_head, *upstream_head; + git_rebase_operation *rebase_operation; + git_oid commit_id; + + cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef")); + cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master")); + + cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref)); + cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref)); + + cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, NULL)); + + /* Allow untracked files */ + cl_git_pass(git_rebase_next(&rebase_operation, rebase)); + cl_git_mkfile("rebase/untracked_file.txt", "This is untracked\n"); + cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature, + NULL, NULL)); + + /* Do not allow unstaged */ + cl_git_pass(git_rebase_next(&rebase_operation, rebase)); + cl_git_mkfile("rebase/veal.txt", "This is an unstaged change\n"); + cl_git_fail_with(GIT_EUNMERGED, git_rebase_commit(&commit_id, rebase, NULL, signature, + NULL, NULL)); + + git_annotated_commit_free(branch_head); + git_annotated_commit_free(upstream_head); + git_reference_free(branch_ref); + git_reference_free(upstream_ref); + git_rebase_free(rebase); +} + void test_rebase_merge__commit_updates_rewritten(void) { git_rebase *rebase; -- cgit v1.2.3