@@ -264,14 +264,15 @@ func (repo *Repository) FilesCountBetween(startCommitID, endCommitID string) (in
264264 return len (strings .Split (stdout , "\n " )) - 1 , nil
265265}
266266
267- // CommitsBetween returns a list that contains commits between [last, before).
267+ // CommitsBetween returns a list that contains commits between [before, last).
268+ // If before is detached (removed by reset + push) it is not included.
268269func (repo * Repository ) CommitsBetween (last * Commit , before * Commit ) (* list.List , error ) {
269270 var stdout []byte
270271 var err error
271272 if before == nil {
272273 stdout , err = NewCommand ("rev-list" , last .ID .String ()).RunInDirBytes (repo .Path )
273274 } else {
274- stdout , err = NewCommand ("rev-list" , before .ID .String ()+ "... " + last .ID .String ()).RunInDirBytes (repo .Path )
275+ stdout , err = NewCommand ("rev-list" , before .ID .String ()+ ".." + last .ID .String ()).RunInDirBytes (repo .Path )
275276 if err != nil && strings .Contains (err .Error (), "no merge base" ) {
276277 // future versions of git >= 2.28 are likely to return an error if before and last have become unrelated.
277278 // previously it would return the results of git rev-list before last so let's try that...
@@ -284,14 +285,14 @@ func (repo *Repository) CommitsBetween(last *Commit, before *Commit) (*list.List
284285 return repo .parsePrettyFormatLogToList (bytes .TrimSpace (stdout ))
285286}
286287
287- // CommitsBetweenLimit returns a list that contains at most limit commits skipping the first skip commits between [last, before )
288+ // CommitsBetweenLimit returns a list that contains at most limit commits skipping the first skip commits between [before, last )
288289func (repo * Repository ) CommitsBetweenLimit (last * Commit , before * Commit , limit , skip int ) (* list.List , error ) {
289290 var stdout []byte
290291 var err error
291292 if before == nil {
292293 stdout , err = NewCommand ("rev-list" , "--max-count" , strconv .Itoa (limit ), "--skip" , strconv .Itoa (skip ), last .ID .String ()).RunInDirBytes (repo .Path )
293294 } else {
294- stdout , err = NewCommand ("rev-list" , "--max-count" , strconv .Itoa (limit ), "--skip" , strconv .Itoa (skip ), before .ID .String ()+ "... " + last .ID .String ()).RunInDirBytes (repo .Path )
295+ stdout , err = NewCommand ("rev-list" , "--max-count" , strconv .Itoa (limit ), "--skip" , strconv .Itoa (skip ), before .ID .String ()+ ".." + last .ID .String ()).RunInDirBytes (repo .Path )
295296 if err != nil && strings .Contains (err .Error (), "no merge base" ) {
296297 // future versions of git >= 2.28 are likely to return an error if before and last have become unrelated.
297298 // previously it would return the results of git rev-list --max-count n before last so let's try that...
@@ -322,7 +323,7 @@ func (repo *Repository) CommitsBetweenIDs(last, before string) (*list.List, erro
322323
323324// CommitsCountBetween return numbers of commits between two commits
324325func (repo * Repository ) CommitsCountBetween (start , end string ) (int64 , error ) {
325- count , err := CommitsCountFiles (repo .Path , []string {start + "... " + end }, []string {})
326+ count , err := CommitsCountFiles (repo .Path , []string {start + ".." + end }, []string {})
326327 if err != nil && strings .Contains (err .Error (), "no merge base" ) {
327328 // future versions of git >= 2.28 are likely to return an error if before and last have become unrelated.
328329 // previously it would return the results of git rev-list before last so let's try that...
0 commit comments