Skip to content

Commit 8f376a5

Browse files
committed
Merge branch 'jc/maint-refresh-index-is-optional-for-status' into maint
* jc/maint-refresh-index-is-optional-for-status: status: don't require the repository to be writable
2 parents 9504f3d + ab68545 commit 8f376a5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

builtin-commit.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,13 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
278278
* We still need to refresh the index here.
279279
*/
280280
if (!pathspec || !*pathspec) {
281-
fd = hold_locked_index(&index_lock, 1);
281+
fd = hold_locked_index(&index_lock, !is_status);
282282
refresh_cache(refresh_flags);
283-
if (write_cache(fd, active_cache, active_nr) ||
284-
commit_locked_index(&index_lock))
285-
die("unable to write new_index file");
283+
if (0 <= fd) {
284+
if (write_cache(fd, active_cache, active_nr) ||
285+
commit_locked_index(&index_lock))
286+
die("unable to write new_index file");
287+
}
286288
commit_style = COMMIT_AS_IS;
287289
return get_index_file();
288290
}

0 commit comments

Comments
 (0)