git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] builtin-status: submodule summary support
@ 2008-03-12  2:21 Ping Yin
  2008-03-12  2:21 ` [PATCH 2/3] builtin-status: configurable submodule summary size Ping Yin
  2008-03-12  7:33 ` [PATCH 1/3] builtin-status: submodule summary support Johannes Sixt
  0 siblings, 2 replies; 6+ messages in thread
From: Ping Yin @ 2008-03-12  2:21 UTC (permalink / raw)
  To: git; +Cc: gitster, Ping Yin

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 |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/wt-status.c b/wt-status.c
index 701d13d..6d36e54 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,33 @@ 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",
+		"--summary-limit",
+		summary_limit,
+		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 */
+	sm_summary.no_stderr = 1;
+	run_command(&sm_summary);
+}
 
 static void wt_status_print_untracked(struct wt_status *s)
 {
@@ -321,6 +349,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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-03-13 13:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-12  2:21 [PATCH 1/3] builtin-status: submodule summary support Ping Yin
2008-03-12  2:21 ` [PATCH 2/3] builtin-status: configurable submodule summary size Ping Yin
2008-03-12  2:21   ` [PATCH 3/3] buitin-status: Add tests for submodule summary Ping Yin
2008-03-12  7:38     ` Johannes Sixt
2008-03-12  7:33 ` [PATCH 1/3] builtin-status: submodule summary support Johannes Sixt
2008-03-13 13:05   ` Ping Yin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).