From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Hongyi Zhao" <hongyi.zhao@gmail.com>,
"Philippe Blain" <levraiphilippeblain@gmail.com>,
"João Victor Bonfim"
<JoaoVictorBonfim+Git-Mail-List@protonmail.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH v2 1/2] completion tests: re-source git-completion.bash in a subshell
Date: Wed, 2 Feb 2022 12:15:09 +0100 [thread overview]
Message-ID: <patch-v2-1.2-cf09546e079-20220202T111228Z-avarab@gmail.com> (raw)
In-Reply-To: <cover-v2-0.2-00000000000-20220202T111228Z-avarab@gmail.com>
Change tests of git-completion.bash that re-source it to do so inside
a subshell. Re-sourcing it will clobber variables it sets, and in the
case of the "GIT_COMPLETION_SHOW_ALL=1" test added in
ca2d62b7879 (parse-options: don't complete option aliases by default,
2021-07-16) change the behavior of the completion persistently.
Aside from the addition of "(" and ")" on new lines this is an
indentation-only change, only the "(" and ")" lines are changed under
"git diff -w".
So let's change that test, and for good measure do the same for the
three tests that precede it, which were added in
8b0eaa41f23 (completion: clear cached --options when sourcing the
completion script, 2018-03-22). The may not be wrong, but doing this
establishes a more reliable pattern for future tests, which might use
these as a template to copy.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
t/t9902-completion.sh | 50 +++++++++++++++++++++++++------------------
1 file changed, 29 insertions(+), 21 deletions(-)
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 98c62806328..c9805f2147d 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -2396,27 +2396,33 @@ test_expect_success 'options with value' '
'
test_expect_success 'sourcing the completion script clears cached commands' '
- __git_compute_all_commands &&
- verbose test -n "$__git_all_commands" &&
- . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&
- verbose test -z "$__git_all_commands"
+ (
+ __git_compute_all_commands &&
+ verbose test -n "$__git_all_commands" &&
+ . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&
+ verbose test -z "$__git_all_commands"
+ )
'
test_expect_success 'sourcing the completion script clears cached merge strategies' '
- __git_compute_merge_strategies &&
- verbose test -n "$__git_merge_strategies" &&
- . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&
- verbose test -z "$__git_merge_strategies"
+ (
+ __git_compute_merge_strategies &&
+ verbose test -n "$__git_merge_strategies" &&
+ . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&
+ verbose test -z "$__git_merge_strategies"
+ )
'
test_expect_success 'sourcing the completion script clears cached --options' '
- __gitcomp_builtin checkout &&
- verbose test -n "$__gitcomp_builtin_checkout" &&
- __gitcomp_builtin notes_edit &&
- verbose test -n "$__gitcomp_builtin_notes_edit" &&
- . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&
- verbose test -z "$__gitcomp_builtin_checkout" &&
- verbose test -z "$__gitcomp_builtin_notes_edit"
+ (
+ __gitcomp_builtin checkout &&
+ verbose test -n "$__gitcomp_builtin_checkout" &&
+ __gitcomp_builtin notes_edit &&
+ verbose test -n "$__gitcomp_builtin_notes_edit" &&
+ . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&
+ verbose test -z "$__gitcomp_builtin_checkout" &&
+ verbose test -z "$__gitcomp_builtin_notes_edit"
+ )
'
test_expect_success 'option aliases are not shown by default' '
@@ -2424,12 +2430,14 @@ test_expect_success 'option aliases are not shown by default' '
'
test_expect_success 'option aliases are shown with GIT_COMPLETION_SHOW_ALL' '
- . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&
- GIT_COMPLETION_SHOW_ALL=1 && export GIT_COMPLETION_SHOW_ALL &&
- test_completion "git clone --recurs" <<-\EOF
- --recurse-submodules Z
- --recursive Z
- EOF
+ (
+ . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&
+ GIT_COMPLETION_SHOW_ALL=1 && export GIT_COMPLETION_SHOW_ALL &&
+ test_completion "git clone --recurs" <<-\EOF
+ --recurse-submodules Z
+ --recursive Z
+ EOF
+ )
'
test_expect_success '__git_complete' '
--
2.35.0.913.g12b4baa2536
next prev parent reply other threads:[~2022-02-02 11:15 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-22 8:42 Some sub-commands can't be completed by TAB key Hongyi Zhao
2022-01-22 14:47 ` Johannes Sixt
2022-01-23 0:38 ` Hongyi Zhao
2022-01-23 17:31 ` Philippe Blain
2022-01-23 19:51 ` Junio C Hamano
2022-01-24 1:42 ` Hongyi Zhao
2022-01-24 9:18 ` João Victor Bonfim
2022-01-25 7:33 ` Junio C Hamano
2022-01-25 12:49 ` [PATCH] completion: add a GIT_COMPLETION_SHOW_ALL_COMMANDS Ævar Arnfjörð Bjarmason
2022-01-26 22:34 ` Junio C Hamano
2022-02-02 11:15 ` [PATCH v2 0/2] " Ævar Arnfjörð Bjarmason
2022-02-02 11:15 ` Ævar Arnfjörð Bjarmason [this message]
2022-02-02 11:15 ` [PATCH v2 2/2] " Ævar Arnfjörð Bjarmason
2022-02-06 13:30 ` SZEDER Gábor
2022-02-06 20:09 ` Junio C Hamano
2022-02-06 22:47 ` SZEDER Gábor
2022-02-07 7:03 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=patch-v2-1.2-cf09546e079-20220202T111228Z-avarab@gmail.com \
--to=avarab@gmail.com \
--cc=JoaoVictorBonfim+Git-Mail-List@protonmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=hongyi.zhao@gmail.com \
--cc=levraiphilippeblain@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).