diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-09-03 19:18:02 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-09-03 19:18:02 -0700 |
commit | 311e5ce2cc06f7bb640be62f487e5b3d14bbb9a0 (patch) | |
tree | 26d97cd3ac03658ae61e42bcf267468f8fb0b9bc | |
parent | 1c820392282466b50f650d484a3560087a7fe686 (diff) | |
parent | 475a34451f86d1b954c5da37f04ed044544cf6e4 (diff) | |
download | git-311e5ce2cc06f7bb640be62f487e5b3d14bbb9a0.tar.gz |
Merge branch 'dt/commit-preserve-base-index-upon-opportunistic-cache-tree-update' into maint
When re-priming the cache-tree opportunistically while committing
the in-core index as-is, we mistakenly invalidated the in-core
index too aggressively, causing the experimental split-index code
to unnecessarily rewrite the on-disk index file(s).
* dt/commit-preserve-base-index-upon-opportunistic-cache-tree-update:
commit: don't rewrite shared index unnecessarily
-rw-r--r-- | builtin/commit.c | 4 | ||||
-rwxr-xr-x | t/t0090-cache-tree.sh | 10 | ||||
-rw-r--r-- | test-dump-split-index.c | 6 |
3 files changed, 15 insertions, 5 deletions
diff --git a/builtin/commit.c b/builtin/commit.c index 254477fd1d..1692620e25 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -404,10 +404,8 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix hold_locked_index(&index_lock, 1); refresh_cache_or_die(refresh_flags); if (active_cache_changed - || !cache_tree_fully_valid(active_cache_tree)) { + || !cache_tree_fully_valid(active_cache_tree)) update_main_cache_tree(WRITE_TREE_SILENT); - active_cache_changed = 1; - } if (active_cache_changed) { if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK)) diff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh index 601d02d71f..f92dd1f1dc 100755 --- a/t/t0090-cache-tree.sh +++ b/t/t0090-cache-tree.sh @@ -218,4 +218,14 @@ test_expect_success 'no phantom error when switching trees' ' ! test -s errors ' +test_expect_success 'switching trees does not invalidate shared index' ' + git update-index --split-index && + >split && + git add split && + test-dump-split-index .git/index | grep -v ^own >before && + git commit -m "as-is" && + test-dump-split-index .git/index | grep -v ^own >after && + test_cmp before after +' + test_done diff --git a/test-dump-split-index.c b/test-dump-split-index.c index 9cf3112c9d..861d28c9b6 100644 --- a/test-dump-split-index.c +++ b/test-dump-split-index.c @@ -26,9 +26,11 @@ int main(int ac, char **av) sha1_to_hex(ce->sha1), ce_stage(ce), ce->name); } printf("replacements:"); - ewah_each_bit(si->replace_bitmap, show_bit, NULL); + if (si->replace_bitmap) + ewah_each_bit(si->replace_bitmap, show_bit, NULL); printf("\ndeletions:"); - ewah_each_bit(si->delete_bitmap, show_bit, NULL); + if (si->delete_bitmap) + ewah_each_bit(si->delete_bitmap, show_bit, NULL); printf("\n"); return 0; } |