]> git.ipfire.org Git - thirdparty/git.git/commitdiff
checkout: quote invalid treeish in error message
authorbrian m. carlson <sandals@crustytoothpaste.net>
Wed, 24 Dec 2025 20:32:53 +0000 (20:32 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 24 Dec 2025 23:27:22 +0000 (08:27 +0900)
We received a report that invoking "git restore -source my_base_branch"
resulted in the confusing error message "fatal: could not resolve
ource".  This looked like a typo in our error message, but it is
actually because "-source" is missing its second dash and is being
resolved as "-s ource".  However, due to the lack of the quoting
recommended in CodingGuidelines, this is confusing to the reader and
we can do better.

Add the necessary quoting to this message.  With this change, we now get
this less confusing message:

    fatal: could not resolve 'ource'

Reported-by: Zhelyo Zhelev <zhelyo@gmail.com>
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/checkout.c

index 01ea9ff8b28022d718fa1368ac7144c8d9b4a1a3..afec07534ffbb7cfd52cd78acbb2f4f2fbab2be7 100644 (file)
@@ -1875,7 +1875,7 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
                struct object_id rev;
 
                if (repo_get_oid_mb(the_repository, opts->from_treeish, &rev))
-                       die(_("could not resolve %s"), opts->from_treeish);
+                       die(_("could not resolve '%s'"), opts->from_treeish);
 
                setup_new_branch_info_and_source_tree(&new_branch_info,
                                                      opts, &rev,