summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md4
-rw-r--r--include/git2/rebase.h6
-rw-r--r--src/rebase.c2
-rw-r--r--tests/rebase/iterator.c2
4 files changed, 12 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index be8e92400..69c69912d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
------
diff --git a/include/git2/rebase.h b/include/git2/rebase.h
index 58b66b7fa..3d8d180a5 100644
--- a/include/git2/rebase.h
+++ b/include/git2/rebase.h
@@ -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.
diff --git a/src/rebase.c b/src/rebase.c
index eb25d4c3a..3bc10f4af 100644
--- a/src/rebase.c
+++ b/src/rebase.c
@@ -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)
diff --git a/tests/rebase/iterator.c b/tests/rebase/iterator.c
index 2cff82ced..23272d51c 100644
--- a/tests/rebase/iterator.c
+++ b/tests/rebase/iterator.c
@@ -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));