Log returns the commit history from the given LogOptions.
(o *LogOptions)
| 1246 | |
| 1247 | // Log returns the commit history from the given LogOptions. |
| 1248 | func (r *Repository) Log(o *LogOptions) (object.CommitIter, error) { |
| 1249 | fn := commitIterFunc(o.Order) |
| 1250 | if fn == nil { |
| 1251 | return nil, fmt.Errorf("invalid Order=%v", o.Order) |
| 1252 | } |
| 1253 | |
| 1254 | var ( |
| 1255 | it object.CommitIter |
| 1256 | err error |
| 1257 | ) |
| 1258 | if o.All { |
| 1259 | it, err = r.logAll(fn) |
| 1260 | } else { |
| 1261 | it, err = r.log(o.From, fn) |
| 1262 | } |
| 1263 | |
| 1264 | if err != nil { |
| 1265 | return nil, err |
| 1266 | } |
| 1267 | |
| 1268 | if o.FileName != nil { |
| 1269 | // for `git log --all` also check parent (if the next commit comes from the real parent) |
| 1270 | it = r.logWithFile(*o.FileName, it, o.All) |
| 1271 | } |
| 1272 | if o.PathFilter != nil { |
| 1273 | it = r.logWithPathFilter(o.PathFilter, it, o.All) |
| 1274 | } |
| 1275 | |
| 1276 | if o.Since != nil || o.Until != nil { |
| 1277 | limitOptions := object.LogLimitOptions{Since: o.Since, Until: o.Until} |
| 1278 | it = r.logWithLimit(it, limitOptions) |
| 1279 | } |
| 1280 | |
| 1281 | return it, nil |
| 1282 | } |
| 1283 | |
| 1284 | func (r *Repository) log(from plumbing.Hash, commitIterFunc func(*object.Commit) object.CommitIter) (object.CommitIter, error) { |
| 1285 | h := from |