diff options
author | SZEDER Gábor <szeder.dev@gmail.com> | 2017-02-03 03:48:28 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-02-03 22:18:41 -0800 |
commit | beb6ee71639ffe96f676ba4268cb85e4a933ab7e (patch) | |
tree | 8a2e8d6eef00c0c51546ce2caf0eeeb44b8facdf /t | |
parent | completion: don't guard git executions with __gitdir() (diff) | |
download | tgif-beb6ee71639ffe96f676ba4268cb85e4a933ab7e.tar.xz |
completion: extract repository discovery from __gitdir()
To prepare for caching the path to the repository in the following
commit, extract the repository discovering part of __gitdir() into the
__git_find_repo_path() helper function, which stores the found path in
the $__git_repo_path variable instead of printing it. Make __gitdir()
a wrapper around this new function. Declare $__git_repo_path local in
the toplevel completion functions __git_main() and __gitk_main() to
ensure that it never leaks into the environment and influences
subsequent completions (though this isn't necessary right now, as
__gitdir() is still only executed in subshells, but will matter for
the following commit).
Adjust tests checking __gitdir() or any other completion function
calling __gitdir() to perform those checks in a subshell to prevent
$__git_repo_path from leaking into the test environment. Otherwise
leave the tests unchanged to demonstrate that this change doesn't
alter __gitdir()'s behavior.
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t9902-completion.sh | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 984df05b23..1816ed2e05 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -147,19 +147,25 @@ test_expect_success '__gitdir - from command line (through $__git_dir)' ' test_expect_success '__gitdir - repo as argument' ' echo "otherrepo/.git" >expected && - __gitdir "otherrepo" >"$actual" && + ( + __gitdir "otherrepo" >"$actual" + ) && test_cmp expected "$actual" ' test_expect_success '__gitdir - remote as argument' ' echo "remote" >expected && - __gitdir "remote" >"$actual" && + ( + __gitdir "remote" >"$actual" + ) && test_cmp expected "$actual" ' test_expect_success '__gitdir - .git directory in cwd' ' echo ".git" >expected && - __gitdir >"$actual" && + ( + __gitdir >"$actual" + ) && test_cmp expected "$actual" ' @@ -450,7 +456,9 @@ test_expect_success '__git_remotes - list remotes from $GIT_DIR/remotes and from git remote add remote_in_config_1 git://remote_1 && test_when_finished "git remote remove remote_in_config_2" && git remote add remote_in_config_2 git://remote_2 && - __git_remotes >actual && + ( + __git_remotes >actual + ) && test_cmp expect actual ' @@ -459,8 +467,10 @@ test_expect_success '__git_is_configured_remote' ' git remote add remote_1 git://remote_1 && test_when_finished "git remote remove remote_2" && git remote add remote_2 git://remote_2 && - verbose __git_is_configured_remote remote_2 && - test_must_fail __git_is_configured_remote non-existent + ( + verbose __git_is_configured_remote remote_2 && + test_must_fail __git_is_configured_remote non-existent + ) ' test_expect_success 'setup for ref completion' ' |