File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,16 @@ pub struct CommitRange<'a> {
4646}
4747
4848impl < ' a > CommitRange < ' a > {
49+ /// Create an empty CommitRange with no commits in its iterator.
50+ pub fn empty ( repo : & ' a Repository ) -> Self {
51+ Self {
52+ repo,
53+ start_oid : String :: new ( ) ,
54+ end_oid : String :: new ( ) ,
55+ refname : String :: new ( ) ,
56+ }
57+ }
58+
4959 #[ allow( dead_code) ]
5060 pub fn new (
5161 repo : & ' a Repository ,
@@ -221,6 +231,15 @@ impl<'a> IntoIterator for CommitRange<'a> {
221231 type IntoIter = CommitRangeIterator < ' a > ;
222232
223233 fn into_iter ( self ) -> Self :: IntoIter {
234+ // Empty range - return empty iterator
235+ if self . start_oid . is_empty ( ) && self . end_oid . is_empty ( ) {
236+ return CommitRangeIterator {
237+ repo : self . repo ,
238+ commit_oids : Vec :: new ( ) ,
239+ index : 0 ,
240+ } ;
241+ }
242+
224243 // ie for single commit branches
225244 if self . start_oid == self . end_oid {
226245 return CommitRangeIterator {
You can’t perform that action at this time.
0 commit comments