diff options
author | Matthieu Moy <Matthieu.Moy@imag.fr> | 2013-09-06 19:43:06 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-09-06 13:33:18 -0700 |
commit | 3ba7407b8b7b7a75f720641327207d6cfdb163a2 (patch) | |
tree | 7e234f6f8a8257f2861754357500b444c3a18972 /wt-status.c | |
parent | bb7e32e383d66c290d11174108b2944532905df6 (diff) | |
download | git-3ba7407b8b7b7a75f720641327207d6cfdb163a2.tar.gz |
submodule summary: ignore --for-status option
The --for-status option was an undocumented option used only by
wt-status.c, which inserted a header and commented out the output. We can
achieve the same result within wt-status.c, without polluting the
submodule command-line options.
This will make it easier to disable the comments from wt-status.c later.
The --for-status is kept so that another topic in flight
(bc/submodule-status-ignored) can continue relying on it, although it is
currently a no-op.
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wt-status.c')
-rw-r--r-- | wt-status.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/wt-status.c b/wt-status.c index 958a53c9cb..853813f560 100644 --- a/wt-status.c +++ b/wt-status.c @@ -665,6 +665,10 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt char index[PATH_MAX]; const char *env[] = { NULL, NULL }; struct argv_array argv = ARGV_ARRAY_INIT; + struct strbuf cmd_stdout = STRBUF_INIT; + struct strbuf summary = STRBUF_INIT; + char *summary_content; + size_t len; sprintf(summary_limit, "%d", s->submodule_summary); snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", s->index_file); @@ -685,9 +689,30 @@ static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitt sm_summary.git_cmd = 1; sm_summary.no_stdin = 1; fflush(s->fp); - sm_summary.out = dup(fileno(s->fp)); /* run_command closes it */ + sm_summary.out = -1; + run_command(&sm_summary); argv_array_clear(&argv); + + len = strbuf_read(&cmd_stdout, sm_summary.out, 1024); + + /* 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); + + fputs(summary.buf, s->fp); + strbuf_release(&summary); } static void wt_status_print_other(struct wt_status *s, |