{"thread":{"id":"64661","subject":"[BUG] git restore: typo in error message \"could not resolve ource\"","startedAt":"2025-12-22T09:16:46Z","lastAt":"2025-12-24T23:44:01Z","messageCount":5,"participants":["Zhelyo Zhelev","brian m. carlson","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"532614","messageId":"CAMxgZ8KqU9BUJ6T7DLct3CaEh9EYdcMO=dBAMPyQsb=knekSuQ@mail.gmail.com","threadId":"64661","inReplyTo":null,"subject":"[BUG] git restore: typo in error message \"could not resolve ource\"","fromName":"Zhelyo Zhelev","fromEmail":"zhelyo@gmail.com","sentAt":"2025-12-22T09:16:07Z","receivedAt":"2025-12-22T09:16:46Z","isPatch":false,"sender":{"key":"zhelyo@gmail.com","avatar":null},"body":"Thank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\nI executed the following command in repository: git restore -source\nmy_base_branch\nI have reproduced this on both Windows (git version 2.52.0.windows.1)\nand Ubuntu (git version 2.52.0).\n\nWhat did you expect to happen? (Expected behavior)\nThe error message should be:\nfatal: could not resolve source\n\nWhat happened instead? (Actual behavior)\nThe error message is:\nfatal: could not resolve ource\n\nWhat's different between what you expected and what actually happened?\nThere is a typo in the displayed error message - the first letter 's'\nis missing from the word \"source\" in the output.\n\nAnything else you want to add:\nThe bug is present in the latest stable version 2.52.0 on both Linux\nand Windows.\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.52.0.windows.1\ncpu: x86_64\nbuilt from commit: 2912d8e9b8253723974b7baf1c890273b1a1c5bd\nsizeof-long: 4\nsizeof-size_t: 8\nshell-path: D:/git-sdk-64-build-installers/usr/bin/sh\nrust: disabled\nfeature: fsmonitor--daemon\nlibcurl: 8.17.0\nOpenSSL: OpenSSL 3.5.4 30 Sep 2025\nzlib: 1.3.1\nSHA-1: SHA1_DC\nSHA-256: SHA256_BLK\ndefault-ref-format: files\ndefault-hash: sha1\nuname: Windows 10.0 26100\ncompiler info: gnuc: 15.2\nlibc info: no libc information available\n$SHELL (typically, interactive shell): <unset>\n\n\n[Enabled Hooks]\n"},{"id":"532616","messageId":"aUkx2XYCP75GrCsS@fruit.crustytoothpaste.net","threadId":"64661","inReplyTo":"CAMxgZ8KqU9BUJ6T7DLct3CaEh9EYdcMO=dBAMPyQsb=knekSuQ@mail.gmail.com","subject":"Re: [BUG] git restore: typo in error message \"could not resolve ource\"","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2025-12-22T11:56:09Z","receivedAt":"2025-12-22T11:56:17Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2025-12-22 at 09:16:07, Zhelyo Zhelev wrote:\n> Thank you for filling out a Git bug report!\n> Please answer the following questions to help us understand your issue.\n> \n> What did you do before the bug happened? (Steps to reproduce your issue)\n> I executed the following command in repository: git restore -source\n> my_base_branch\n> I have reproduced this on both Windows (git version 2.52.0.windows.1)\n> and Ubuntu (git version 2.52.0).\n\nI can also reproduce this using Git 2.51.0.338.gd7d06c2dae8 on Debian\nunstable.\n\n> What did you expect to happen? (Expected behavior)\n> The error message should be:\n> fatal: could not resolve source\n> \n> What happened instead? (Actual behavior)\n> The error message is:\n> fatal: could not resolve ource\n> \n> What's different between what you expected and what actually happened?\n> There is a typo in the displayed error message - the first letter 's'\n> is missing from the word \"source\" in the output.\n\nI think this is due to a typo in your command and I'll explain why it\nhappens.\n\nYou wrote `git restore -source`, not `git restore --source`.  Most\nprograms use double dashes for long options, including Git.  Part of the\nreason the second dash is necessary is that `-source` is interpreted as\n`-s ource`, or the equivalent of `--source=ource`.  Git was confused\nbecause `ource` didn't match any revision it could check out and\nobviously that's because you didn't intend that at all.\n\nSo I think this is functioning as designed and isn't actually a typo in\nGit.  The code appears to be in `builtin/checkout.c`:\n\n    builtin/checkout.c:                     die(_(\"could not resolve %s\"), opts->from_treeish);\n\nThat shows that it prints \"could not resolve\" and then the thing it\ntried to resolve as a branch.\n-- \nbrian m. carlson (they/them)\nToronto, Ontario, CA\n"},{"id":"532617","messageId":"xmqqbjjqslgq.fsf@gitster.g","threadId":"64661","inReplyTo":"aUkx2XYCP75GrCsS@fruit.crustytoothpaste.net","subject":"Re: [BUG] git restore: typo in error message \"could not resolve ource\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-12-22T13:19:17Z","receivedAt":"2025-12-22T13:19:19Z","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> So I think this is functioning as designed and isn't actually a typo in\n> Git.  The code appears to be in `builtin/checkout.c`:\n>\n>     builtin/checkout.c:                     die(_(\"could not resolve %s\"), opts->from_treeish);\n>\n> That shows that it prints \"could not resolve\" and then the thing it\n> tried to resolve as a branch.\n\nHilarious.\n\nWe probably should give a pair of quotes around '%s' like other\nmessages, and that is what CodingGuidelines asks us to do.  In the\nsection of \"Error Messages\", we find this.\n\n - Enclose the subject of an error inside a pair of single quotes,\n   e.g. `die(_(\"unable to open '%s'\"), path)`.\n\nThanks.\n"},{"id":"532725","messageId":"20251224203253.881129-1-sandals@crustytoothpaste.net","threadId":"64661","inReplyTo":"xmqqbjjqslgq.fsf@gitster.g","subject":"[PATCH] checkout: quote invalid treeish in error message","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2025-12-24T20:32:53Z","receivedAt":"2025-12-24T20:33:20Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"We received a report that invoking \"git restore -source my_base_branch\"\nresulted in the confusing error message \"fatal: could not resolve\nource\".  This looked like a typo in our error message, but it is\nactually because \"-source\" is missing its second dash and is being\nresolved as \"-s ource\".  However, due to the lack of the quoting\nrecommended in CodingGuidelines, this is confusing to the reader and\nwe can do better.\n\nAdd the necessary quoting to this message.  With this change, we now get\nthis less confusing message:\n\n    fatal: could not resolve 'ource'\n\nReported-by: Zhelyo Zhelev <zhelyo@gmail.com>\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/checkout.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 66b69df6e6..261699e2f5 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -1899,7 +1899,7 @@ static int checkout_main(int argc, const char **argv, const char *prefix,\n \t\tstruct object_id rev;\n \n \t\tif (repo_get_oid_mb(the_repository, opts->from_treeish, &rev))\n-\t\t\tdie(_(\"could not resolve %s\"), opts->from_treeish);\n+\t\t\tdie(_(\"could not resolve '%s'\"), opts->from_treeish);\n \n \t\tsetup_new_branch_info_and_source_tree(&new_branch_info,\n \t\t\t\t\t\t      opts, &rev,\n"},{"id":"532733","messageId":"xmqqecojo37l.fsf@gitster.g","threadId":"64661","inReplyTo":"20251224203253.881129-1-sandals@crustytoothpaste.net","subject":"Re: [PATCH] checkout: quote invalid treeish in error message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-12-24T23:43:58Z","receivedAt":"2025-12-24T23:44:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n\n> We received a report that invoking \"git restore -source my_base_branch\"\n> resulted in the confusing error message \"fatal: could not resolve\n> ource\".  This looked like a typo in our error message, but it is\n> actually because \"-source\" is missing its second dash and is being\n> resolved as \"-s ource\".  However, due to the lack of the quoting\n> recommended in CodingGuidelines, this is confusing to the reader and\n> we can do better.\n>\n> Add the necessary quoting to this message.  With this change, we now get\n> this less confusing message:\n>\n>     fatal: could not resolve 'ource'\n>\n> Reported-by: Zhelyo Zhelev <zhelyo@gmail.com>\n> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n> ---\n>  builtin/checkout.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n\nObviously the right thing to do.  Thanks.\n\n>\n> diff --git a/builtin/checkout.c b/builtin/checkout.c\n> index 66b69df6e6..261699e2f5 100644\n> --- a/builtin/checkout.c\n> +++ b/builtin/checkout.c\n> @@ -1899,7 +1899,7 @@ static int checkout_main(int argc, const char **argv, const char *prefix,\n>  \t\tstruct object_id rev;\n>  \n>  \t\tif (repo_get_oid_mb(the_repository, opts->from_treeish, &rev))\n> -\t\t\tdie(_(\"could not resolve %s\"), opts->from_treeish);\n> +\t\t\tdie(_(\"could not resolve '%s'\"), opts->from_treeish);\n>  \n>  \t\tsetup_new_branch_info_and_source_tree(&new_branch_info,\n>  \t\t\t\t\t\t      opts, &rev,\n"}]}