surround %s with quotes when failed to lookup commit

The output may become confusing to recognize if the user accidentally gave an extra opening space, like: $ git commit --fixup=" 6d6360b67e99c2fd82d64619c971fdede98ee74b" fatal: could not lookup commit 6d6360b67e99c2fd82d64619c971fdede98ee74b and it will be better if we surround the %s specifier with single quotes. Signed-off-by: Teng Long <dyroneteng@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Teng Long committed May 29, 2023 at 21:27 UTC e4cf01346831ec8f2d4d2bd4d325d2f152259c49
2 files changed +4 -4
builtin/commit.c
+3 -3
@@ -763,7 +763,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
763 struct commit *c;
764 c = lookup_commit_reference_by_name(squash_message);
765 if (!c)
766 - die(_("could not lookup commit %s"), squash_message);
766 + die(_("could not lookup commit '%s'"), squash_message);
767 ctx.output_encoding = get_commit_output_encoding();
768 repo_format_commit_message(the_repository, c,
769 "squash! %s\n\n", &sb,
@@ -798,7 +798,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
798 char *fmt;
799 commit = lookup_commit_reference_by_name(fixup_commit);
800 if (!commit)
801 - die(_("could not lookup commit %s"), fixup_commit);
801 + die(_("could not lookup commit '%s'"), fixup_commit);
802 ctx.output_encoding = get_commit_output_encoding();
803 fmt = xstrfmt("%s! %%s\n\n", fixup_prefix);
804 repo_format_commit_message(the_repository, commit, fmt, &sb,
@@ -1189,7 +1189,7 @@ static const char *read_commit_message(const char *name)
1189
1190 commit = lookup_commit_reference_by_name(name);
1191 if (!commit)
1192 - die(_("could not lookup commit %s"), name);
1192 + die(_("could not lookup commit '%s'"), name);
1193 out_enc = get_commit_output_encoding();
1194 return repo_logmsg_reencode(the_repository, commit, NULL, out_enc);
1195 }
builtin/merge-tree.c
+1 -1
@@ -448,7 +448,7 @@ static int real_merge(struct merge_tree_options *o,
448
449 base_commit = lookup_commit_reference_by_name(merge_base);
450 if (!base_commit)
451 - die(_("could not lookup commit %s"), merge_base);
451 + die(_("could not lookup commit '%s'"), merge_base);
452
453 opt.ancestor = merge_base;
454 base_tree = repo_get_commit_tree(the_repository, base_commit);