Code

rev-list documentation: clarify the two parts of history simplification
[git.git] / builtin-revert.c
index 84865397405d96aa4fdbfca801e8ecd47e3dea36..7483a7a63bf09a7a123e442e9b933b9d24f2b1a6 100644 (file)
@@ -251,7 +251,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
        int i, index_fd, clean;
        char *oneline, *reencoded_message = NULL;
        const char *message, *encoding;
-       const char *defmsg = xstrdup(git_path("MERGE_MSG"));
+       char *defmsg = xstrdup(git_path("MERGE_MSG"));
        struct merge_options o;
        struct tree *result, *next_tree, *base_tree, *head_tree;
        static struct lock_file index_lock;
@@ -329,7 +329,8 @@ static int revert_or_cherry_pick(int argc, const char **argv)
         * reverse of it if we are revert.
         */
 
-       msg_fd = hold_lock_file_for_update(&msg_file, defmsg, 1);
+       msg_fd = hold_lock_file_for_update(&msg_file, defmsg,
+                                          LOCK_DIE_ON_ERROR);
 
        encoding = get_encoding(message);
        if (!encoding)
@@ -431,6 +432,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
                return execv_git_cmd(args);
        }
        free(reencoded_message);
+       free(defmsg);
 
        return 0;
 }