From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 5/9] git stat: show traditional status headers and trailers as well
Date: Sat, 15 Aug 2009 15:39:53 -0700 [thread overview]
Message-ID: <1250375997-10657-6-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1250375997-10657-5-git-send-email-gitster@pobox.com>
Also honor -v to show the "diff --cached" output.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
* Fix-up to 3/9; will be squashed in the final round to remove the trace
of ill conceived wt_status_print_body() refactoring.
builtin-commit.c | 8 +++++++-
wt-status.c | 27 +++++++++------------------
wt-status.h | 1 -
3 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index 7120876..8db0365 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -352,6 +352,8 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
static int run_status(FILE *fp, const char *index_file, const char *prefix, int nowarn,
struct wt_status *s)
{
+ unsigned char sha1[20];
+
if (s->relative_paths)
s->prefix = prefix;
@@ -363,7 +365,9 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int
s->index_file = index_file;
s->fp = fp;
s->nowarn = nowarn;
+ s->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;
+ wt_status_collect(s);
wt_status_print(s);
return s->commitable;
@@ -903,6 +907,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix)
struct wt_status s;
unsigned char sha1[20];
static struct option builtin_stat_options[] = {
+ OPT__VERBOSE(&verbose),
{ OPTION_STRING, 'u', "untracked-files", &untracked_files_arg,
"mode",
"show untracked files, optional modes: all, normal, no. (Default: all)",
@@ -922,13 +927,14 @@ int cmd_stat(int argc, const char **argv, const char *prefix)
s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;
wt_status_collect(&s);
+ s.verbose = verbose;
if (s.relative_paths)
s.prefix = prefix;
if (s.use_color == -1)
s.use_color = git_use_color_default;
if (diff_use_color_default == -1)
diff_use_color_default = git_use_color_default;
- wt_status_print_body(&s);
+ wt_status_print(&s);
return 0;
}
diff --git a/wt-status.c b/wt-status.c
index c887a90..c55be53 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -531,25 +531,10 @@ static void wt_status_print_tracking(struct wt_status *s)
color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
}
-void wt_status_print_body(struct wt_status *s)
-{
- wt_status_print_unmerged(s);
- wt_status_print_updated(s);
- wt_status_print_changed(s);
- if (s->submodule_summary)
- wt_status_print_submodule_summary(s);
- if (s->show_untracked_files)
- wt_status_print_untracked(s);
- else if (s->commitable)
- fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n");
-}
-
void wt_status_print(struct wt_status *s)
{
- unsigned char sha1[20];
const char *branch_color = color(WT_STATUS_HEADER, s);
- s->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;
if (s->branch) {
const char *on_what = "On branch ";
const char *branch_name = s->branch;
@@ -566,15 +551,21 @@ void wt_status_print(struct wt_status *s)
wt_status_print_tracking(s);
}
- wt_status_collect(s);
-
if (s->is_initial) {
color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "# Initial commit");
color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
}
- wt_status_print_body(s);
+ wt_status_print_unmerged(s);
+ wt_status_print_updated(s);
+ wt_status_print_changed(s);
+ if (s->submodule_summary)
+ wt_status_print_submodule_summary(s);
+ if (s->show_untracked_files)
+ wt_status_print_untracked(s);
+ else if (s->commitable)
+ fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n");
if (s->verbose)
wt_status_print_verbose(s);
diff --git a/wt-status.h b/wt-status.h
index ab52ce1..a0e7517 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -54,6 +54,5 @@ struct wt_status {
void wt_status_prepare(struct wt_status *s);
void wt_status_print(struct wt_status *s);
void wt_status_collect(struct wt_status *s);
-void wt_status_print_body(struct wt_status *s);
#endif /* STATUS_H */
--
1.6.4.224.g3be84
next prev parent reply other threads:[~2009-08-15 22:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-15 22:39 [PATCH 0/9] "git status" that is not "git commit --dry-run" Junio C Hamano
2009-08-15 22:39 ` [PATCH 1/9] Documentation/git-commit.txt: describe --dry-run Junio C Hamano
2009-08-15 22:39 ` [PATCH 2/9] git commit --dry-run -v: show diff in color when asked Junio C Hamano
2009-08-15 22:39 ` [PATCH 3/9] git stat: the beginning Junio C Hamano
2009-08-15 22:39 ` [PATCH 4/9] git stat: honor relative paths setting Junio C Hamano
2009-08-15 22:39 ` Junio C Hamano [this message]
2009-08-15 22:39 ` [PATCH 6/9] git stat: pathspec limits, unlike traditional "git status" Junio C Hamano
2009-08-15 22:39 ` [PATCH 7/9] git stat -s: short status output Junio C Hamano
2009-08-15 22:39 ` [PATCH 8/9] git status: not "commit --dry-run" anymore Junio C Hamano
2009-08-15 22:39 ` [PATCH 9/9] git-status: adjust tests Junio C Hamano
2009-08-17 8:57 ` [PATCH 8/9] git status: not "commit --dry-run" anymore Thomas Rast
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1250375997-10657-6-git-send-email-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox