Skip to content

Commit 3f9c5df

Browse files
dschogitster
authored andcommitted
t7006: demonstrate a problem with aliases in subdirectories
When expanding aliases, the git_dir is set during the alias expansion (by virtue of running setup_git_directory_gently()). This git_dir may be relative to the current working directory, and indeed often is simply ".git/". When the alias expands to a shell command, we restore the original working directory, though, yet we do not reset git_dir. As a consequence, subsequent read_early_config() runs will mistake the git_dir to be populated properly and not find the correct config. Demonstrate this problem by adding a test case. Signed-off-by: Johannes Schindelin <[email protected]> Reviewed-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e4feff4 commit 3f9c5df

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

t/t7006-pager.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,17 @@ test_expect_success TTY 'core.pager in repo config works and retains cwd' '
391391
)
392392
'
393393

394+
test_expect_failure TTY 'core.pager is found via alias in subdirectory' '
395+
sane_unset GIT_PAGER &&
396+
test_config core.pager "cat >via-alias" &&
397+
(
398+
cd sub &&
399+
rm -f via-alias &&
400+
test_terminal git -c alias.r="-p rev-parse" r HEAD &&
401+
test_path_is_file via-alias
402+
)
403+
'
404+
394405
test_doesnt_paginate expect_failure test_must_fail 'git -p nonsense'
395406

396407
test_pager_choices 'git shortlog'

0 commit comments

Comments
 (0)