aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-07-15 12:06:55 -0700
committerJunio C Hamano <gitster@pobox.com>2010-07-15 12:06:55 -0700
commitbff6e86b3d01febaa2d73ff4e890f091999e9e28 (patch)
treed93b87fe04a84c47d399ad7b89d66952d6e277fc /builtin
parent754e66b7a0bec277c319a4d6105024d210f47066 (diff)
parentd5f5d0a9443c3892cdf9665ed8e0f9004706ed65 (diff)
downloadgit-bff6e86b3d01febaa2d73ff4e890f091999e9e28.tar.gz
git-bff6e86b3d01febaa2d73ff4e890f091999e9e28.tar.xz
Merge branch 'jk/maint-status-keep-index-timestamp'
* jk/maint-status-keep-index-timestamp: do not write out index when status does not have to
Diffstat (limited to 'builtin')
-rw-r--r--builtin/commit.c16
1 files changed, 11 insertions, 5 deletions
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;