mirror of
https://github.com/git/git.git
synced 2024-11-23 09:56:28 +08:00
03267e8656
The read_cache() in prepare_to_commit() would end up clobbering the pointer we had for a previously populated "the_index.cache_tree" in the very common case of "git commit" stressed by e.g. the tests being changed here. We'd populate "the_index.cache_tree" by calling "update_main_cache_tree" in prepare_index(), but would not end up with a "fully prepared" index. What constitutes an existing index is clearly overly fuzzy, here we'll check "active_nr" (aka "the_index.cache_nr"), but our "the_index.cache_tree" might have been malloc()'d already. Thus the code added in11c8a74a64
(commit: write cache-tree data when writing index anyway, 2011-12-06) would end up allocating the "cache_tree", and would interact here with code added in7168624c35
(Do not generate full commit log message if it is not going to be used, 2007-11-28). The result was a very common memory leak. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Taylor Blau <me@ttaylorr.com>
74 lines
1.6 KiB
Bash
Executable File
74 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='Test reflog interaction with detached HEAD'
|
|
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
|
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
|
. ./test-lib.sh
|
|
|
|
reset_state () {
|
|
rm -rf .git && "$TAR" xf .git-saved.tar
|
|
}
|
|
|
|
test_expect_success setup '
|
|
test_tick &&
|
|
git commit --allow-empty -m initial &&
|
|
git branch side &&
|
|
test_tick &&
|
|
git commit --allow-empty -m second &&
|
|
"$TAR" cf .git-saved.tar .git
|
|
'
|
|
|
|
test_expect_success baseline '
|
|
reset_state &&
|
|
git rev-parse main main^ >expect &&
|
|
git log -g --format=%H >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success 'switch to branch' '
|
|
reset_state &&
|
|
git rev-parse side main main^ >expect &&
|
|
git checkout side &&
|
|
git log -g --format=%H >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success 'detach to other' '
|
|
reset_state &&
|
|
git rev-parse main side main main^ >expect &&
|
|
git checkout side &&
|
|
git checkout main^0 &&
|
|
git log -g --format=%H >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success 'detach to self' '
|
|
reset_state &&
|
|
git rev-parse main main main^ >expect &&
|
|
git checkout main^0 &&
|
|
git log -g --format=%H >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success 'attach to self' '
|
|
reset_state &&
|
|
git rev-parse main main main main^ >expect &&
|
|
git checkout main^0 &&
|
|
git checkout main &&
|
|
git log -g --format=%H >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success 'attach to other' '
|
|
reset_state &&
|
|
git rev-parse side main main main^ >expect &&
|
|
git checkout main^0 &&
|
|
git checkout side &&
|
|
git log -g --format=%H >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_done
|