Merge branch 'pr/5061'
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
diff --git a/src/revwalk.c b/src/revwalk.c
index 6d12d34..935bd4d 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -194,10 +194,17 @@ int git_revwalk_push_range(git_revwalk *walk, const char *range)
if ((error = git_revparse(&revspec, walk->repo, range)))
return error;
+ if (!revspec.to) {
+ git_error_set(GIT_ERROR_INVALID, "invalid revspec: range not provided");
+ error = GIT_EINVALIDSPEC;
+ goto out;
+ }
+
if (revspec.flags & GIT_REVPARSE_MERGE_BASE) {
/* TODO: support "<commit>...<commit>" */
git_error_set(GIT_ERROR_INVALID, "symmetric differences not implemented in revwalk");
- return GIT_EINVALIDSPEC;
+ error = GIT_EINVALIDSPEC;
+ goto out;
}
if ((error = push_commit(walk, git_object_id(revspec.from), 1, false)))
diff --git a/tests/revwalk/basic.c b/tests/revwalk/basic.c
index 8e73025..ee70ec6 100644
--- a/tests/revwalk/basic.c
+++ b/tests/revwalk/basic.c
@@ -400,6 +400,24 @@ void test_revwalk_basic__push_range(void)
cl_git_pass(test_walk_only(_walk, commit_sorting_segment, 2));
}
+void test_revwalk_basic__push_range_merge_base(void)
+{
+ revwalk_basic_setup_walk(NULL);
+
+ git_revwalk_reset(_walk);
+ git_revwalk_sorting(_walk, 0);
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_revwalk_push_range(_walk, "HEAD...HEAD~2"));
+}
+
+void test_revwalk_basic__push_range_no_range(void)
+{
+ revwalk_basic_setup_walk(NULL);
+
+ git_revwalk_reset(_walk);
+ git_revwalk_sorting(_walk, 0);
+ cl_git_fail_with(GIT_EINVALIDSPEC, git_revwalk_push_range(_walk, "HEAD"));
+}
+
void test_revwalk_basic__push_mixed(void)
{
git_oid oid;