]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/commit.c
SubmittingPatches: Clarify the Signed-off-by rules
[thirdparty/git.git] / builtin / commit.c
index c101f006f6b5d7d185aa97081fb9717de92b09cd..2bb30c0e80f8948b28599da06c94c8c66b5733c7 100644 (file)
@@ -147,7 +147,7 @@ static struct option builtin_commit_options[] = {
                    "terminate entries with NUL"),
        OPT_BOOLEAN(0, "amend", &amend, "amend previous commit"),
        OPT_BOOLEAN(0, "no-post-rewrite", &no_post_rewrite, "bypass post-rewrite hook"),
-       { OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, "mode", "show untracked files, optional modes: all, normal, no. (Default: all)", PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
+       { OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, "mode", "show untracked files, optional modes: all, normal, no (Default: all)", PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
        /* end commit contents options */
 
        { OPTION_BOOLEAN, 0, "allow-empty", &allow_empty, NULL,
@@ -343,9 +343,13 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
        if (!pathspec || !*pathspec) {
                fd = hold_locked_index(&index_lock, 1);
                refresh_cache_or_die(refresh_flags);
-               if (write_cache(fd, active_cache, active_nr) ||
-                   commit_locked_index(&index_lock))
-                       die("unable to write new_index file");
+               if (active_cache_changed) {
+                       if (write_cache(fd, active_cache, active_nr) ||
+                           commit_locked_index(&index_lock))
+                               die("unable to write new_index file");
+               } else {
+                       rollback_lock_file(&index_lock);
+               }
                commit_style = COMMIT_AS_IS;
                return get_index_file();
        }
@@ -1085,9 +1089,11 @@ int cmd_status(int argc, const char **argv, const char *prefix)
 
        fd = hold_locked_index(&index_lock, 0);
        if (0 <= fd) {
-               if (!write_cache(fd, active_cache, active_nr))
+               if (active_cache_changed &&
+                   !write_cache(fd, active_cache, active_nr))
                        commit_locked_index(&index_lock);
-               rollback_lock_file(&index_lock);
+               else
+                       rollback_lock_file(&index_lock);
        }
 
        s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;