Commit f3a199dd by Edward Thomson

rebase: init and open take a rebase_options

`git_rebase_init` and `git_rebase_open` should take a
`git_rebase_options` and use it for future rebase operations on
that `rebase` object.
parent 5ae38538
......@@ -108,6 +108,14 @@ v0.22 + 1
if it is called immediately after creating a rebase session but before
you have applied the first patch.
* `git_rebase_options` now contains an optional pointer to
`git_checkout_options` that will be used for functions that modify
the working directory, namely `git_checkout_init`, `git_checkout_next`
and `git_checkout_abort`. As a result, `git_rebase_open` now also
takes a `git_rebase_options` and only the `git_rebase_init` and
`git_rebase_open` functions take a `git_rebase_options`, where they
will persist the options to subsequent `git_rebase` calls.
v0.22
------
......
......@@ -30,19 +30,32 @@ typedef struct {
unsigned int version;
/**
* Provide a quiet rebase experience; unused by libgit2 but provided for
* interoperability with other clients.
* Used by `git_rebase_init`, this will instruct other clients working
* on this rebase that you want a quiet rebase experience, which they
* may choose to provide in an application-specific manner. This has no
* effect upon libgit2 directly, but is provided for interoperability with
* other clients.
*/
int quiet;
/**
* Canonical name of the notes reference used to rewrite notes for
* rebased commits when finishing the rebase; if NULL, the contents of
* the coniguration option `notes.rewriteRef` is examined, unless the
* configuration option `notes.rewrite.rebase` is set to false. If
* `notes.rewriteRef` is NULL, notes will not be rewritten.
* Used by `git_rebase_finish`, this is the canonical name of the notes
* reference used to rewrite notes for rebased commits when finishing the
* rebase; if NULL, the contents of the coniguration option
* `notes.rewriteRef` is examined, unless the configuration option
* `notes.rewrite.rebase` is set to false. If `notes.rewriteRef` is also
* NULL, notes will not be rewritten.
*/
const char *rewrite_notes_ref;
/**
* Options to control how files are written during `git_rebase_init`,
* `git_checkout_next` and `git_checkout_abort`. Note that a minimum
* strategy of `GIT_CHECKOUT_SAFE` is defaulted in `init` and `next`,
* and a minimum strategy of `GIT_CHECKOUT_FORCE` is defaulted in
* `abort` to match git semantics.
*/
git_checkout_options *checkout_options;
} git_rebase_options;
/**
......@@ -142,9 +155,7 @@ GIT_EXTERN(int) git_rebase_init_options(
* reachable commits
* @param onto The branch to rebase onto, or NULL to rebase onto the given
* upstream
* @param opts Options to specify how rebase is performed
* @param checkout_opts Options to specify how the checkout to the `onto`
* branch is performed
* @param opts Options to specify how rebase is performed, or NULL
* @return Zero on success; -1 on failure.
*/
GIT_EXTERN(int) git_rebase_init(
......@@ -153,8 +164,7 @@ GIT_EXTERN(int) git_rebase_init(
const git_annotated_commit *branch,
const git_annotated_commit *upstream,
const git_annotated_commit *onto,
const git_rebase_options *opts,
const git_checkout_options *checkout_opts);
const git_rebase_options *opts);
/**
* Opens an existing rebase that was previously started by either an
......@@ -162,9 +172,13 @@ GIT_EXTERN(int) git_rebase_init(
*
* @param out Pointer to store the rebase object
* @param repo The repository that has a rebase in-progress
* @param opts Options to specify how rebase is performed
* @return Zero on success; -1 on failure.
*/
GIT_EXTERN(int) git_rebase_open(git_rebase **out, git_repository *repo);
GIT_EXTERN(int) git_rebase_open(
git_rebase **out,
git_repository *repo,
const git_rebase_options *opts);
/**
* Gets the count of rebase operations that are to be applied.
......@@ -205,13 +219,11 @@ GIT_EXTERN(git_rebase_operation *) git_rebase_operation_byindex(
*
* @param operation Pointer to store the rebase operation that is to be performed next
* @param rebase The rebase in progress
* @param checkout_opts Options to specify how the patch should be checked out
* @return Zero on success; -1 on failure.
*/
GIT_EXTERN(int) git_rebase_next(
git_rebase_operation **operation,
git_rebase *rebase,
git_checkout_options *checkout_opts);
git_rebase *rebase);
/**
* Commits the current patch. You must have resolved any conflicts that
......@@ -248,14 +260,10 @@ GIT_EXTERN(int) git_rebase_commit(
* and working directory to their state before rebase began.
*
* @param rebase The rebase that is in-progress
* @param checkout_opts The checkout options that will be used to influence a
* hard reset of the working directory.
* @return Zero on success; GIT_ENOTFOUND if a rebase is not in progress,
* -1 on other errors.
*/
GIT_EXTERN(int) git_rebase_abort(
git_rebase *rebase,
const git_checkout_options *checkout_opts);
GIT_EXTERN(int) git_rebase_abort(git_rebase *rebase);
/**
* Finishes a rebase that is currently in progress once all patches have
......@@ -263,13 +271,11 @@ GIT_EXTERN(int) git_rebase_abort(
*
* @param rebase The rebase that is in-progress
* @param signature The identity that is finishing the rebase (optional)
* @param opts Options to specify how rebase is finished
* @return Zero on success; -1 on error
*/
GIT_EXTERN(int) git_rebase_finish(
git_rebase *rebase,
const git_signature *signature,
const git_rebase_options *opts);
const git_signature *signature);
/**
* Frees the `git_rebase` object.
......
......@@ -27,8 +27,8 @@ static void test_abort(git_annotated_commit *branch, git_annotated_commit *onto)
git_reflog *reflog;
const git_reflog_entry *reflog_entry;
cl_git_pass(git_rebase_open(&rebase, repo));
cl_git_pass(git_rebase_abort(rebase, NULL));
cl_git_pass(git_rebase_open(&rebase, repo, NULL));
cl_git_pass(git_rebase_abort(rebase));
cl_assert_equal_i(GIT_REPOSITORY_STATE_NONE, git_repository_state(repo));
......@@ -73,7 +73,7 @@ void test_rebase_abort__merge(void)
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_annotated_commit_from_ref(&onto_head, repo, onto_ref));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, NULL, onto_head, NULL, NULL));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, NULL, onto_head, NULL));
cl_assert_equal_i(GIT_REPOSITORY_STATE_REBASE_MERGE, git_repository_state(repo));
test_abort(branch_head, onto_head);
......@@ -102,7 +102,7 @@ void test_rebase_abort__detached_head(void)
cl_git_pass(git_signature_new(&signature, "Rebaser", "rebaser@example.com", 1404157834, -400));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, NULL, onto_head, NULL, NULL));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, NULL, onto_head, NULL));
cl_assert_equal_i(GIT_REPOSITORY_STATE_REBASE_MERGE, git_repository_state(repo));
test_abort(branch_head, onto_head);
......@@ -131,7 +131,7 @@ void test_rebase_abort__old_style_head_file(void)
cl_git_pass(git_signature_new(&signature, "Rebaser", "rebaser@example.com", 1404157834, -400));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, NULL, onto_head, NULL, NULL));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, NULL, onto_head, NULL));
cl_assert_equal_i(GIT_REPOSITORY_STATE_REBASE_MERGE, git_repository_state(repo));
p_rename("rebase-merge/.git/rebase-merge/orig-head",
......
......@@ -52,52 +52,49 @@ void test_rebase_iterator__iterates(void)
git_reference *branch_ref, *upstream_ref;
git_annotated_commit *branch_head, *upstream_head;
git_rebase_operation *rebase_operation;
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
git_oid commit_id;
int error;
checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
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, NULL));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, NULL));
test_operations(rebase, GIT_REBASE_NO_OPERATION);
git_rebase_free(rebase);
cl_git_pass(git_rebase_open(&rebase, repo));
cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
cl_git_pass(git_rebase_open(&rebase, repo, NULL));
cl_git_pass(git_rebase_next(&rebase_operation, rebase));
cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
NULL, NULL));
test_operations(rebase, 0);
cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
cl_git_pass(git_rebase_next(&rebase_operation, rebase));
cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
NULL, NULL));
test_operations(rebase, 1);
cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
cl_git_pass(git_rebase_next(&rebase_operation, rebase));
cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
NULL, NULL));
test_operations(rebase, 2);
git_rebase_free(rebase);
cl_git_pass(git_rebase_open(&rebase, repo));
cl_git_pass(git_rebase_open(&rebase, repo, NULL));
cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
cl_git_pass(git_rebase_next(&rebase_operation, rebase));
cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
NULL, NULL));
test_operations(rebase, 3);
cl_git_pass(git_rebase_next(&rebase_operation, rebase, &checkout_opts));
cl_git_pass(git_rebase_next(&rebase_operation, rebase));
cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
NULL, NULL));
test_operations(rebase, 4);
cl_git_fail(error = git_rebase_next(&rebase_operation, rebase, &checkout_opts));
cl_git_fail(error = git_rebase_next(&rebase_operation, rebase));
cl_assert_equal_i(GIT_ITEROVER, error);
test_operations(rebase, 4);
......
......@@ -39,12 +39,12 @@ void test_rebase_setup__blocked_when_in_progress(void)
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, NULL));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, NULL));
git_rebase_free(rebase);
cl_assert_equal_i(GIT_REPOSITORY_STATE_REBASE_MERGE, git_repository_state(repo));
cl_git_fail(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, NULL, NULL));
cl_git_fail(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, NULL));
git_annotated_commit_free(branch_head);
git_annotated_commit_free(upstream_head);
......@@ -70,7 +70,7 @@ void test_rebase_setup__merge(void)
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, NULL));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, NULL));
cl_assert_equal_i(GIT_REPOSITORY_STATE_REBASE_MERGE, git_repository_state(repo));
......@@ -118,7 +118,7 @@ void test_rebase_setup__merge_root(void)
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_annotated_commit_from_ref(&onto_head, repo, onto_ref));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, NULL, onto_head, NULL, NULL));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, NULL, onto_head, NULL));
git_oid_fromstr(&head_id, "efad0b11c47cb2f0220cbd6f5b0f93bb99064b00");
cl_git_pass(git_repository_head(&head, repo));
......@@ -168,7 +168,7 @@ void test_rebase_setup__merge_onto_and_upstream(void)
cl_git_pass(git_annotated_commit_from_ref(&branch2_head, repo, branch2_ref));
cl_git_pass(git_annotated_commit_from_ref(&onto_head, repo, onto_ref));
cl_git_pass(git_rebase_init(&rebase, repo, branch1_head, branch2_head, onto_head, NULL, NULL));
cl_git_pass(git_rebase_init(&rebase, repo, branch1_head, branch2_head, onto_head, NULL));
git_oid_fromstr(&head_id, "efad0b11c47cb2f0220cbd6f5b0f93bb99064b00");
cl_git_pass(git_repository_head(&head, repo));
......@@ -215,7 +215,7 @@ void test_rebase_setup__branch_with_merges(void)
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, NULL));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, NULL));
cl_assert_equal_i(GIT_REPOSITORY_STATE_REBASE_MERGE, git_repository_state(repo));
......@@ -263,7 +263,7 @@ void test_rebase_setup__orphan_branch(void)
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, NULL));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, NULL));
cl_assert_equal_i(GIT_REPOSITORY_STATE_REBASE_MERGE, git_repository_state(repo));
......@@ -314,7 +314,7 @@ void test_rebase_setup__merge_null_branch_uses_HEAD(void)
cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_rebase_init(&rebase, repo, NULL, upstream_head, NULL, NULL, NULL));
cl_git_pass(git_rebase_init(&rebase, repo, NULL, upstream_head, NULL, NULL));
cl_assert_equal_i(GIT_REPOSITORY_STATE_REBASE_MERGE, git_repository_state(repo));
......@@ -358,7 +358,7 @@ static int rebase_is_blocked(void)
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));
error = git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, NULL, NULL);
error = git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, NULL);
git_annotated_commit_free(branch_head);
git_annotated_commit_free(upstream_head);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment