1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-07 17:53:12 +01:00
git/t/t5615-alternate-env.sh
Johannes Sixt 71dd50472d t0021, t5615: use $PWD instead of $(pwd) in PATH-like shell variables
We have to use $PWD instead of $(pwd) because on Windows the latter
would add a C: style path to bash's Unix-style $PATH variable, which
becomes confused by the colon after the drive letter. ($PWD is a
Unix-style path.)

In the case of GIT_ALTERNATE_OBJECT_DIRECTORIES, bash on Windows
assembles a Unix-style path list with the colon as separators. It
converts the value to a Windows-style path list with the semicolon as
path separator when it forwards the variable to git.exe. The same
confusion happens when bash's original value is contaminated with
Windows style paths.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-11-11 10:54:46 -08:00

71 lines
1.6 KiB
Bash
Executable file

#!/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" >&3 &&
echo "$obj $expect" >&4
done 3>input 4>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
'
test_done