Thread (2 messages) 2 messages, 2 authors, 2025-12-22

Re: [BUG] git restore: typo in error message "could not resolve ource"

From: brian m. carlson <hidden>
Date: 2025-12-22 11:56:17

On 2025-12-22 at 09:16:07, Zhelyo Zhelev wrote:
Thank you for filling out a Git bug report!
Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue)
I executed the following command in repository: git restore -source
my_base_branch
I have reproduced this on both Windows (git version 2.52.0.windows.1)
and Ubuntu (git version 2.52.0).
I can also reproduce this using Git 2.51.0.338.gd7d06c2dae8 on Debian
unstable.
What did you expect to happen? (Expected behavior)
The error message should be:
fatal: could not resolve source

What happened instead? (Actual behavior)
The error message is:
fatal: could not resolve ource

What's different between what you expected and what actually happened?
There is a typo in the displayed error message - the first letter 's'
is missing from the word "source" in the output.
I think this is due to a typo in your command and I'll explain why it
happens.

You wrote `git restore -source`, not `git restore --source`.  Most
programs use double dashes for long options, including Git.  Part of the
reason the second dash is necessary is that `-source` is interpreted as
`-s ource`, or the equivalent of `--source=ource`.  Git was confused
because `ource` didn't match any revision it could check out and
obviously that's because you didn't intend that at all.

So I think this is functioning as designed and isn't actually a typo in
Git.  The code appears to be in `builtin/checkout.c`:

    builtin/checkout.c:                     die(_("could not resolve %s"), opts->from_treeish);

That shows that it prints "could not resolve" and then the thing it
tried to resolve as a branch.
-- 
brian m. carlson (they/them)
Toronto, Ontario, CA

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help