diff --git a/advice.c b/advice.c index 567209aa79..b224825637 100644 --- a/advice.c +++ b/advice.c @@ -191,13 +191,22 @@ void NORETURN die_conclude_merge(void) void detach_advice(const char *new_name) { const char *fmt = - _("Note: checking out '%s'.\n\n" + _("Note: checking out '%s'.\n" + "\n" "You are in 'detached HEAD' state. You can look around, make experimental\n" "changes and commit them, and you can discard any commits you make in this\n" - "state without impacting any branches by performing another checkout.\n\n" + "state without impacting any branches by performing another checkout.\n" + "\n" "If you want to create a new branch to retain commits you create, you may\n" - "do so (now or later) by using -b with the checkout command again. Example:\n\n" - " git checkout -b \n\n"); + "do so (now or later) by using -b with the checkout command again. Example:\n" + "\n" + " git checkout -b \n" + "\n" + "Or undo this checkout with:\n" + "\n" + " git checkout -\n" + "\n" + "Turn off this advice by setting config variable advice.detachedHead to false\n\n"); fprintf(stderr, fmt, new_name); } diff --git a/t/t2020-checkout-detach.sh b/t/t2020-checkout-detach.sh index 1fa670625c..743c7248a2 100755 --- a/t/t2020-checkout-detach.sh +++ b/t/t2020-checkout-detach.sh @@ -206,6 +206,12 @@ test_expect_success 'describe_detached_head prints no SHA-1 ellipsis when not as git checkout -b + Or undo this checkout with: + + git checkout - + + Turn off this advice by setting config variable advice.detachedHead to false + HEAD is now at \$commit three EOF @@ -282,6 +288,12 @@ test_expect_success 'describe_detached_head does print SHA-1 ellipsis when asked git checkout -b + Or undo this checkout with: + + git checkout - + + Turn off this advice by setting config variable advice.detachedHead to false + HEAD is now at \$commit... three EOF