Skip to content

Commit

Permalink
[PATCH] Re-instate index file write optimization
Browse files Browse the repository at this point in the history
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 <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Linus Torvalds authored and Junio C Hamano committed Oct 2, 2005
1 parent 5d1a5c0 commit 5cd5ace
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions update-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,11 @@ int main(int argc, const char **argv)
update_one(buf.buf, prefix, prefix_length);
}
}
if (write_cache(newfd, active_cache, active_nr) ||
commit_index_file(&cache_file))
die("Unable to write new cachefile");
if (active_cache_changed) {
if (write_cache(newfd, active_cache, active_nr) ||
commit_index_file(&cache_file))
die("Unable to write new cachefile");
}

return has_errors ? 1 : 0;
}

0 comments on commit 5cd5ace

Please sign in to comment.