diff options
author | SZEDER Gábor <szeder.dev@gmail.com> | 2017-02-03 03:48:15 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-02-04 07:18:40 +0100 |
commit | a2f03b0ec8a69049343a00f522a88ae280235176 (patch) | |
tree | 16f03ab4cced9431e4f4e00d8786355b6ed1e79d /t/t9902-completion.sh | |
parent | completion tests: add tests for the __git_refs() helper function (diff) | |
download | git-a2f03b0ec8a69049343a00f522a88ae280235176.tar.xz git-a2f03b0ec8a69049343a00f522a88ae280235176.zip |
completion: ensure that the repository path given on the command line exists
The __gitdir() helper function prints the path to the git repository
to its stdout or stays silent and returns with error when it can't
find a repository or when the repository given via $GIT_DIR doesn't
exist.
This is not the case, however, when the path in $__git_dir, i.e. the
path to the repository specified on the command line via 'git
--git-dir=<path>', doesn't exist: __gitdir() still outputs it as if it
were a real existing repository, making some completion functions
believe that they operate on an existing repository.
Check that the path in $__git_dir exists and return with error without
printing anything to stdout if it doesn't.
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t9902-completion.sh')
-rwxr-xr-x | t/t9902-completion.sh | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 7956cb9b16..7667baabff 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -211,6 +211,14 @@ test_expect_success '__gitdir - $GIT_DIR set while .git directory in parent' ' test_cmp expected "$actual" ' +test_expect_success '__gitdir - non-existing path in $__git_dir' ' + ( + __git_dir="non-existing" && + test_must_fail __gitdir >"$actual" + ) && + test_must_be_empty "$actual" +' + test_expect_success '__gitdir - non-existing $GIT_DIR' ' ( GIT_DIR="$ROOT/non-existing" && |