X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=builtin%2Fcommit.c;h=a78dbd83bf04c7080487b8508321d79d848e9b1f;hb=23cbf11b5c08c6d0ab0fd0d6f2dc5a32ca31c745;hp=c101f006f6b5d7d185aa97081fb9717de92b09cd;hpb=c255a70b5ef4e70070b6076c4308da9d163d56a9;p=git.git diff --git a/builtin/commit.c b/builtin/commit.c index c101f006f..a78dbd83b 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -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;