{"thread":{"id":"43791","subject":"[PATCHv2] checkout: do not mention detach advice for explicit --detach option","startedAt":"2016-08-12T00:30:00Z","lastAt":"2016-08-12T07:49:23Z","messageCount":2,"participants":["Stefan Beller","Remi Galan Alfonso"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"298813","messageId":"20160812002947.1582-1-sbeller@google.com","threadId":"43791","inReplyTo":null,"subject":"[PATCHv2] checkout: do not mention detach advice for explicit --detach option","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-08-12T00:29:47Z","receivedAt":"2016-08-12T00:30:00Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"When a user asked for a detached HEAD specifically with `--detach`,\nwe do not need to give advice on what a detached HEAD state entails as\nwe can assume they know what they're getting into as they asked for it.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n \n jrnieder wrote:\n > Examples?\n \n What do you mean by example?\n  \n builtin/checkout.c         |  2 +-\n t/t2020-checkout-detach.sh | 13 +++++++++++++\n 2 files changed, 14 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 8d852d4..85408b1 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -658,7 +658,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,\n \t\tupdate_ref(msg.buf, \"HEAD\", new->commit->object.oid.hash, NULL,\n \t\t\t   REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);\n \t\tif (!opts->quiet) {\n-\t\t\tif (old->path && advice_detached_head)\n+\t\t\tif (old->path && advice_detached_head && !opts->force_detach)\n \t\t\t\tdetach_advice(new->name);\n \t\t\tdescribe_detached_head(_(\"HEAD is now at\"), new->commit);\n \t\t}\ndiff --git a/t/t2020-checkout-detach.sh b/t/t2020-checkout-detach.sh\nindex 5d68729..941ea49 100755\n--- a/t/t2020-checkout-detach.sh\n+++ b/t/t2020-checkout-detach.sh\n@@ -163,4 +163,17 @@ test_expect_success 'tracking count is accurate after orphan check' '\n \ttest_i18ncmp expect stdout\n '\n \n+test_expect_success 'no advice given for explicit detached head state' '\n+\tgit config advice.detachedHead false &&\n+\tgit checkout child &&\n+\tgit checkout --detach HEAD >expect &&\n+\tgit config advice.detachedHead true &&\n+\tgit checkout child &&\n+\tgit checkout --detach HEAD >actual &&\n+\ttest_cmp expect actual &&\n+\tgit checkout child &&\n+\tgit checkout HEAD >actual &&\n+\t! test_cmp expect actual\n+'\n+\n test_done\n-- \n2.9.2.730.g46b112d\n\n"},{"id":"298832","messageId":"2038600423.1215501.1470989378002.JavaMail.zimbra@ensimag.grenoble-inp.fr","threadId":"43791","inReplyTo":"20160812002947.1582-1-sbeller@google.com","subject":"Re: [PATCHv2] checkout: do not mention detach advice for explicit --detach option","fromName":"Remi Galan Alfonso","fromEmail":"remi.galan-alfonso@ensimag.grenoble-inp.fr","sentAt":"2016-08-12T08:09:38Z","receivedAt":"2016-08-12T07:49:23Z","isPatch":false,"sender":{"key":"remi.galan-alfonso@ensimag.grenoble-inp.fr","avatar":"https://avatars.githubusercontent.com/u/12509162?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n> +test_expect_success 'no advice given for explicit detached head state' '\n> +        git config advice.detachedHead false &&\n> +        git checkout child &&\n> +        git checkout --detach HEAD >expect &&\n> +        git config advice.detachedHead true &&\n\nIs there a reason for not unsetting `advice.detachedHead` at the\nend of the test?\n\nThanks,\nRémi\n"}]}