Imported Upstream version 2.12.1
[platform/upstream/git.git] / merge.c
diff --git a/merge.c b/merge.c
index 74ced7f..04ee5fc 100644 (file)
--- a/merge.c
+++ b/merge.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "lockfile.h"
 #include "commit.h"
 #include "run-command.h"
 #include "resolve-undo.h"
@@ -9,7 +10,7 @@
 static const char *merge_argument(struct commit *commit)
 {
        if (commit)
-               return sha1_to_hex(commit->object.sha1);
+               return oid_to_hex(&commit->object.oid);
        else
                return EMPTY_TREE_SHA1_HEX;
 }
@@ -56,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));
@@ -89,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;
 }