File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -194,10 +194,17 @@ int git_revwalk_push_range(git_revwalk *walk, const char *range)
194194 if ((error = git_revparse (& revspec , walk -> repo , range )))
195195 return error ;
196196
197+ if (!revspec .to ) {
198+ git_error_set (GIT_ERROR_INVALID , "invalid revspec: range not provided" );
199+ error = GIT_EINVALIDSPEC ;
200+ goto out ;
201+ }
202+
197203 if (revspec .flags & GIT_REVPARSE_MERGE_BASE ) {
198204 /* TODO: support "<commit>...<commit>" */
199205 git_error_set (GIT_ERROR_INVALID , "symmetric differences not implemented in revwalk" );
200- return GIT_EINVALIDSPEC ;
206+ error = GIT_EINVALIDSPEC ;
207+ goto out ;
201208 }
202209
203210 if ((error = push_commit (walk , git_object_id (revspec .from ), 1 , false)))
Original file line number Diff line number Diff line change @@ -400,6 +400,24 @@ void test_revwalk_basic__push_range(void)
400400 cl_git_pass (test_walk_only (_walk , commit_sorting_segment , 2 ));
401401}
402402
403+ void test_revwalk_basic__push_range_merge_base (void )
404+ {
405+ revwalk_basic_setup_walk (NULL );
406+
407+ git_revwalk_reset (_walk );
408+ git_revwalk_sorting (_walk , 0 );
409+ cl_git_fail_with (GIT_EINVALIDSPEC , git_revwalk_push_range (_walk , "HEAD...HEAD~2" ));
410+ }
411+
412+ void test_revwalk_basic__push_range_no_range (void )
413+ {
414+ revwalk_basic_setup_walk (NULL );
415+
416+ git_revwalk_reset (_walk );
417+ git_revwalk_sorting (_walk , 0 );
418+ cl_git_fail_with (GIT_EINVALIDSPEC , git_revwalk_push_range (_walk , "HEAD" ));
419+ }
420+
403421void test_revwalk_basic__push_mixed (void )
404422{
405423 git_oid oid ;
You can’t perform that action at this time.
0 commit comments