From: Kevin Backhouse via GitGitGadget Date: Thu, 24 Aug 2023 14:12:44 GMT Subject: [PATCH v2 1/2] Regression test for https://github.com/gitgitgadget/git/pull/1577 Message-ID: In-Reply-To: From: Kevin Backhouse Signed-off-by: Kevin Backhouse --- t/t9904-merge-leak.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 t/t9904-merge-leak.sh diff --git a/t/t9904-merge-leak.sh b/t/t9904-merge-leak.sh new file mode 100755 index 00000000000..09a4474fd73 --- /dev/null +++ b/t/t9904-merge-leak.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# + +test_description='regression test for memory leak in git merge' + +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + +. ./lib-bash.sh + +# test-lib.sh disables LeakSanitizer by default, but we want it enabled +# for this test +ASAN_OPTIONS= +export ASAN_OPTIONS + +. "$GIT_BUILD_DIR/contrib/completion/git-prompt.sh" + +test_expect_success 'Merge fails due to local changes' ' + git init && + echo x > x.txt && + git add . && + git commit -m "WIP" && + git checkout -b dev && + echo y > x.txt && + git add . && + git commit -m "WIP" && + git checkout main && + echo z > x.txt && + git add . && + git commit -m "WIP" && + echo a > x.txt && + git add . && + echo "error: ''Your local changes to the following files would be overwritten by merge:''" >expected && + echo " x.txt" >>expected && + echo "Merge with strategy ort failed." >>expected && + test_must_fail git merge -s ort dev 2>actual && + test_cmp expected actual +' + +test_done -- gitgitgadget