@@ -44,10 +44,6 @@ fn run_with_repo(logger: &slog::Logger, config: &Config, repo: &git2::Repository
44
44
config. force_detach ,
45
45
logger,
46
46
) ?;
47
- if stack. is_empty ( ) {
48
- crit ! ( logger, "No commits available to fix up, exiting" ) ;
49
- return Ok ( ( ) ) ;
50
- }
51
47
52
48
let autostage_enabled = config:: auto_stage_if_nothing_staged ( repo) ;
53
49
let index_was_empty = nothing_left_in_index ( repo) ?;
@@ -374,7 +370,14 @@ fn run_with_repo(logger: &slog::Logger, config: &Config, repo: &git2::Repository
374
370
--base to increase the search range."
375
371
)
376
372
}
377
- } else if config. and_rebase {
373
+ }
374
+
375
+ if stack. is_empty ( ) {
376
+ crit ! ( logger, "No commits available to fix up, exiting" ) ;
377
+ return Ok ( ( ) ) ;
378
+ }
379
+
380
+ if config. and_rebase && patches_considered != 0 {
378
381
use std:: process:: Command ;
379
382
// unwrap() is safe here, as we exit early if the stack is empty
380
383
let last_commit_in_stack = & stack. last ( ) . unwrap ( ) . 0 ;
@@ -777,6 +780,16 @@ mod tests {
777
780
"level" : "WARN" ,
778
781
"msg" : "Please try a different --base" ,
779
782
} ) ,
783
+ & json!( {
784
+ "level" : "WARN" ,
785
+ "msg" : "Could not find a commit to fix up, \
786
+ use --base to increase the search range.",
787
+ } ) ,
788
+ & json!( {
789
+ "level" : "WARN" ,
790
+ "msg" : "Could not find a commit to fix up, \
791
+ use --base to increase the search range.",
792
+ } ) ,
780
793
& json!( {
781
794
"level" : "CRIT" ,
782
795
"msg" : "No commits available to fix up, exiting" ,
@@ -812,6 +825,16 @@ mod tests {
812
825
"level" : "WARN" ,
813
826
"msg" : "Will not fix up past the merge commit" ,
814
827
} ) ,
828
+ & json!( {
829
+ "level" : "WARN" ,
830
+ "msg" : "Could not find a commit to fix up, \
831
+ use --base to increase the search range.",
832
+ } ) ,
833
+ & json!( {
834
+ "level" : "WARN" ,
835
+ "msg" : "Could not find a commit to fix up, \
836
+ use --base to increase the search range.",
837
+ } ) ,
815
838
& json!( {
816
839
"level" : "CRIT" ,
817
840
"msg" : "No commits available to fix up, exiting" ,
@@ -1031,7 +1054,17 @@ mod tests {
1031
1054
& json!( {
1032
1055
"level" : "WARN" ,
1033
1056
"msg" : "Will not fix up past commits not authored by you, \
1034
- use --force-author to override"
1057
+ use --force-author to override",
1058
+ } ) ,
1059
+ & json!( {
1060
+ "level" : "WARN" ,
1061
+ "msg" : "Could not find a commit to fix up, \
1062
+ use --base to increase the search range.",
1063
+ } ) ,
1064
+ & json!( {
1065
+ "level" : "WARN" ,
1066
+ "msg" : "Could not find a commit to fix up, \
1067
+ use --base to increase the search range.",
1035
1068
} ) ,
1036
1069
& json!( { "level" : "CRIT" , "msg" : "No commits available to fix up, exiting" } ) ,
1037
1070
] ,
@@ -1140,7 +1173,20 @@ mod tests {
1140
1173
"level" : "WARN" ,
1141
1174
"msg" : "HEAD is not a branch, but --force-detach used to continue." ,
1142
1175
} ) ,
1143
- & json!( { "level" : "WARN" , "msg" : "Please use --base to specify a base commit." } ) ,
1176
+ & json!( {
1177
+ "level" : "WARN" ,
1178
+ "msg" : "Please use --base to specify a base commit." ,
1179
+ } ) ,
1180
+ & json!( {
1181
+ "level" : "WARN" ,
1182
+ "msg" : "Could not find a commit to fix up, \
1183
+ use --base to increase the search range.",
1184
+ } ) ,
1185
+ & json!( {
1186
+ "level" : "WARN" ,
1187
+ "msg" : "Could not find a commit to fix up, \
1188
+ use --base to increase the search range.",
1189
+ } ) ,
1144
1190
& json!( { "level" : "CRIT" , "msg" : "No commits available to fix up, exiting" } ) ,
1145
1191
] ,
1146
1192
) ;
0 commit comments