git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 2/4] builtin-status: submodule summary support

From
Ping Yin <pkufranky@gmail.com>
Date
Mar 13, 2008, 13:48 UTC
Message-ID
<1205416085-23431-3-git-send-email-pkufranky@gmail.com>
In-Reply-To
<1205416085-23431-2-git-send-email-pkufranky@gmail.com>

This commit teaches 'git commit/status' show 'Modified submodules' section given by 'git submodule summary --cached --for-status' just before 'Untracked files' section.

Signed-off-by: Ping Yin <pkufranky@gmail.com>
---
 wt-status.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/wt-status.c b/wt-status.c
index 701d13d..75ee7ba 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -8,6 +8,7 @@
 #include "revision.h"
 #include "diffcore.h"
 #include "quote.h"
+#include "run-command.h"
 
 int wt_status_relative_paths = 1;
 int wt_status_use_color = -1;
@@ -219,6 +220,30 @@ static void wt_status_print_changed(struct wt_status *s)
 	rev.diffopt.format_callback_data = s;
 	run_diff_files(&rev, 0);
 }
+static void wt_status_print_submodule_summary(struct wt_status *s)
+{
+	struct child_process sm_summary;
+	const char *argv[] = {
+		"submodule",
+		"summary",
+		"--cached",
+		"--for-status",
+		s->amend ? "HEAD^" : "HEAD",
+		NULL
+	};
+	char index[PATH_MAX];
+	const char *env[2] = { index, NULL };
+	snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", s->index_file);
+
+	memset(&sm_summary, 0, sizeof(sm_summary));
+	sm_summary.argv = argv;
+	sm_summary.env = env;
+	sm_summary.git_cmd = 1;
+	sm_summary.no_stdin = 1;
+	fflush(s->fp);
+	sm_summary.out = dup(fileno(s->fp));    /* run_command closes it */
+	run_command(&sm_summary);
+}
 
 static void wt_status_print_untracked(struct wt_status *s)
 {
@@ -321,6 +346,9 @@ void wt_status_print(struct wt_status *s)
 	}
 
 	wt_status_print_changed(s);
+	// must flush s->fp since following call will write to s->fp in a child process
+	fflush(s->fp);
+	wt_status_print_submodule_summary(s);
 	wt_status_print_untracked(s);
 
 	if (s->verbose && !s->is_initial)
-- 
1.5.4.3.347.g5314c
Previous: Ping YinNext: Ping Yin
Message 3 of 15 in “builtin-status submodule summary”
  1. Ping YinMar 13, 2008
  2. 1/4 git-submodule summary: --for-status optionPing Yin, Mar 13, 2008
  3. 2/4 builtin-status: submodule summary supportPing Yin, Mar 13, 2008
  4. 3/4 builtin-status: configurable submodule summary sizePing Yin, Mar 13, 2008
  5. 4/4 buitin-status: Add tests for submodule summaryPing Yin, Mar 13, 2008
  6. Johannes SixtMar 13, 2008
  7. Junio C HamanoMar 13, 2008
  8. Ping YinMar 13, 2008
  9. Ping YinMar 13, 2008
  10. Johannes SixtMar 13, 2008
  11. Johannes SixtMar 13, 2008
  12. Ping YinMar 13, 2008
  13. Ping YinMar 14, 2008
  14. Junio C HamanoMar 14, 2008
  15. Ping YinMar 14, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.