Re: [PATCH v3 1/7] merge-ort-wrappers: make printed message match the one from recursive
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 21, 2022, 15:47 UTC
- Message-ID
- <xmqqsfmulb6w.fsf@gitster.g>
- In-Reply-To
- <e39b2e15ece14ba2b1118ae95e0d90ed60589b41.1658391391.git.gitgitgadget@gmail.com>
"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 9 quoted lines
> if (head && repo_index_has_changes(opt->repo, head, &sb)) {
> - fprintf(stderr, _("Your local changes to the following files would be overwritten by merge:\n %s"),
> + struct strbuf err = STRBUF_INIT;
> + strbuf_addstr(&err, "error: ");
> + strbuf_addf(&err, _("Your local changes to the following files would be overwritten by merge:\n %s"),
> sb.buf);
> + strbuf_addch(&err, '\n');
> + fputs(err.buf, stderr);
> + strbuf_release(&err);Makes me wonder why this is not a mere
error(_("Your local chagnes ... by merge:\n %s"), sb.buf);that reuses the exact string. The err() function in merge-recursive.c is strangely complex (and probably buggy---if it is not buffering output, it adds "error: " prefix to opt->obuf before calling vaddf to add the message, and then sends that to error() to give it another "error: " prefix), but all the above does is to send a message to standard error stream.
> strbuf_release(&sb); > return -1; > }