diff options
| -rw-r--r-- | contrib/completion/git-completion.bash | 2 | ||||
| -rwxr-xr-x | t/t9902-completion.sh | 31 |
2 files changed, 32 insertions, 1 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index d703e3e64f..54ce58f73d 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -148,7 +148,7 @@ __git_pseudoref_exists () # platforms. if __git_eread "$__git_repo_path/HEAD" head; then if [ "$head" == "ref: refs/heads/.invalid" ]; then - __git rev-parse --verify --quiet "$ref" + __git rev-parse --verify --quiet "$ref" >/dev/null return $? fi fi diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 95ec762a74..56dc7343a2 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -1933,6 +1933,14 @@ test_expect_success 'git checkout - --orphan with branch already provided comple EOF ' +test_expect_success 'git restore completes modified files' ' + test_commit A a.file && + echo B >a.file && + test_completion "git restore a." <<-\EOF + a.file + EOF +' + test_expect_success 'teardown after ref completion' ' git branch -d matching-branch && git tag -d matching-tag && @@ -2728,4 +2736,27 @@ test_expect_success '__git_complete' ' test_must_fail __git_complete ga missing ' +test_expect_success '__git_pseudoref_exists' ' + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + sane_unset __git_repo_path && + + # HEAD points to an existing branch, so it should exist. + test_commit A && + __git_pseudoref_exists HEAD >output 2>&1 && + test_must_be_empty output && + + # CHERRY_PICK_HEAD does not exist, so the existence check should fail. + ! __git_pseudoref_exists CHERRY_PICK_HEAD >output 2>&1 && + test_must_be_empty output && + + # CHERRY_PICK_HEAD points to a commit, so it should exist. + git update-ref CHERRY_PICK_HEAD A && + __git_pseudoref_exists CHERRY_PICK_HEAD >output 2>&1 && + test_must_be_empty output + ) +' + test_done |
