1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-18 21:46:26 +02:00
git/t/t5529-push-errors.sh
Ævar Arnfjörð Bjarmason c65d18cb52 push: free_refs() the "local_refs" in set_refspecs()
Fix a memory leak that's been with us since this code was added in
ca02465b41 (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".

See fd3cb0501e (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>
2023-02-06 15:34:40 -08:00

51 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