@@ -1200,6 +1200,7 @@ struct todo_list {
1200
1200
struct todo_item * items ;
1201
1201
int nr , alloc , current ;
1202
1202
int done_nr , total_nr ;
1203
+ struct stat_data stat ;
1203
1204
};
1204
1205
1205
1206
#define TODO_LIST_INIT { STRBUF_INIT }
@@ -1330,6 +1331,7 @@ static int count_commands(struct todo_list *todo_list)
1330
1331
static int read_populate_todo (struct todo_list * todo_list ,
1331
1332
struct replay_opts * opts )
1332
1333
{
1334
+ struct stat st ;
1333
1335
const char * todo_file = get_todo_path (opts );
1334
1336
int fd , res ;
1335
1337
@@ -1343,6 +1345,11 @@ static int read_populate_todo(struct todo_list *todo_list,
1343
1345
}
1344
1346
close (fd );
1345
1347
1348
+ res = stat (todo_file , & st );
1349
+ if (res )
1350
+ return error (_ ("could not stat '%s'" ), todo_file );
1351
+ fill_stat_data (& todo_list -> stat , & st );
1352
+
1346
1353
res = parse_insn_buffer (todo_list -> buf .buf , todo_list );
1347
1354
if (res ) {
1348
1355
if (is_rebase_i (opts ))
@@ -2028,10 +2035,25 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
2028
2035
} else if (item -> command == TODO_EXEC ) {
2029
2036
char * end_of_arg = (char * )(item -> arg + item -> arg_len );
2030
2037
int saved = * end_of_arg ;
2038
+ struct stat st ;
2031
2039
2032
2040
* end_of_arg = '\0' ;
2033
2041
res = do_exec (item -> arg );
2034
2042
* end_of_arg = saved ;
2043
+
2044
+ /* Reread the todo file if it has changed. */
2045
+ if (res )
2046
+ ; /* fall through */
2047
+ else if (stat (get_todo_path (opts ), & st ))
2048
+ res = error_errno (_ ("could not stat '%s'" ),
2049
+ get_todo_path (opts ));
2050
+ else if (match_stat_data (& todo_list -> stat , & st )) {
2051
+ todo_list_release (todo_list );
2052
+ if (read_populate_todo (todo_list , opts ))
2053
+ res = -1 ; /* message was printed */
2054
+ /* `current` will be incremented below */
2055
+ todo_list -> current = -1 ;
2056
+ }
2035
2057
} else if (!is_noop (item -> command ))
2036
2058
return error (_ ("unknown command %d" ), item -> command );
2037
2059
0 commit comments