Thread (3 messages) 3 messages, 3 authors, 2022-02-25

Re: [PATCH v2] switch: mention the --detach option when dying due to lack of a branch

From: Alex Henrie <hidden>
Date: 2022-02-25 17:20:23

Possibly related (same subject, not in this thread)

On Fri, Feb 25, 2022 at 4:57 AM Ævar Arnfjörð Bjarmason
[off-list ref] wrote:
On Thu, Feb 24 2022, Junio C Hamano wrote:
quoted
Alex Henrie [off-list ref] writes:
quoted
diff --git a/t/t2060-switch.sh b/t/t2060-switch.sh
index ebb961be29..f54691bac9 100755
--- a/t/t2060-switch.sh
+++ b/t/t2060-switch.sh
@@ -32,6 +32,17 @@ test_expect_success 'switch and detach' '
     test_must_fail git symbolic-ref HEAD
 '

+test_expect_success 'suggestion to detach' '
+    test_must_fail git switch main^{commit} 2>stderr &&
+    test_i18ngrep "try again with the --detach option" stderr
+'
+
+test_expect_success 'suggestion to detach is suppressed with advice.suggestDetachingHead=false' '
+    test_config advice.suggestDetachingHead false &&
+    test_must_fail git switch main^{commit} 2>stderr &&
+    test_i18ngrep ! "try again with the --detach option" stderr
+'
OK, we try to be consistent with other tests in the file, and leave
s/test_i18n// to a file-wide clean-up outside the topic.
FWIW that's not the case here. This is the first use of test_i18ngrep in
this file.

But better to use test_cmp as noted in
[ref] in the sid-thread.
Why is test_cmp preferable to grep in tests like this?

-Alex
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help