]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/commit.c
diff/status: refactor opportunistic index update
[thirdparty/git.git] / builtin / commit.c
index 2bb30c0e80f8948b28599da06c94c8c66b5733c7..0b6ce2fa3757b0d052ee28d716687a70e1c4ca37 100644 (file)
@@ -25,6 +25,7 @@
 #include "rerere.h"
 #include "unpack-trees.h"
 #include "quote.h"
+#include "submodule.h"
 
 static const char * const builtin_commit_usage[] = {
        "git commit [options] [--] <filepattern>...",
@@ -1073,6 +1074,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
                status_format = STATUS_FORMAT_PORCELAIN;
 
        wt_status_prepare(&s);
+       gitmodules_config();
        git_config(git_status_config, &s);
        in_merge = file_exists(git_path("MERGE_HEAD"));
        argc = parse_options(argc, argv, prefix,
@@ -1088,13 +1090,8 @@ int cmd_status(int argc, const char **argv, const char *prefix)
        refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, s.pathspec, NULL, NULL);
 
        fd = hold_locked_index(&index_lock, 0);
-       if (0 <= fd) {
-               if (active_cache_changed &&
-                   !write_cache(fd, active_cache, active_nr))
-                       commit_locked_index(&index_lock);
-               else
-                       rollback_lock_file(&index_lock);
-       }
+       if (0 <= fd)
+               update_index_if_able(&the_index, &index_lock);
 
        s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;
        s.in_merge = in_merge;
@@ -1163,7 +1160,6 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
        init_revisions(&rev, prefix);
        setup_revisions(0, NULL, &rev, NULL);
 
-       rev.abbrev = 0;
        rev.diff = 1;
        rev.diffopt.output_format =
                DIFF_FORMAT_SHORTSTAT | DIFF_FORMAT_SUMMARY;