@@ -2693,19 +2693,13 @@ static int read_populate_todo(struct repository *r,
2693
2693
struct todo_list * todo_list ,
2694
2694
struct replay_opts * opts )
2695
2695
{
2696
- struct stat st ;
2697
2696
const char * todo_file = get_todo_path (opts );
2698
2697
int res ;
2699
2698
2700
2699
strbuf_reset (& todo_list -> buf );
2701
2700
if (strbuf_read_file_or_whine (& todo_list -> buf , todo_file ) < 0 )
2702
2701
return -1 ;
2703
2702
2704
- res = stat (todo_file , & st );
2705
- if (res )
2706
- return error (_ ("could not stat '%s'" ), todo_file );
2707
- fill_stat_data (& todo_list -> stat , & st );
2708
-
2709
2703
res = todo_list_parse_insn_buffer (r , todo_list -> buf .buf , todo_list );
2710
2704
if (res ) {
2711
2705
if (is_rebase_i (opts ))
@@ -4284,6 +4278,30 @@ static int stopped_at_head(struct repository *r)
4284
4278
4285
4279
}
4286
4280
4281
+ static int reread_todo_if_changed (struct repository * r ,
4282
+ struct todo_list * todo_list ,
4283
+ struct replay_opts * opts )
4284
+ {
4285
+ int offset ;
4286
+ struct strbuf buf = STRBUF_INIT ;
4287
+
4288
+ if (strbuf_read_file_or_whine (& buf , get_todo_path (opts )) < 0 )
4289
+ return -1 ;
4290
+ offset = get_item_line_offset (todo_list , todo_list -> current + 1 );
4291
+ if (buf .len != todo_list -> buf .len - offset ||
4292
+ memcmp (buf .buf , todo_list -> buf .buf + offset , buf .len )) {
4293
+ /* Reread the todo file if it has changed. */
4294
+ todo_list_release (todo_list );
4295
+ if (read_populate_todo (r , todo_list , opts ))
4296
+ return -1 ; /* message was printed */
4297
+ /* `current` will be incremented on return */
4298
+ todo_list -> current = -1 ;
4299
+ }
4300
+ strbuf_release (& buf );
4301
+
4302
+ return 0 ;
4303
+ }
4304
+
4287
4305
static const char rescheduled_advice [] =
4288
4306
N_ ("Could not execute the todo command\n"
4289
4307
"\n"
@@ -4462,20 +4480,9 @@ static int pick_commits(struct repository *r,
4462
4480
item -> commit ,
4463
4481
arg , item -> arg_len ,
4464
4482
opts , res , 0 );
4465
- } else if (is_rebase_i (opts ) && check_todo && !res ) {
4466
- struct stat st ;
4467
-
4468
- if (stat (get_todo_path (opts ), & st )) {
4469
- res = error_errno (_ ("could not stat '%s'" ),
4470
- get_todo_path (opts ));
4471
- } else if (match_stat_data (& todo_list -> stat , & st )) {
4472
- /* Reread the todo file if it has changed. */
4473
- todo_list_release (todo_list );
4474
- if (read_populate_todo (r , todo_list , opts ))
4475
- res = -1 ; /* message was printed */
4476
- /* `current` will be incremented below */
4477
- todo_list -> current = -1 ;
4478
- }
4483
+ } else if (is_rebase_i (opts ) && check_todo && !res &&
4484
+ reread_todo_if_changed (r , todo_list , opts )) {
4485
+ return -1 ;
4479
4486
}
4480
4487
4481
4488
todo_list -> current ++ ;
0 commit comments