Skip to content

Commit 2a4062a

Browse files
committed
Merge branch 'js/sequencer-wo-die'
Lifts calls to exit(2) and die() higher in the callchain in sequencer.c files so that more helper functions in it can be used by callers that want to handle error conditions themselves. * js/sequencer-wo-die: sequencer: ensure to release the lock when we could not read the index sequencer: lib'ify checkout_fast_forward() sequencer: lib'ify fast_forward_to() sequencer: lib'ify save_opts() sequencer: lib'ify save_todo() sequencer: lib'ify save_head() sequencer: lib'ify create_seq_dir() sequencer: lib'ify read_populate_opts() sequencer: lib'ify read_populate_todo() sequencer: lib'ify read_and_refresh_cache() sequencer: lib'ify prepare_revs() sequencer: lib'ify walk_revs_populate_todo() sequencer: lib'ify do_pick_commit() sequencer: lib'ify do_recursive_merge() sequencer: lib'ify write_message() sequencer: do not die() in do_pick_commit() sequencer: lib'ify sequencer_pick_revisions()
2 parents a0d9b7f + 49fb937 commit 2a4062a

File tree

2 files changed

+131
-75
lines changed

2 files changed

+131
-75
lines changed

merge.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ int checkout_fast_forward(const unsigned char *head,
5757

5858
refresh_cache(REFRESH_QUIET);
5959

60-
hold_locked_index(lock_file, 1);
60+
if (hold_locked_index(lock_file, 0) < 0)
61+
return -1;
6162

6263
memset(&trees, 0, sizeof(trees));
6364
memset(&opts, 0, sizeof(opts));
@@ -90,7 +91,9 @@ int checkout_fast_forward(const unsigned char *head,
9091
}
9192
if (unpack_trees(nr_trees, t, &opts))
9293
return -1;
93-
if (write_locked_index(&the_index, lock_file, COMMIT_LOCK))
94-
die(_("unable to write new index file"));
94+
if (write_locked_index(&the_index, lock_file, COMMIT_LOCK)) {
95+
rollback_lock_file(lock_file);
96+
return error(_("unable to write new index file"));
97+
}
9598
return 0;
9699
}

0 commit comments

Comments
 (0)