diff options
author | David Aguilar <davvid@gmail.com> | 2017-02-05 13:23:38 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-02-06 10:13:48 -0800 |
commit | d81345ce09c121fb0d18dec5c2535ec8d2a67542 (patch) | |
tree | dfd66a63db19d383530453f73f23b38d60fdf116 /t/t7800-difftool.sh | |
parent | 94d3997ecc09f36d17b9ad4b49c4709885e300f7 (diff) | |
download | git-d81345ce09c121fb0d18dec5c2535ec8d2a67542.tar.gz |
difftool: fix bug when printing usage
"git difftool -h" reports an error:
fatal: BUG: setup_git_env called without repository
Defer repository setup so that the help option processing happens before
the repository is initialized.
Add tests to ensure that the basic usage works inside and outside of a
repository.
Signed-off-by: David Aguilar <davvid@gmail.com>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7800-difftool.sh')
-rwxr-xr-x | t/t7800-difftool.sh | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index 81a2de2b9d..1c81f46cbf 100755 --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@ -23,6 +23,19 @@ prompt_given () test "$prompt" = "Launch 'test-tool' [Y/n]? branch" } +test_expect_success 'basic usage requires no repo' ' + lines=$(git difftool -h | grep ^usage: | wc -l) && + test "$lines" -eq 1 && + # create a ceiling directory to prevent Git from finding a repo + mkdir -p not/repo && + ceiling="$PWD/not" && + lines=$(cd not/repo && + GIT_CEILING_DIRECTORIES="$ceiling" git difftool -h | + grep ^usage: | wc -l) && + test "$lines" -eq 1 && + rmdir -p not/repo +' + # Create a file on master and change it on branch test_expect_success 'setup' ' echo master >file && |