Re: [PATCH v3 3/4] get rid of "git submodule summary --for-status"
Junio C Hamano <gitster@pobox.com> writes:
Show 22 quoted lines
> Matthieu Moy <Matthieu.Moy@imag.fr> writes:
>
>> + /* prepend header, only if there's an actual output */
>> + if (len) {
>> + if (uncommitted)
>> + strbuf_addstr(&summary, _("Submodules changed but not updated:"));
>> + else
>> + strbuf_addstr(&summary, _("Submodule changes to be committed:"));
>> + strbuf_addstr(&summary, "\n\n");
>> + }
>> + strbuf_addbuf(&summary, &cmd_stdout);
>> + strbuf_release(&cmd_stdout);
>> +
>> + summary_content = strbuf_detach(&summary, &len);
>> + strbuf_add_commented_lines(&summary, summary_content, len);
>> + free(summary_content);
>> +
>> + summary_content = strbuf_detach(&summary, &len);
>> + fprintf(s->fp, summary_content);
>> + free(summary_content);
>
> This "fprintf()" looks bogus to me.Oops, indeed. I forgot the "%s".
> How about adding this on top?
Your solution is better, yes.
Show 19 quoted lines
> wt-status.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/wt-status.c b/wt-status.c
> index d91661d..1f17652 100644
> --- a/wt-status.c
> +++ b/wt-status.c
> @@ -710,9 +710,8 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt
> strbuf_add_commented_lines(&summary, summary_content, len);
> free(summary_content);
>
> - summary_content = strbuf_detach(&summary, &len);
> - fprintf(s->fp, summary_content);
> - free(summary_content);
> + fputs(summary.buf, s->fp);
> + strbuf_release(&summary);
> }
>
> static void wt_status_print_other(struct wt_status *s,
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/