Skip to content

Commit

Permalink
sequencer: lib'ify checkout_fast_forward()
Browse files Browse the repository at this point in the history
Instead of dying there, let the caller high up in the callchain
notice the error and handle it (by dying, still).

The only callers of checkout_fast_forward(), cmd_merge(),
pull_into_void(), cmd_pull() and sequencer's fast_forward_to(),
already check the return value and handle it appropriately. With this
step, we make it notice an error return from this function.

So this is a safe conversion to make checkout_fast_forward()
callable from new callers that want it not to die, without changing
the external behaviour of anything existing.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
dscho committed Oct 29, 2016
1 parent fb7c5a7 commit 039115c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions merge.c
Expand Up @@ -57,7 +57,8 @@ int checkout_fast_forward(const unsigned char *head,

refresh_cache(REFRESH_QUIET);

hold_locked_index(lock_file, 1);
if (hold_locked_index(lock_file, 0) < 0)
return -1;

memset(&trees, 0, sizeof(trees));
memset(&opts, 0, sizeof(opts));
Expand Down Expand Up @@ -90,7 +91,9 @@ int checkout_fast_forward(const unsigned char *head,
}
if (unpack_trees(nr_trees, t, &opts))
return -1;
if (write_locked_index(&the_index, lock_file, COMMIT_LOCK))
die(_("unable to write new index file"));
if (write_locked_index(&the_index, lock_file, COMMIT_LOCK)) {
rollback_lock_file(lock_file);
return error(_("unable to write new index file"));
}
return 0;
}

0 comments on commit 039115c

Please sign in to comment.