@@ -73,6 +73,10 @@ struct RepoStatsOptions {
7373 #[ clap( long, default_value_t = 20 ) ]
7474 top : usize ,
7575
76+ /// Only include first-parent commits.
77+ #[ clap( long, default_value = "false" ) ]
78+ first_parent : bool ,
79+
7680 /// Only include commits authored by these names (repeatable, case-insensitive fuzzy match).
7781 #[ clap( long = "name" , value_name = "NAME" ) ]
7882 names : Vec < String > ,
@@ -85,7 +89,7 @@ struct RepoStatsOptions {
8589
8690#[ derive( Debug , Subcommand ) ]
8791enum RepoSubcommand {
88- /// Analyze first-parent commits by author over time.
92+ /// Analyze commits by author over time.
8993 #[ clap( name = "stats" ) ]
9094 Stats ( RepoStatsOptions ) ,
9195}
@@ -231,11 +235,11 @@ fn repo_stats(options: &RepoStatsOptions) -> Result<(), String> {
231235 let email_filters_lower: Vec < String > =
232236 options. emails . iter ( ) . map ( |s| s. to_lowercase ( ) ) . collect ( ) ;
233237
234- let mut git_args: Vec < String > = vec ! [
235- "log" . to_string ( ) ,
236- "--first-parent" . to_string( ) ,
237- "--pretty=format:%ct%x09%an%x09%ae" . to_string ( ) ,
238- ] ;
238+ let mut git_args: Vec < String > = vec ! [ "log" . to_string ( ) ] ;
239+ if options . first_parent {
240+ git_args . push ( "--first-parent" . to_string ( ) ) ;
241+ }
242+ git_args . push ( "--pretty=format:%ct%x09%an%x09%ae" . to_string ( ) ) ;
239243 if let Some ( start_ts) = range. start_ts {
240244 git_args. push ( format ! ( "--since=@{start_ts}" ) ) ;
241245 }
@@ -339,10 +343,17 @@ fn repo_stats(options: &RepoStatsOptions) -> Result<(), String> {
339343 progress. finish ( ) ;
340344
341345 if totals. is_empty ( ) {
342- println ! (
343- "No first-parent commits found between {} and {}." ,
344- range. start_label, range. end_label
345- ) ;
346+ if options. first_parent {
347+ println ! (
348+ "No first-parent commits found between {} and {}." ,
349+ range. start_label, range. end_label
350+ ) ;
351+ } else {
352+ println ! (
353+ "No commits found between {} and {}." ,
354+ range. start_label, range. end_label
355+ ) ;
356+ }
346357 return Ok ( ( ) ) ;
347358 }
348359
0 commit comments