summaryrefslogtreecommitdiffstats
path: root/builtin-commit.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-01-20 02:10:35 +0100
committerJunio C Hamano <gitster@pobox.com>2010-01-20 02:10:35 +0100
commitab6854515ee2280f187fbc2ab08f9e9115438f3e (patch)
treed1bcf567557cb622bde89663fe3f386bcf2e911f /builtin-commit.c
parentbisect: fix singular/plural grammar nit (diff)
downloadgit-ab6854515ee2280f187fbc2ab08f9e9115438f3e.tar.xz
git-ab6854515ee2280f187fbc2ab08f9e9115438f3e.zip
status: don't require the repository to be writable
We need to update the index before hooks run when actually making a commit, but we shouldn't have to write the index when running "status". If we can, then we have already spent cycles to refresh the index and it is a waste not to write it out, but it is not a disaster if we cannot write it out. The main reason the user is running "git status" is to get the "status", and refreshing the index is a mere side effect that we can do without. Discovery and initial attempted fix by Dscho. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to '')
-rw-r--r--builtin-commit.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/builtin-commit.c b/builtin-commit.c
index 33aa593c21..83b7c353ed 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -278,11 +278,13 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
* We still need to refresh the index here.
*/
if (!pathspec || !*pathspec) {
- fd = hold_locked_index(&index_lock, 1);
+ fd = hold_locked_index(&index_lock, !is_status);
refresh_cache(refresh_flags);
- if (write_cache(fd, active_cache, active_nr) ||
- commit_locked_index(&index_lock))
- die("unable to write new_index file");
+ if (0 <= fd) {
+ if (write_cache(fd, active_cache, active_nr) ||
+ commit_locked_index(&index_lock))
+ die("unable to write new_index file");
+ }
commit_style = COMMIT_AS_IS;
return get_index_file();
}