From c8bae7493d2f2910b57f13ded012e86bdcfb0532 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 16:47:53 +0200 Subject: Adding upstream version 1:2.39.2. Signed-off-by: Daniel Baumann --- t/t8007-cat-file-textconv.sh | 130 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100755 t/t8007-cat-file-textconv.sh (limited to 't/t8007-cat-file-textconv.sh') diff --git a/t/t8007-cat-file-textconv.sh b/t/t8007-cat-file-textconv.sh new file mode 100755 index 0000000..c8266f1 --- /dev/null +++ b/t/t8007-cat-file-textconv.sh @@ -0,0 +1,130 @@ +#!/bin/sh + +test_description='git cat-file textconv support' + +TEST_PASSES_SANITIZE_LEAK=true +. ./test-lib.sh + +cat >helper <<'EOF' +#!/bin/sh +grep -q '^bin: ' "$1" || { echo "E: $1 is not \"binary\" file" 1>&2; exit 1; } +sed 's/^bin: /converted: /' "$1" +EOF +chmod +x helper + +test_expect_success 'setup ' ' + echo "bin: test" >one.bin && + test_ln_s_add one.bin symlink.bin && + git add . && + GIT_AUTHOR_NAME=Number1 git commit -a -m First --date="2010-01-01 18:00:00" && + echo "bin: test version 2" >one.bin && + GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00" +' + +test_expect_success 'usage: ' ' + cat >expect <<-\EOF && + fatal: Not a valid object name HEAD2 + EOF + test_must_fail git cat-file --textconv HEAD2 2>actual && + test_cmp expect actual +' + +test_expect_success 'usage: :' ' + cat >expect <<-\EOF && + fatal: invalid object name '\''HEAD2'\''. + EOF + test_must_fail git cat-file --textconv HEAD2:two.bin 2>actual && + test_cmp expect actual +' + +test_expect_success 'usage: :' ' + cat >expect <<-\EOF && + fatal: path '\''two.bin'\'' does not exist in '\''HEAD'\'' + EOF + test_must_fail git cat-file --textconv HEAD:two.bin 2>actual && + test_cmp expect actual +' + + +test_expect_success 'usage: with no ' ' + cat >expect <<-\EOF && + fatal: : required, only '\''HEAD'\'' given + EOF + test_must_fail git cat-file --textconv HEAD 2>actual && + test_cmp expect actual +' + + +test_expect_success 'usage: :' ' + cat >expect <<-\EOF && + fatal: invalid object name '\''HEAD2'\''. + EOF + test_must_fail git cat-file --textconv HEAD2:one.bin 2>actual && + test_cmp expect actual +' + +cat >expected <result && + test_cmp expected result +' + +test_expect_success 'setup textconv filters' ' + echo "*.bin diff=test" >.gitattributes && + git config diff.test.textconv ./helper && + git config diff.test.cachetextconv false +' + +test_expect_success 'cat-file without --textconv' ' + git cat-file blob :one.bin >result && + test_cmp expected result +' + +cat >expected <result && + test_cmp expected result +' + +cat >expected <result && + test_cmp expected result +' + +cat >expected <result && + test_cmp expected result +' + +test_expect_success 'cat-file without --textconv (symlink)' ' + printf "%s" "one.bin" >expected && + git cat-file blob :symlink.bin >result && + test_cmp expected result +' + + +test_expect_success 'cat-file --textconv on index (symlink)' ' + git cat-file --textconv :symlink.bin >result && + test_cmp expected result +' + +test_expect_success 'cat-file --textconv on HEAD (symlink)' ' + git cat-file --textconv HEAD:symlink.bin >result && + test_cmp expected result +' + +test_done -- cgit v1.2.3