Code

difftool: put the cursor on the editable file for Vim
[git.git] / builtin-commit.c
index 93ca49635731942c72cb52b27b1a6ba53becd1ca..2f0b00a174ff970939d2758334cb8d1dca41cb42 100644 (file)
@@ -225,18 +225,18 @@ static char *prepare_index(int argc, const char **argv, const char *prefix)
 
        if (interactive) {
                interactive_add(argc, argv, prefix);
-               if (read_cache() < 0)
+               if (read_cache_preload(NULL) < 0)
                        die("index file corrupt");
                commit_style = COMMIT_AS_IS;
                return get_index_file();
        }
 
-       if (read_cache() < 0)
-               die("index file corrupt");
-
        if (*argv)
                pathspec = get_pathspec(prefix, argv);
 
+       if (read_cache_preload(pathspec) < 0)
+               die("index file corrupt");
+
        /*
         * Non partial, non as-is commit.
         *
@@ -624,7 +624,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 +638,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; the index is unmerged?");
+               error("Error building trees");
                return 0;
        }
 
@@ -866,6 +865,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)
        if (wt_status_use_color == -1)
                wt_status_use_color = git_use_color_default;
 
+       if (diff_use_color_default == -1)
+               diff_use_color_default = git_use_color_default;
+
        argc = parse_and_validate_options(argc, argv, builtin_status_usage, prefix);
 
        index_file = prepare_index(argc, argv, prefix);
@@ -932,11 +934,6 @@ static int git_commit_config(const char *k, const char *v, void *cb)
        return git_status_config(k, v, cb);
 }
 
-static const char commit_utf8_warn[] =
-"Warning: commit message does not conform to UTF-8.\n"
-"You may want to amend it after fixing the message, or set the config\n"
-"variable i18n.commitencoding to the encoding your project uses.\n";
-
 int cmd_commit(int argc, const char **argv, const char *prefix)
 {
        struct strbuf sb = STRBUF_INIT;
@@ -950,6 +947,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 
        git_config(git_commit_config, NULL);
 
+       if (wt_status_use_color == -1)
+               wt_status_use_color = git_use_color_default;
+
        argc = parse_and_validate_options(argc, argv, builtin_commit_usage, prefix);
 
        index_file = prepare_index(argc, argv, prefix);
@@ -1015,9 +1015,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);