Commit 30640aa9 by Edward Thomson

rebase: identify a rebase that has not started

In `git_rebase_operation_current()`, indicate when a rebase has not
started (with `GIT_REBASE_NO_OPERATION`) rather than conflating that
with the first operation being in-progress.
parent 08c45213
......@@ -101,6 +101,10 @@ v0.22 + 1
* `git_note_default_ref()` now uses a `git_buf` to return the string,
as the string is otherwise not guaranteed to stay allocated.
* `git_rebase_operation_current()` will return `GIT_REBASE_NO_OPERATION`
if it is called immediately after creating a rebase session but before
you have applied the first patch.
v0.22
------
......
......@@ -89,6 +89,9 @@ typedef enum {
#define GIT_REBASE_OPTIONS_VERSION 1
#define GIT_REBASE_OPTIONS_INIT {GIT_REBASE_OPTIONS_VERSION}
/** Indicates that a rebase operation is not (yet) in progress. */
#define GIT_REBASE_NO_OPERATION SIZE_MAX
/**
* A rebase operation
*
......@@ -170,6 +173,9 @@ GIT_EXTERN(size_t) git_rebase_operation_entrycount(git_rebase *rebase);
/**
* Gets the index of the rebase operation that is currently being applied.
* If the first operation has not yet been applied (because you have
* called `init` but not yet `next`) then this returns
* `GIT_REBASE_NO_OPERATION`.
*
* @param rebase The in-progress rebase
* @return The index of the rebase operation currently being applied.
......
......@@ -1148,7 +1148,7 @@ size_t git_rebase_operation_current(git_rebase *rebase)
{
assert(rebase);
return rebase->current;
return rebase->started ? rebase->current : GIT_REBASE_NO_OPERATION;
}
git_rebase_operation *git_rebase_operation_byindex(git_rebase *rebase, size_t idx)
......
......@@ -65,7 +65,7 @@ void test_rebase_iterator__iterates(void)
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));
test_operations(rebase, 0);
test_operations(rebase, GIT_REBASE_NO_OPERATION);
git_rebase_free(rebase);
cl_git_pass(git_rebase_open(&rebase, repo));
......
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