diff options
author | Emily Shaffer <emilyshaffer@google.com> | 2020-03-02 20:05:06 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-03-15 09:35:46 -0700 |
commit | 5c20398699165a91af2d81ea2d20385bc8dd3627 (patch) | |
tree | 7ee6a11bb7465d2c938a39410c958acfb9639a43 /t/t6136-pathspec-in-bare.sh | |
parent | e0020b2f82910f50bc697d86aff70c3796fbdc41 (diff) | |
download | git-5c20398699165a91af2d81ea2d20385bc8dd3627.tar.gz |
prefix_path: show gitdir if worktree unavailable
If there is no worktree at present, we can still hint the user about
Git's current directory by showing them the absolute path to the Git
directory. Even though the Git directory doesn't make it as easy to
locate the worktree in question, it can still help a user figure out
what's going on while developing a script.
This fixes a segmentation fault introduced in e0020b2f
("prefix_path: show gitdir when arg is outside repo", 2020-02-14).
Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
[jc: added minimum tests, with help from Szeder Gábor]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t6136-pathspec-in-bare.sh')
-rwxr-xr-x | t/t6136-pathspec-in-bare.sh | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/t/t6136-pathspec-in-bare.sh b/t/t6136-pathspec-in-bare.sh new file mode 100755 index 0000000000..b117251366 --- /dev/null +++ b/t/t6136-pathspec-in-bare.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +test_description='diagnosing out-of-scope pathspec' + +. ./test-lib.sh + +test_expect_success 'setup a bare and non-bare repository' ' + test_commit file1 && + git clone --bare . bare +' + +test_expect_success 'log and ls-files in a bare repository' ' + ( + cd bare && + test_must_fail git log -- .. >out 2>err && + test_must_be_empty out && + test_i18ngrep "outside repository" err && + + test_must_fail git ls-files -- .. >out 2>err && + test_must_be_empty out && + test_i18ngrep "outside repository" err + ) +' + +test_expect_success 'log and ls-files in .git directory' ' + ( + cd .git && + test_must_fail git log -- .. >out 2>err && + test_must_be_empty out && + test_i18ngrep "outside repository" err && + + test_must_fail git ls-files -- .. >out 2>err && + test_must_be_empty out && + test_i18ngrep "outside repository" err + ) +' + +test_done |