aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-04-23 22:07:46 -0700
committerJunio C Hamano <gitster@pobox.com>2017-04-23 22:07:46 -0700
commita2e2c046833be53e7599ee7fed5c45f16580ab37 (patch)
tree0ea4faab2f6b99ac0cbbfebdd1e4f35ac7eff622 /t
parent4c01f67d9102942cc7f0a737de4c609a6ac1832e (diff)
parent86f951570839e241cfa8effbe195674193693a7f (diff)
downloadgit-a2e2c046833be53e7599ee7fed5c45f16580ab37.tar.gz
git-a2e2c046833be53e7599ee7fed5c45f16580ab37.tar.xz
Merge branch 'nd/conditional-config-include'
$GIT_DIR may in some cases be normalized with all symlinks resolved while "gitdir" path expansion in the pattern does not receive the same treatment, leading to incorrect mismatch. This has been fixed. * nd/conditional-config-include: config: resolve symlinks in conditional include's patterns path.c: and an option to call real_path() in expand_user_path()
Diffstat (limited to 't')
-rwxr-xr-xt/t1305-config-include.sh54
1 files changed, 54 insertions, 0 deletions
diff --git a/t/t1305-config-include.sh b/t/t1305-config-include.sh
index e83393932..8fbc7a029 100755
--- a/t/t1305-config-include.sh
+++ b/t/t1305-config-include.sh
@@ -3,6 +3,16 @@
test_description='test config file include directives'
. ./test-lib.sh
+# Force setup_explicit_git_dir() to run until the end. This is needed
+# by some tests to make sure real_path() is called on $GIT_DIR. The
+# caller needs to make sure git commands are run from a subdirectory
+# though or real_path() will not be called.
+force_setup_explicit_git_dir() {
+ GIT_DIR="$(pwd)/.git"
+ GIT_WORK_TREE="$(pwd)"
+ export GIT_DIR GIT_WORK_TREE
+}
+
test_expect_success 'include file by absolute path' '
echo "[test]one = 1" >one &&
echo "[include]path = \"$(pwd)/one\"" >.gitconfig &&
@@ -208,6 +218,50 @@ test_expect_success 'conditional include, both unanchored, icase' '
)
'
+test_expect_success SYMLINKS 'conditional include, set up symlinked $HOME' '
+ mkdir real-home &&
+ ln -s real-home home &&
+ (
+ HOME="$TRASH_DIRECTORY/home" &&
+ export HOME &&
+ cd "$HOME" &&
+
+ git init foo &&
+ cd foo &&
+ mkdir sub
+ )
+'
+
+test_expect_success SYMLINKS 'conditional include, $HOME expansion with symlinks' '
+ (
+ HOME="$TRASH_DIRECTORY/home" &&
+ export HOME &&
+ cd "$HOME"/foo &&
+
+ echo "[includeIf \"gitdir:~/foo/\"]path=bar2" >>.git/config &&
+ echo "[test]two=2" >.git/bar2 &&
+ echo 2 >expect &&
+ force_setup_explicit_git_dir &&
+ git -C sub config test.two >actual &&
+ test_cmp expect actual
+ )
+'
+
+test_expect_success SYMLINKS 'conditional include, relative path with symlinks' '
+ echo "[includeIf \"gitdir:./foo/.git\"]path=bar4" >home/.gitconfig &&
+ echo "[test]four=4" >home/bar4 &&
+ (
+ HOME="$TRASH_DIRECTORY/home" &&
+ export HOME &&
+ cd "$HOME"/foo &&
+
+ echo 4 >expect &&
+ force_setup_explicit_git_dir &&
+ git -C sub config test.four >actual &&
+ test_cmp expect actual
+ )
+'
+
test_expect_success 'include cycles are detected' '
cat >.gitconfig <<-\EOF &&
[test]value = gitconfig