diff options
author | Vincent Ambo <Vincent Ambo> | 2020-01-11T23·36+0000 |
---|---|---|
committer | Vincent Ambo <Vincent Ambo> | 2020-01-11T23·36+0000 |
commit | 1b593e1ea4d2af0f6444d9a7788d5d99abd6fde5 (patch) | |
tree | e3accb9beed5c4c1b5a05c99db71ab2841f0ed04 /t/t5615-alternate-env.sh |
Squashed 'third_party/git/' content from commit cb71568594
git-subtree-dir: third_party/git git-subtree-split: cb715685942260375e1eb8153b0768a376e4ece7
Diffstat (limited to 't/t5615-alternate-env.sh')
-rwxr-xr-x | t/t5615-alternate-env.sh | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/t/t5615-alternate-env.sh b/t/t5615-alternate-env.sh new file mode 100755 index 000000000000..b4905b822c07 --- /dev/null +++ b/t/t5615-alternate-env.sh @@ -0,0 +1,90 @@ +#!/bin/sh + +test_description='handling of alternates in environment variables' +. ./test-lib.sh + +check_obj () { + alt=$1; shift + while read obj expect + do + echo "$obj" >&5 && + echo "$obj $expect" >&6 + done 5>input 6>expect && + GIT_ALTERNATE_OBJECT_DIRECTORIES=$alt \ + git "$@" cat-file --batch-check='%(objectname) %(objecttype)' \ + <input >actual && + test_cmp expect actual +} + +test_expect_success 'create alternate repositories' ' + git init --bare one.git && + one=$(echo one | git -C one.git hash-object -w --stdin) && + git init --bare two.git && + two=$(echo two | git -C two.git hash-object -w --stdin) +' + +test_expect_success 'objects inaccessible without alternates' ' + check_obj "" <<-EOF + $one missing + $two missing + EOF +' + +test_expect_success 'access alternate via absolute path' ' + check_obj "$PWD/one.git/objects" <<-EOF + $one blob + $two missing + EOF +' + +test_expect_success 'access multiple alternates' ' + check_obj "$PWD/one.git/objects:$PWD/two.git/objects" <<-EOF + $one blob + $two blob + EOF +' + +# bare paths are relative from $GIT_DIR +test_expect_success 'access alternate via relative path (bare)' ' + git init --bare bare.git && + check_obj "../one.git/objects" -C bare.git <<-EOF + $one blob + EOF +' + +# non-bare paths are relative to top of worktree +test_expect_success 'access alternate via relative path (worktree)' ' + git init worktree && + check_obj "../one.git/objects" -C worktree <<-EOF + $one blob + EOF +' + +# path is computed after moving to top-level of worktree +test_expect_success 'access alternate via relative path (subdir)' ' + mkdir subdir && + check_obj "one.git/objects" -C subdir <<-EOF + $one blob + EOF +' + +# set variables outside test to avoid quote insanity; the \057 is '/', +# which doesn't need quoting, but just confirms that de-quoting +# is working. +quoted='"one.git\057objects"' +unquoted='two.git/objects' +test_expect_success 'mix of quoted and unquoted alternates' ' + check_obj "$quoted:$unquoted" <<-EOF + $one blob + $two blob + EOF +' + +test_expect_success !MINGW 'broken quoting falls back to interpreting raw' ' + mv one.git \"one.git && + check_obj \"one.git/objects <<-EOF + $one blob + EOF +' + +test_done |