* [PATCH v1 0/1] surround %s with quotes when failed to lookup commit @ 2023-05-29 13:27 Teng Long 2023-05-29 13:27 ` [PATCH v1 1/1] " Teng Long 0 siblings, 1 reply; 4+ messages in thread From: Teng Long @ 2023-05-29 13:27 UTC (permalink / raw) To: git; +Cc: tenglong.tl, Teng Long From: Teng Long <dyroneteng@gmail.com> When lookup commit fails, wrap quotes around %s format specifier. Do we have to put a "<topic>": or "<filename>:" before the commit title, such as this patch, which modifies two different features, how should we name it appropriately. Thanks. Teng Long (1): surround %s with quotes when failed to lookup commit builtin/commit.c | 6 +++--- builtin/merge-tree.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) -- 2.41.0.rc2 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v1 1/1] surround %s with quotes when failed to lookup commit 2023-05-29 13:27 [PATCH v1 0/1] surround %s with quotes when failed to lookup commit Teng Long @ 2023-05-29 13:27 ` Teng Long 2023-06-03 0:00 ` Junio C Hamano 2023-06-03 0:11 ` Junio C Hamano 0 siblings, 2 replies; 4+ messages in thread From: Teng Long @ 2023-05-29 13:27 UTC (permalink / raw) To: git; +Cc: tenglong.tl, Teng Long From: Teng Long <dyroneteng@gmail.com> The output maybe become confused to recognize if the user accidentally mistook 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> --- builtin/commit.c | 6 +++--- builtin/merge-tree.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin/commit.c b/builtin/commit.c index e67c4be2..9ab57ea1 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -763,7 +763,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, struct commit *c; c = lookup_commit_reference_by_name(squash_message); if (!c) - die(_("could not lookup commit %s"), squash_message); + die(_("could not lookup commit '%s'"), squash_message); ctx.output_encoding = get_commit_output_encoding(); repo_format_commit_message(the_repository, c, "squash! %s\n\n", &sb, @@ -798,7 +798,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, char *fmt; commit = lookup_commit_reference_by_name(fixup_commit); if (!commit) - die(_("could not lookup commit %s"), fixup_commit); + die(_("could not lookup commit '%s'"), fixup_commit); ctx.output_encoding = get_commit_output_encoding(); fmt = xstrfmt("%s! %%s\n\n", fixup_prefix); repo_format_commit_message(the_repository, commit, fmt, &sb, @@ -1189,7 +1189,7 @@ static const char *read_commit_message(const char *name) commit = lookup_commit_reference_by_name(name); if (!commit) - die(_("could not lookup commit %s"), name); + die(_("could not lookup commit '%s'"), name); out_enc = get_commit_output_encoding(); return repo_logmsg_reencode(the_repository, commit, NULL, out_enc); } diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c index b8f8a8b5..4325897a 100644 --- a/builtin/merge-tree.c +++ b/builtin/merge-tree.c @@ -448,7 +448,7 @@ static int real_merge(struct merge_tree_options *o, base_commit = lookup_commit_reference_by_name(merge_base); if (!base_commit) - die(_("could not lookup commit %s"), merge_base); + die(_("could not lookup commit '%s'"), merge_base); opt.ancestor = merge_base; base_tree = repo_get_commit_tree(the_repository, base_commit); -- 2.41.0.rc2 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v1 1/1] surround %s with quotes when failed to lookup commit 2023-05-29 13:27 ` [PATCH v1 1/1] " Teng Long @ 2023-06-03 0:00 ` Junio C Hamano 2023-06-03 0:11 ` Junio C Hamano 1 sibling, 0 replies; 4+ messages in thread From: Junio C Hamano @ 2023-06-03 0:00 UTC (permalink / raw) To: Teng Long; +Cc: git, tenglong.tl Teng Long <dyroneteng@gmail.com> writes: > From: Teng Long <dyroneteng@gmail.com> > > The output maybe become confused to recognize if the user Probably "may become confusing to". > accidentally mistook an extra opening space, like: > > $git commit --fixup=" 6d6360b67e99c2fd82d64619c971fdede98ee74b" > fatal: could not lookup commit 6d6360b67e99c2fd82d64619c971fdede98ee74b I'd prefer a space between the prompt "$" and the command "git". > > and it will be better if we surround the %s specifier with single quotes. Indeed. Everything else in the message I am responding to, I am 100% happy with. Will queue with manual fixups. Thanks. > Signed-off-by: Teng Long <dyroneteng@gmail.com> > --- > builtin/commit.c | 6 +++--- > builtin/merge-tree.c | 2 +- > 2 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/builtin/commit.c b/builtin/commit.c > index e67c4be2..9ab57ea1 100644 > --- a/builtin/commit.c > +++ b/builtin/commit.c > @@ -763,7 +763,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, > struct commit *c; > c = lookup_commit_reference_by_name(squash_message); > if (!c) > - die(_("could not lookup commit %s"), squash_message); > + die(_("could not lookup commit '%s'"), squash_message); > ctx.output_encoding = get_commit_output_encoding(); > repo_format_commit_message(the_repository, c, > "squash! %s\n\n", &sb, > @@ -798,7 +798,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, > char *fmt; > commit = lookup_commit_reference_by_name(fixup_commit); > if (!commit) > - die(_("could not lookup commit %s"), fixup_commit); > + die(_("could not lookup commit '%s'"), fixup_commit); > ctx.output_encoding = get_commit_output_encoding(); > fmt = xstrfmt("%s! %%s\n\n", fixup_prefix); > repo_format_commit_message(the_repository, commit, fmt, &sb, > @@ -1189,7 +1189,7 @@ static const char *read_commit_message(const char *name) > > commit = lookup_commit_reference_by_name(name); > if (!commit) > - die(_("could not lookup commit %s"), name); > + die(_("could not lookup commit '%s'"), name); > out_enc = get_commit_output_encoding(); > return repo_logmsg_reencode(the_repository, commit, NULL, out_enc); > } > diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c > index b8f8a8b5..4325897a 100644 > --- a/builtin/merge-tree.c > +++ b/builtin/merge-tree.c > @@ -448,7 +448,7 @@ static int real_merge(struct merge_tree_options *o, > > base_commit = lookup_commit_reference_by_name(merge_base); > if (!base_commit) > - die(_("could not lookup commit %s"), merge_base); > + die(_("could not lookup commit '%s'"), merge_base); > > opt.ancestor = merge_base; > base_tree = repo_get_commit_tree(the_repository, base_commit); ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1 1/1] surround %s with quotes when failed to lookup commit 2023-05-29 13:27 ` [PATCH v1 1/1] " Teng Long 2023-06-03 0:00 ` Junio C Hamano @ 2023-06-03 0:11 ` Junio C Hamano 1 sibling, 0 replies; 4+ messages in thread From: Junio C Hamano @ 2023-06-03 0:11 UTC (permalink / raw) To: Teng Long; +Cc: git, tenglong.tl Teng Long <dyroneteng@gmail.com> writes: > From: Teng Long <dyroneteng@gmail.com> > > The output maybe become confused to recognize if the user > accidentally mistook 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. The only remaining hits from $ git grep -e '_("[^('\'']%s' (that is, "find the messages that has %s without a single quote or an opening parenthesis immediately before it") are found in builtin/remote.c where this template const char *dangling_msg = dry_run ? _(" %s will become dangling!") : _(" %s has become dangling!"); is given to the refs.c::warn_dangling_symrefs() API function to be used to show refs found by the system to be dangling. It can be argued that these are better quoted for consistency, but I tend to side with the current code, as there is much less risk (than the cases you fixed in your patch) for ambiguity and confusion there. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-03 0:11 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-05-29 13:27 [PATCH v1 0/1] surround %s with quotes when failed to lookup commit Teng Long 2023-05-29 13:27 ` [PATCH v1 1/1] " Teng Long 2023-06-03 0:00 ` Junio C Hamano 2023-06-03 0:11 ` Junio C Hamano
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).