sha1_file: refactor read_object
[gitweb.git] / merge.c
diff --git a/merge.c b/merge.c
index 5db7d56b90c3413bbd831f90de73d3306e10ce2f..1d441ad94254257ad2ac28b8a17dc0b8e5ce14f9 100644 (file)
--- a/merge.c
+++ b/merge.c
@@ -44,8 +44,8 @@ int try_merge_command(const char *strategy, size_t xopts_nr,
        return ret;
 }
 
-int checkout_fast_forward(const unsigned char *head,
-                         const unsigned char *remote,
+int checkout_fast_forward(const struct object_id *head,
+                         const struct object_id *remote,
                          int overwrite_ignore)
 {
        struct tree *trees[MAX_UNPACK_TREES];
@@ -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, LOCK_REPORT_ON_ERROR) < 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;
 }