git/t/t4258-am-quoted-cr.sh
Rubén Justo 71c7916053 apply: plug a leak in apply_data
We have an execution path in apply_data that leaks the local struct
image.  Plug it.

This leak can be triggered with:

    $ echo foo >file
    $ git add file && git commit -m file
    $ echo bar >file
    $ git diff file >diff
    $ sed s/foo/frotz/ <diff >baddiff
    $ git apply --cached <baddiff

Fixing this leak allows us to mark as leak-free the following tests:

    + t2016-checkout-patch.sh
    + t4103-apply-binary.sh
    + t4104-apply-boundary.sh
    + t4113-apply-ending.sh
    + t4117-apply-reject.sh
    + t4123-apply-shrink.sh
    + t4252-am-options.sh
    + t4258-am-quoted-cr.sh

Mark them with "TEST_PASSES_SANITIZE_LEAK=true" to notice and fix
promply any new leak that may be introduced and triggered by them in the
future.

Signed-off-by: Rubén Justo <rjusto@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-04-22 16:27:42 -07:00

38 lines
872 B
Bash
Executable file

#!/bin/sh
test_description='test am --quoted-cr=<action>'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
DATA="$TEST_DIRECTORY/t4258"
test_expect_success 'setup' '
test_write_lines one two three >text &&
test_commit one text &&
test_write_lines one owt three >text &&
test_commit two text
'
test_expect_success 'am warn if quoted-cr is found' '
git reset --hard one &&
test_must_fail git am "$DATA/mbox" 2>err &&
grep "quoted CRLF detected" err
'
test_expect_success 'am --quoted-cr=strip' '
test_might_fail git am --abort &&
git reset --hard one &&
git am --quoted-cr=strip "$DATA/mbox" &&
git diff --exit-code HEAD two
'
test_expect_success 'am with config mailinfo.quotedCr=strip' '
test_might_fail git am --abort &&
git reset --hard one &&
test_config mailinfo.quotedCr strip &&
git am "$DATA/mbox" &&
git diff --exit-code HEAD two
'
test_done