summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 996277c)
raw | patch | inline | side by side (parent: 996277c)
author | Thomas Rast <trast@student.ethz.ch> | |
Tue, 6 Dec 2011 17:43:38 +0000 (18:43 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 6 Dec 2011 22:58:53 +0000 (14:58 -0800) |
In prepare_index(), we refresh the index, and then write it to disk if
this changed the index data. After running hooks we re-read the index
and compute the root tree sha1 with the cache-tree machinery.
This gives us a mostly free opportunity to write up-to-date cache-tree
data: we can compute it in prepare_index() immediately before writing
the index to disk.
If we do this, we were going to write the index anyway, and the later
cache-tree update has no further work to do. If we don't do it, we
don't do any extra work, though we still don't have have cache-tree
data after the commit.
The only case that suffers badly is when the pre-commit hook changes
many trees in the index. I'm writing this off as highly unusual.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
this changed the index data. After running hooks we re-read the index
and compute the root tree sha1 with the cache-tree machinery.
This gives us a mostly free opportunity to write up-to-date cache-tree
data: we can compute it in prepare_index() immediately before writing
the index to disk.
If we do this, we were going to write the index anyway, and the later
cache-tree update has no further work to do. If we don't do it, we
don't do any extra work, though we still don't have have cache-tree
data after the commit.
The only case that suffers badly is when the pre-commit hook changes
many trees in the index. I'm writing this off as highly unusual.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/commit.c | patch | blob | history | |
t/t0090-cache-tree.sh | patch | blob | history |
diff --git a/builtin/commit.c b/builtin/commit.c
index 4f782a33f1dde5c82d7da5f1051083a743e00ddd..5125841f92bf709610a77c641afdccc4491b4440 100644 (file)
--- a/builtin/commit.c
+++ b/builtin/commit.c
fd = hold_locked_index(&index_lock, 1);
add_files_to_cache(also ? prefix : NULL, pathspec, 0);
refresh_cache_or_die(refresh_flags);
+ update_main_cache_tree(1);
if (write_cache(fd, active_cache, active_nr) ||
close_lock_file(&index_lock))
die(_("unable to write new_index file"));
fd = hold_locked_index(&index_lock, 1);
refresh_cache_or_die(refresh_flags);
if (active_cache_changed) {
+ update_main_cache_tree(1);
if (write_cache(fd, active_cache, active_nr) ||
commit_locked_index(&index_lock))
die(_("unable to write new_index file"));
diff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh
index 3d0702a6f9e09fa5fd1b983d8f7f548870bf34dc..a3527a5c99cc69a5f54eaf2ff4b20f8c239f55bc 100755 (executable)
--- a/t/t0090-cache-tree.sh
+++ b/t/t0090-cache-tree.sh
test_no_cache_tree
'
-test_expect_failure 'second commit has cache-tree' '
+test_expect_success 'second commit has cache-tree' '
test_commit bar &&
test_shallow_cache_tree
'