{"thread":{"id":"53689","subject":"git switch error message tweak","startedAt":"2020-06-16T06:47:25Z","lastAt":"2020-06-17T20:30:43Z","messageCount":2,"participants":["Ed Avis","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"399846","messageId":"BL0PR11MB34603334FD8AF4B662A74C3A9D9D0@BL0PR11MB3460.namprd11.prod.outlook.com","threadId":"53689","inReplyTo":null,"subject":"git switch error message tweak","fromName":"Ed Avis","fromEmail":"ed.avis@qmaw.com","sentAt":"2020-06-16T06:47:03Z","receivedAt":"2020-06-16T06:47:25Z","isPatch":false,"sender":{"key":"ed.avis@qmaw.com","avatar":null},"body":"To help those migrating from 'git checkout' to the newer 'git switch'\nand 'git restore', this error message could be improved:\n\n% git switch baa022666d26a5d40e86c0b6349eb7435033e80a\nfatal: a branch is expected, got commit 'baa022666d26a5d40e86c0b6349eb7435033e80a'\n\nIt could print additionally\n\nTo switch to this commit in 'detached HEAD' mode, use --detach.\n\nas long as it was indeed a commit that was given.\n\nI note also that while git checkout prints a spiel about \"You are in\n'detached HEAD' state\", git switch --detach does not.  Was this\ndeliberate, on the assumption that if you pass --detach you know what\nyou are doing?  I think it might be better to honour the\nadvice.detachedHead setting the same way for both checkout and switch.\n\nThanks for considering this request, and apologies if this is something already discussed and decided.\n\n-- \nEd Avis <ed.avis@qmaw.com>"},{"id":"400000","messageId":"xmqq8sgltoyb.fsf@gitster.c.googlers.com","threadId":"53689","inReplyTo":"BL0PR11MB34603334FD8AF4B662A74C3A9D9D0@BL0PR11MB3460.namprd11.prod.outlook.com","subject":"Re: git switch error message tweak","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-06-17T20:30:36Z","receivedAt":"2020-06-17T20:30:43Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ed Avis <ed.avis@qmaw.com> writes:\n\n> To help those migrating from 'git checkout' to the newer 'git switch'\n> and 'git restore', this error message could be improved:\n>\n> % git switch baa022666d26a5d40e86c0b6349eb7435033e80a\n> fatal: a branch is expected, got commit 'baa022666d26a5d40e86c0b6349eb7435033e80a'\n>\n> It could print additionally\n>\n> To switch to this commit in 'detached HEAD' mode, use --detach.\n>\n> as long as it was indeed a commit that was given.\n\nExcellent.\n\n> I note also that while git checkout prints a spiel about \"You are in\n> 'detached HEAD' state\", git switch --detach does not. Was this\n> deliberate, on the assumption that if you pass --detach you know what\n> you are doing?\n\nI'd say you are correct---one who passes \"--detach\" knows enough to\nwant to be in the detached HEAD state and knows enough that the\nstate is nothing to be worried about.\n"}]}