Merge branch 'maint-1.5.6' into maint-1.6.0
[git.git] / builtin-commit.c
index 649c8beb3e716dd5797787ced61d2fee23b7140f..fde7b891d9d015acfeb1ee3b9ab42ff1eafd49b6 100644 (file)
@@ -224,7 +224,8 @@ static char *prepare_index(int argc, const char **argv, const char *prefix)
        const char **pathspec = NULL;
 
        if (interactive) {
-               interactive_add(argc, argv, prefix);
+               if (interactive_add(argc, argv, prefix) != 0)
+                       die("interactive add failed");
                if (read_cache() < 0)
                        die("index file corrupt");
                commit_style = COMMIT_AS_IS;
@@ -320,7 +321,8 @@ static char *prepare_index(int argc, const char **argv, const char *prefix)
                die("unable to write new_index file");
 
        fd = hold_lock_file_for_update(&false_lock,
-                                      git_path("next-index-%d", getpid()), 1);
+                                      git_path("next-index-%d", getpid()),
+                                      LOCK_DIE_ON_ERROR);
 
        create_base_index();
        add_remove_files(&partial);
@@ -624,7 +626,6 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
        if (!commitable && !in_merge && !allow_empty &&
            !(amend && is_a_merge(head_sha1))) {
                run_status(stdout, index_file, prefix, 0);
-               unlink(commit_editmsg);
                return 0;
        }
 
@@ -639,7 +640,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
                active_cache_tree = cache_tree();
        if (cache_tree_update(active_cache_tree,
                              active_cache, active_nr, 0, 0) < 0) {
-               error("Error building trees");
+               error("Error building trees; the index is unmerged?");
                return 0;
        }
 
@@ -882,7 +883,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
 
        if (!log_tree_commit(&rev, commit)) {
                struct strbuf buf = STRBUF_INIT;
-               format_commit_message(commit, "%h: %s", &buf);
+               format_commit_message(commit, "%h: %s", &buf, DATE_NORMAL);
                printf("%s\n", buf.buf);
                strbuf_release(&buf);
        }
@@ -1003,9 +1004,11 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
        }
 
        /* Truncate the message just before the diff, if any. */
-       p = strstr(sb.buf, "\ndiff --git a/");
-       if (p != NULL)
-               strbuf_setlen(&sb, p - sb.buf + 1);
+       if (verbose) {
+               p = strstr(sb.buf, "\ndiff --git ");
+               if (p != NULL)
+                       strbuf_setlen(&sb, p - sb.buf + 1);
+       }
 
        if (cleanup_mode != CLEANUP_NONE)
                stripspace(&sb, cleanup_mode == CLEANUP_ALL);