rebase -i: move unlink() calls
At the start of each iteration the loop that picks commits removes the state files from the previous pick. However some of these files are only written if there are conflicts in which case we exit the loop before the end of the loop body. Therefore they only need to be removed when the rebase continues, not at the start of each iteration. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood committed
Sep 6, 2023 at 15:22 UTC
36ac861a305720c54f759da814647d5987beb10b
1 file changed
+4
-3
sequencer.c
+4
-3
@@ -4639,6 +4639,10 @@ static int pick_commits(struct repository *r,
4639
if (read_and_refresh_cache(r, opts))
4640
return -1;
4641
4642
+ unlink(rebase_path_message());
4643
+ unlink(rebase_path_stopped_sha());
4644
+ unlink(rebase_path_amend());
4645
+
4646
while (todo_list->current < todo_list->nr) {
4647
struct todo_item *item = todo_list->items + todo_list->current;
4648
const char *arg = todo_item_get_arg(todo_list, item);
@@ -4662,10 +4666,7 @@ static int pick_commits(struct repository *r,
4666
todo_list->total_nr,
4667
opts->verbose ? "\n" : "\r");
4668
}
4665
- unlink(rebase_path_message());
4669
unlink(rebase_path_author_script());
4667
- unlink(rebase_path_stopped_sha());
4668
- unlink(rebase_path_amend());
4670
unlink(git_path_merge_head(r));
4671
unlink(git_path_auto_merge(r));
4672
delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);