summaryrefslogtreecommitdiff
path: root/builtin/commit.c
diff options
context:
space:
mode:
authorDavid Turner <dturner@twopensource.com>2014-07-13 20:28:19 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-07-14 19:34:51 (GMT)
commit9c4d6c0297b7d6167bf330853139b0515b351b89 (patch)
tree6acd9d9d6a0b15a519525e511bfb6997ecd5dea7 /builtin/commit.c
parent59a8adb6fb4ed27868e7144f4531b1bfd065a9c6 (diff)
downloadgit-9c4d6c0297b7d6167bf330853139b0515b351b89.zip
git-9c4d6c0297b7d6167bf330853139b0515b351b89.tar.gz
git-9c4d6c0297b7d6167bf330853139b0515b351b89.tar.bz2
cache-tree: Write updated cache-tree after commit
During the commit process, update the cache-tree. Write this updated cache-tree so that it's ready for subsequent commands. Add test code which demonstrates that git commit now writes the cache tree. Make all tests test the entire cache-tree, not just the root level. Signed-off-by: David Turner <dturner@twitter.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/commit.c')
-rw-r--r--builtin/commit.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/builtin/commit.c b/builtin/commit.c
index 12afc42..77570c4 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -342,6 +342,17 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
discard_cache();
read_cache_from(index_lock.filename);
+ if (update_main_cache_tree(WRITE_TREE_SILENT) == 0) {
+ fd = open(index_lock.filename, O_WRONLY);
+ if (fd >= 0)
+ if (write_cache(fd, active_cache, active_nr) < 0)
+ die(_("unable to write index file"));
+ else
+ close_lock_file(&index_lock);
+ else
+ die(_("unable to write index file"));
+ } else
+ warning(_("Failed to update main cache tree"));
commit_style = COMMIT_NORMAL;
return index_lock.filename;
@@ -383,8 +394,12 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
if (!only && !pathspec.nr) {
fd = hold_locked_index(&index_lock, 1);
refresh_cache_or_die(refresh_flags);
- if (active_cache_changed) {
+ if (active_cache_changed
+ || !cache_tree_fully_valid(active_cache_tree)) {
update_main_cache_tree(WRITE_TREE_SILENT);
+ active_cache_changed = 1;
+ }
+ if (active_cache_changed) {
if (write_cache(fd, active_cache, active_nr) ||
commit_locked_index(&index_lock))
die(_("unable to write new_index file"));
@@ -435,6 +450,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
fd = hold_locked_index(&index_lock, 1);
add_remove_files(&partial);
refresh_cache(REFRESH_QUIET);
+ update_main_cache_tree(WRITE_TREE_SILENT);
if (write_cache(fd, active_cache, active_nr) ||
close_lock_file(&index_lock))
die(_("unable to write new_index file"));