{"thread":{"id":"62630","subject":"New checkout --track behaviour?","startedAt":"2024-12-12T10:30:02Z","lastAt":"2024-12-13T10:50:31Z","messageCount":4,"participants":["Francesco Occhipinti","brian m. carlson","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"509023","messageId":"DB9PR08MB71949D21F5F0E81911F0D50F903F2@DB9PR08MB7194.eurprd08.prod.outlook.com","threadId":"62630","inReplyTo":"DB9PR08MB7194822B81F17420B2D3C149903F2@DB9PR08MB7194.eurprd08.prod.outlook.com","subject":"New checkout --track behaviour?","fromName":"Francesco Occhipinti","fromEmail":"francesco.occhipinti@tracsis.com","sentAt":"2024-12-12T10:29:59Z","receivedAt":"2024-12-12T10:30:02Z","isPatch":false,"sender":{"key":"francesco.occhipinti@tracsis.com","avatar":null},"body":"Hello,\n\nDid the interface change in recent git versions? I am pretty sure i\nused to git checkout -tb new_branch, now getting error: option\n`--track' expects \"direct\" or \"inherit\".\n\nUser `geirha` on libera#git helped me troubleshooting. They noticed that:\n\n- git help checkout differs in its description of --track between\n  2.34.1 (ubuntu 22.04) and 2.43.0 (ubuntu 24.04), so looks like it\n  did change recently\n\n- according to the commit message at\n  https://github.com/git/git/commit/6327f0efed36c64d98a140110171362b7cb75a52,\n  -t is supposed to be equivalent to --track=direct, so likely a bug\n  rather than intentional change\n\nI did read all options in `man git config` looking for something\nrelated. Found only branch.autoSetupMerge, but neither setting it to\n`always` nor `inherit` helped\n\nCheers,\nfran\n"},{"id":"509041","messageId":"Z1uuqKI_2rb0HXhP@tapette.crustytoothpaste.net","threadId":"62630","inReplyTo":"DB9PR08MB71949D21F5F0E81911F0D50F903F2@DB9PR08MB7194.eurprd08.prod.outlook.com","subject":"Re: New checkout --track behaviour?","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2024-12-13T03:48:56Z","receivedAt":"2024-12-13T03:49:01Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2024-12-12 at 10:29:59, Francesco Occhipinti wrote:\n> Hello,\n> \n> Did the interface change in recent git versions? I am pretty sure i\n> used to git checkout -tb new_branch, now getting error: option\n> `--track' expects \"direct\" or \"inherit\".\n> \n> User `geirha` on libera#git helped me troubleshooting. They noticed that:\n> \n> - git help checkout differs in its description of --track between\n>   2.34.1 (ubuntu 22.04) and 2.43.0 (ubuntu 24.04), so looks like it\n>   did change recently\n> \n> - according to the commit message at\n>   https://github.com/git/git/commit/6327f0efed36c64d98a140110171362b7cb75a52,\n>   -t is supposed to be equivalent to --track=direct, so likely a bug\n>   rather than intentional change\n\n`-t`, or `--track`, now takes an optional argument.  Before, it didn't,\nso `-tb` was interpreted as `--track -b`.  Now, it's interpreted as\n`--track=b`, since the `b` is interpreted as the option value to\n`--track`.  That's not a valid value, so you get the error message.\n\nThis is indeed a subtle incompatibility in command-line option parsing,\nbut it's not really avoidable and it does occur in pretty much any case\nwhere a short option learns to take an optional argument (for any\nsoftware, not just Git).  So what you probably want to do is `git\ncheckout -t -b new_branch`, and it will work as before.  That will also\nwork on older versions as well, so if you have scripts or aliases that\nneed to work across versions, that should be a safe syntax to use.\n-- \nbrian m. carlson (they/them or he/him)\nToronto, Ontario, CA\n"},{"id":"509078","messageId":"xmqqed2beujw.fsf@gitster.g","threadId":"62630","inReplyTo":"Z1uuqKI_2rb0HXhP@tapette.crustytoothpaste.net","subject":"Re: New checkout --track behaviour?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-12-13T10:39:15Z","receivedAt":"2024-12-13T10:39:17Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n\n> This is indeed a subtle incompatibility in command-line option parsing,\n> but it's not really avoidable and it does occur in pretty much any case\n> where a short option learns to take an optional argument (for any\n> software, not just Git).\n\nPerhaps we'd want something along this line?  While it is not really\navoidable if we have to add an optional value to an existing option,\n\"not really avoidable\" is not a very satisfactory explanation to\nplease those whose established use cases they have, or their\nscripts, have got broken.\n\n--- >8 ------ >8 ------ >8 ---\nSubject: gitcli: explain why short options are better spelled separately\n\nWhen the \"--track\" option of \"git checkout\" command learned to take\nan optional value a few years ago at d3115660 (branch: add flags and\nconfig to inherit tracking, 2021-12-20), \"git checkout -tb foo\" got\nbroken, as it is no longer two options \"--track\" and \"--branch=foo\"\ngiven together, but \"--track=b\" and a regular argument \"foo\".  The\ncommand parser dies upon seeing \"-tb\" saying \"b\" is not a valid\noptional value to \"-t\".\n\nWe already discourage users to spell short options in stuck form,\nand if they spelled \"-t -b foo\", they would not have noticed this\nbreakage.  Add a bit more words to \"git help cli\" to explain why\nwe discourage the stuck form.\n\nWe might also want to add a note to ourselves (perhaps next to the\nDocumentation/CodingGuidelines, we'd want design guidelines) to\nthink very carefully before considering to introduce an option that\ntakes an optional value, and refrain from adding an optional value\nto an existing option.  It would save the end users from confusion.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/gitcli.txt | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git c/Documentation/gitcli.txt w/Documentation/gitcli.txt\nindex bd62cbd043..dcc0aa5bf7 100644\n--- c/Documentation/gitcli.txt\n+++ w/Documentation/gitcli.txt\n@@ -82,7 +82,9 @@ Here are the rules regarding the \"flags\" that you should follow when you are\n scripting Git:\n \n  * Splitting short options to separate words (prefer `git foo -a -b`\n-   to `git foo -ab`, the latter may not even work).\n+   to `git foo -ab`, the latter may not even work, and even if it\n+   worked, it will change the meaning once the '-a' option starts\n+   taking an optional value).\n \n  * When a command-line option takes an argument, use the 'stuck' form.  In\n    other words, write `git foo -oArg` instead of `git foo -o Arg` for short\n"},{"id":"509091","messageId":"DB9PR08MB7194FF8C95C92AF26E1B8F1F90382@DB9PR08MB7194.eurprd08.prod.outlook.com","threadId":"62630","inReplyTo":"Z1uuqKI_2rb0HXhP@tapette.crustytoothpaste.net","subject":"Re: New checkout --track behaviour?","fromName":"Francesco Occhipinti","fromEmail":"francesco.occhipinti@tracsis.com","sentAt":"2024-12-13T10:50:27Z","receivedAt":"2024-12-13T10:50:31Z","isPatch":false,"sender":{"key":"francesco.occhipinti@tracsis.com","avatar":null},"body":"Yes, that works! Thanks Brian\n\n________________________________________\nFrom: brian m. carlson <sandals@crustytoothpaste.net>\nSent: Friday, December 13, 2024 4:48 AM\nTo: Francesco Occhipinti <Francesco.Occhipinti@tracsis.com>\nCc: git@vger.kernel.org <git@vger.kernel.org>\nSubject: Re: New checkout --track behaviour?\n \n[You don't often get email from sandals@crustytoothpaste.net. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]\n\nCAUTION: This email originated from outside of the organisation. Do not click links or open attachments unless you recognise the sender and know the content is safe.\n"}]}