git/rev_list_scanner: add --date-order

This commit is contained in:
Taylor Blau 2017-05-24 16:38:08 -06:00
parent 1411026b7b
commit b1c5fe3547
2 changed files with 15 additions and 0 deletions

@ -37,6 +37,9 @@ const (
// results as given by git-rev-list(1) without any `--<t>-order`
// argument given. By default: reverse chronological order.
DefaultRevListOrder RevListOrder = iota
// DateRevListOrder gives the revisions such that no parents are shown
// before children, and otherwise in commit timestamp order.
DateRevListOrder
)
// ScanRefsOptions is an "options" type that is used to configure a scan
@ -183,6 +186,11 @@ func revListArgs(l, r string, opt *ScanRefsOptions) (io.Reader, []string, error)
var stdin io.Reader
args := []string{"rev-list", "--objects"}
switch opt.Order {
case DateRevListOrder:
args = append(args, "--date-order")
}
switch opt.Mode {
case ScanRefsMode:
if opt.SkipDeletedBlobs {

@ -107,6 +107,13 @@ func TestRevListArgs(t *testing.T) {
},
ExpectedErr: "unknown scan type: -1",
},
"scan date order": {
Left: "left", Right: "right", Opt: &ScanRefsOptions{
Mode: ScanRefsMode,
Order: DateRevListOrder,
},
ExpectedArgs: []string{"rev-list", "--objects", "--date-order", "--do-walk", "left", "right", "--"},
},
} {
t.Run(desc, c.Assert)
}