* New checkout --track behaviour? [not found] <DB9PR08MB7194822B81F17420B2D3C149903F2@DB9PR08MB7194.eurprd08.prod.outlook.com> @ 2024-12-12 10:29 ` Francesco Occhipinti 2024-12-13 3:48 ` brian m. carlson 0 siblings, 1 reply; 4+ messages in thread From: Francesco Occhipinti @ 2024-12-12 10:29 UTC (permalink / raw) To: git@vger.kernel.org Hello, Did the interface change in recent git versions? I am pretty sure i used to git checkout -tb new_branch, now getting error: option `--track' expects "direct" or "inherit". User `geirha` on libera#git helped me troubleshooting. They noticed that: - git help checkout differs in its description of --track between 2.34.1 (ubuntu 22.04) and 2.43.0 (ubuntu 24.04), so looks like it did change recently - according to the commit message at https://github.com/git/git/commit/6327f0efed36c64d98a140110171362b7cb75a52, -t is supposed to be equivalent to --track=direct, so likely a bug rather than intentional change I did read all options in `man git config` looking for something related. Found only branch.autoSetupMerge, but neither setting it to `always` nor `inherit` helped Cheers, fran ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: New checkout --track behaviour? 2024-12-12 10:29 ` New checkout --track behaviour? Francesco Occhipinti @ 2024-12-13 3:48 ` brian m. carlson 2024-12-13 10:39 ` Junio C Hamano 2024-12-13 10:50 ` Francesco Occhipinti 0 siblings, 2 replies; 4+ messages in thread From: brian m. carlson @ 2024-12-13 3:48 UTC (permalink / raw) To: Francesco Occhipinti; +Cc: git@vger.kernel.org [-- Attachment #1: Type: text/plain, Size: 1580 bytes --] On 2024-12-12 at 10:29:59, Francesco Occhipinti wrote: > Hello, > > Did the interface change in recent git versions? I am pretty sure i > used to git checkout -tb new_branch, now getting error: option > `--track' expects "direct" or "inherit". > > User `geirha` on libera#git helped me troubleshooting. They noticed that: > > - git help checkout differs in its description of --track between > 2.34.1 (ubuntu 22.04) and 2.43.0 (ubuntu 24.04), so looks like it > did change recently > > - according to the commit message at > https://github.com/git/git/commit/6327f0efed36c64d98a140110171362b7cb75a52, > -t is supposed to be equivalent to --track=direct, so likely a bug > rather than intentional change `-t`, or `--track`, now takes an optional argument. Before, it didn't, so `-tb` was interpreted as `--track -b`. Now, it's interpreted as `--track=b`, since the `b` is interpreted as the option value to `--track`. That's not a valid value, so you get the error message. This is indeed a subtle incompatibility in command-line option parsing, but it's not really avoidable and it does occur in pretty much any case where a short option learns to take an optional argument (for any software, not just Git). So what you probably want to do is `git checkout -t -b new_branch`, and it will work as before. That will also work on older versions as well, so if you have scripts or aliases that need to work across versions, that should be a safe syntax to use. -- brian m. carlson (they/them or he/him) Toronto, Ontario, CA [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 262 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: New checkout --track behaviour? 2024-12-13 3:48 ` brian m. carlson @ 2024-12-13 10:39 ` Junio C Hamano 2024-12-13 10:50 ` Francesco Occhipinti 1 sibling, 0 replies; 4+ messages in thread From: Junio C Hamano @ 2024-12-13 10:39 UTC (permalink / raw) To: brian m. carlson; +Cc: Francesco Occhipinti, git@vger.kernel.org "brian m. carlson" <sandals@crustytoothpaste.net> writes: > This is indeed a subtle incompatibility in command-line option parsing, > but it's not really avoidable and it does occur in pretty much any case > where a short option learns to take an optional argument (for any > software, not just Git). Perhaps we'd want something along this line? While it is not really avoidable if we have to add an optional value to an existing option, "not really avoidable" is not a very satisfactory explanation to please those whose established use cases they have, or their scripts, have got broken. --- >8 ------ >8 ------ >8 --- Subject: gitcli: explain why short options are better spelled separately When the "--track" option of "git checkout" command learned to take an optional value a few years ago at d3115660 (branch: add flags and config to inherit tracking, 2021-12-20), "git checkout -tb foo" got broken, as it is no longer two options "--track" and "--branch=foo" given together, but "--track=b" and a regular argument "foo". The command parser dies upon seeing "-tb" saying "b" is not a valid optional value to "-t". We already discourage users to spell short options in stuck form, and if they spelled "-t -b foo", they would not have noticed this breakage. Add a bit more words to "git help cli" to explain why we discourage the stuck form. We might also want to add a note to ourselves (perhaps next to the Documentation/CodingGuidelines, we'd want design guidelines) to think very carefully before considering to introduce an option that takes an optional value, and refrain from adding an optional value to an existing option. It would save the end users from confusion. Signed-off-by: Junio C Hamano <gitster@pobox.com> --- Documentation/gitcli.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git c/Documentation/gitcli.txt w/Documentation/gitcli.txt index bd62cbd043..dcc0aa5bf7 100644 --- c/Documentation/gitcli.txt +++ w/Documentation/gitcli.txt @@ -82,7 +82,9 @@ Here are the rules regarding the "flags" that you should follow when you are scripting Git: * Splitting short options to separate words (prefer `git foo -a -b` - to `git foo -ab`, the latter may not even work). + to `git foo -ab`, the latter may not even work, and even if it + worked, it will change the meaning once the '-a' option starts + taking an optional value). * When a command-line option takes an argument, use the 'stuck' form. In other words, write `git foo -oArg` instead of `git foo -o Arg` for short ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: New checkout --track behaviour? 2024-12-13 3:48 ` brian m. carlson 2024-12-13 10:39 ` Junio C Hamano @ 2024-12-13 10:50 ` Francesco Occhipinti 1 sibling, 0 replies; 4+ messages in thread From: Francesco Occhipinti @ 2024-12-13 10:50 UTC (permalink / raw) To: brian m. carlson; +Cc: git@vger.kernel.org Yes, that works! Thanks Brian ________________________________________ From: brian m. carlson <sandals@crustytoothpaste.net> Sent: Friday, December 13, 2024 4:48 AM To: Francesco Occhipinti <Francesco.Occhipinti@tracsis.com> Cc: git@vger.kernel.org <git@vger.kernel.org> Subject: Re: New checkout --track behaviour? [You don't often get email from sandals@crustytoothpaste.net. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ] CAUTION: 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. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-12-13 10:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <DB9PR08MB7194822B81F17420B2D3C149903F2@DB9PR08MB7194.eurprd08.prod.outlook.com>
2024-12-12 10:29 ` New checkout --track behaviour? Francesco Occhipinti
2024-12-13 3:48 ` brian m. carlson
2024-12-13 10:39 ` Junio C Hamano
2024-12-13 10:50 ` Francesco Occhipinti
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).