|
5 | 5 |
|
6 | 6 | test_description='test bash completion'
|
7 | 7 |
|
| 8 | +# The Bash completion scripts must not print anything to either stdout or |
| 9 | +# stderr, which we try to verify. When tracing is enabled without support for |
| 10 | +# BASH_XTRACEFD this assertion will fail, so we have to mark the test as |
| 11 | +# untraceable with such ancient Bash versions. |
| 12 | +test_untraceable=UnfortunatelyYes |
| 13 | + |
8 | 14 | . ./lib-bash.sh
|
9 | 15 |
|
10 | 16 | complete ()
|
@@ -87,9 +93,11 @@ test_completion ()
|
87 | 93 | else
|
88 | 94 | sed -e 's/Z$//' |sort >expected
|
89 | 95 | fi &&
|
90 |
| - run_completion "$1" && |
| 96 | + run_completion "$1" >"$TRASH_DIRECTORY"/bash-completion-output 2>&1 && |
91 | 97 | sort out >out_sorted &&
|
92 |
| - test_cmp expected out_sorted |
| 98 | + test_cmp expected out_sorted && |
| 99 | + test_must_be_empty "$TRASH_DIRECTORY"/bash-completion-output && |
| 100 | + rm "$TRASH_DIRECTORY"/bash-completion-output |
93 | 101 | }
|
94 | 102 |
|
95 | 103 | # Test __gitcomp.
|
@@ -1925,6 +1933,14 @@ test_expect_success 'git checkout - --orphan with branch already provided comple
|
1925 | 1933 | EOF
|
1926 | 1934 | '
|
1927 | 1935 |
|
| 1936 | +test_expect_success 'git restore completes modified files' ' |
| 1937 | + test_commit A a.file && |
| 1938 | + echo B >a.file && |
| 1939 | + test_completion "git restore a." <<-\EOF |
| 1940 | + a.file |
| 1941 | + EOF |
| 1942 | +' |
| 1943 | + |
1928 | 1944 | test_expect_success 'teardown after ref completion' '
|
1929 | 1945 | git branch -d matching-branch &&
|
1930 | 1946 | git tag -d matching-tag &&
|
@@ -2720,4 +2736,31 @@ test_expect_success '__git_complete' '
|
2720 | 2736 | test_must_fail __git_complete ga missing
|
2721 | 2737 | '
|
2722 | 2738 |
|
| 2739 | +test_expect_success '__git_pseudoref_exists' ' |
| 2740 | + test_when_finished "rm -rf repo" && |
| 2741 | + git init repo && |
| 2742 | + ( |
| 2743 | + cd repo && |
| 2744 | + sane_unset __git_repo_path && |
| 2745 | +
|
| 2746 | + # HEAD should exist, even if it points to an unborn branch. |
| 2747 | + __git_pseudoref_exists HEAD >output 2>&1 && |
| 2748 | + test_must_be_empty output && |
| 2749 | +
|
| 2750 | + # HEAD points to an existing branch, so it should exist. |
| 2751 | + test_commit A && |
| 2752 | + __git_pseudoref_exists HEAD >output 2>&1 && |
| 2753 | + test_must_be_empty output && |
| 2754 | +
|
| 2755 | + # CHERRY_PICK_HEAD does not exist, so the existence check should fail. |
| 2756 | + ! __git_pseudoref_exists CHERRY_PICK_HEAD >output 2>&1 && |
| 2757 | + test_must_be_empty output && |
| 2758 | +
|
| 2759 | + # CHERRY_PICK_HEAD points to a commit, so it should exist. |
| 2760 | + git update-ref CHERRY_PICK_HEAD A && |
| 2761 | + __git_pseudoref_exists CHERRY_PICK_HEAD >output 2>&1 && |
| 2762 | + test_must_be_empty output |
| 2763 | + ) |
| 2764 | +' |
| 2765 | + |
2723 | 2766 | test_done
|
0 commit comments