Skip to content

Commit e4cf013

Browse files
dyronegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fe86abd commit e4cf013

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

builtin/commit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
763763
struct commit *c;
764764
c = lookup_commit_reference_by_name(squash_message);
765765
if (!c)
766-
die(_("could not lookup commit %s"), squash_message);
766+
die(_("could not lookup commit '%s'"), squash_message);
767767
ctx.output_encoding = get_commit_output_encoding();
768768
repo_format_commit_message(the_repository, c,
769769
"squash! %s\n\n", &sb,
@@ -798,7 +798,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
798798
char *fmt;
799799
commit = lookup_commit_reference_by_name(fixup_commit);
800800
if (!commit)
801-
die(_("could not lookup commit %s"), fixup_commit);
801+
die(_("could not lookup commit '%s'"), fixup_commit);
802802
ctx.output_encoding = get_commit_output_encoding();
803803
fmt = xstrfmt("%s! %%s\n\n", fixup_prefix);
804804
repo_format_commit_message(the_repository, commit, fmt, &sb,
@@ -1189,7 +1189,7 @@ static const char *read_commit_message(const char *name)
11891189

11901190
commit = lookup_commit_reference_by_name(name);
11911191
if (!commit)
1192-
die(_("could not lookup commit %s"), name);
1192+
die(_("could not lookup commit '%s'"), name);
11931193
out_enc = get_commit_output_encoding();
11941194
return repo_logmsg_reencode(the_repository, commit, NULL, out_enc);
11951195
}

builtin/merge-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ static int real_merge(struct merge_tree_options *o,
448448

449449
base_commit = lookup_commit_reference_by_name(merge_base);
450450
if (!base_commit)
451-
die(_("could not lookup commit %s"), merge_base);
451+
die(_("could not lookup commit '%s'"), merge_base);
452452

453453
opt.ancestor = merge_base;
454454
base_tree = repo_get_commit_tree(the_repository, base_commit);

0 commit comments

Comments
 (0)