From: Linus Torvalds <torvalds@osdl.org>
To: Junio C Hamano <junkio@cox.net>, Git Mailing List <git@vger.kernel.org>
Cc: Wolfgang Denk <wd@denx.de>
Subject: Re-instate index file write optimization
Date: Sat, 1 Oct 2005 13:39:47 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.64.0510011331570.3378@g5.osdl.org> (raw)
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>
---
This only makes sense after applying my previous patch, since otherwise a
"--refresh" will always end up marking the index dirty anyway.
Also, while I tried to verify that we always mark the index dirty when we
change it, I can't guarantee it. In particular, since we now map the index
file with PROT_READ | PROT_WRITE, somebody can modify the index entries in
place without getting a SIGSEGV.
Originally you couldn't do the modify-in-place, and used to be that you
could depend on the active_cache[] being unmodified only by actually
assigning to the pointer array itself.
I don't think git-update-index writes to the entries directly, though
(git-read-tree does, but it doesn't do the optimization).
diff --git a/update-index.c b/update-index.c
--- a/update-index.c
+++ b/update-index.c
@@ -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;
}
reply other threads:[~2005-10-01 20:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.64.0510011331570.3378@g5.osdl.org \
--to=torvalds@osdl.org \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
--cc=wd@denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox