Skip to content

Commit 5cd5ace

Browse files
Linus TorvaldsJunio C Hamano
authored andcommitted
[PATCH] Re-instate index file write optimization
This makes "git-update-index" avoid the new index file write if it didn't make any changes to the index. It still doesn't make things like "git status" be read-only operations in general, but if the index file doesn't need refreshing, it now will at least avoid making unnecessary changes. Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5d1a5c0 commit 5cd5ace

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

update-index.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,11 @@ int main(int argc, const char **argv)
391391
update_one(buf.buf, prefix, prefix_length);
392392
}
393393
}
394-
if (write_cache(newfd, active_cache, active_nr) ||
395-
commit_index_file(&cache_file))
396-
die("Unable to write new cachefile");
394+
if (active_cache_changed) {
395+
if (write_cache(newfd, active_cache, active_nr) ||
396+
commit_index_file(&cache_file))
397+
die("Unable to write new cachefile");
398+
}
397399

398400
return has_errors ? 1 : 0;
399401
}

0 commit comments

Comments
 (0)