summaryrefslogtreecommitdiff
path: root/merge.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2016-09-09 14:38:00 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-09-09 18:24:52 (GMT)
commit55f5704da69d3e6836620f01bee0093ad5e331e8 (patch)
tree188cea6b8a5d07058b7f8949eaf6024e4e5ab476 /merge.c
parent0e408fc347088aa54f97cada3b880afd2560cc94 (diff)
downloadgit-55f5704da69d3e6836620f01bee0093ad5e331e8.zip
git-55f5704da69d3e6836620f01bee0093ad5e331e8.tar.gz
git-55f5704da69d3e6836620f01bee0093ad5e331e8.tar.bz2
sequencer: lib'ify checkout_fast_forward()
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>
Diffstat (limited to 'merge.c')
-rw-r--r--merge.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/merge.c b/merge.c
index 5db7d56..23866c9 100644
--- a/merge.c
+++ b/merge.c
@@ -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));
@@ -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;
}