Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH v3 3/4] get rid of "git submodule summary --for-status"

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:58:34
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

Matthieu Moy [off-list ref] 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.  How about adding this on top?

 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,
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help