mirror of
https://github.com/git/git
synced 2024-11-05 18:59:29 +00:00
c65d18cb52
Fix a memory leak that's been with us since this code was added inca02465b41
(push: use remote.$name.push as a refmap, 2013-12-03). The "remote = remote_get(...)" added in the same commit would seem to leak based only on the context here, but that function is a wrapper for sticking the remotes we fetch into "the_repository->remote_state". Seefd3cb0501e
(remote: move static variables into per-repository struct, 2021-11-17) for the addition of code in repository.c that free's the "remote" allocated here. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
50 lines
1.1 KiB
Bash
Executable file
50 lines
1.1 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='detect some push errors early (before contacting remote)'
|
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'setup commits' '
|
|
test_commit one
|
|
'
|
|
|
|
test_expect_success 'setup remote' '
|
|
git init --bare remote.git &&
|
|
git remote add origin remote.git
|
|
'
|
|
|
|
test_expect_success 'setup fake receive-pack' '
|
|
FAKE_RP_ROOT=$(pwd) &&
|
|
export FAKE_RP_ROOT &&
|
|
write_script fake-rp <<-\EOF &&
|
|
echo yes >"$FAKE_RP_ROOT"/rp-ran
|
|
exit 1
|
|
EOF
|
|
git config remote.origin.receivepack "\"\$FAKE_RP_ROOT/fake-rp\""
|
|
'
|
|
|
|
test_expect_success 'detect missing branches early' '
|
|
echo no >rp-ran &&
|
|
echo no >expect &&
|
|
test_must_fail git push origin missing &&
|
|
test_cmp expect rp-ran
|
|
'
|
|
|
|
test_expect_success 'detect missing sha1 expressions early' '
|
|
echo no >rp-ran &&
|
|
echo no >expect &&
|
|
test_must_fail git push origin main~2:main &&
|
|
test_cmp expect rp-ran
|
|
'
|
|
|
|
test_expect_success 'detect ambiguous refs early' '
|
|
git branch foo &&
|
|
git tag foo &&
|
|
echo no >rp-ran &&
|
|
echo no >expect &&
|
|
test_must_fail git push origin foo &&
|
|
test_cmp expect rp-ran
|
|
'
|
|
|
|
test_done
|