From: Jonathan Nieder <jrnieder@gmail.com>
To: git@vger.kernel.org
Cc: Jakub Narebski <jnareb@gmail.com>, Jeff King <peff@peff.net>,
Thomas Rast <trast@student.ethz.ch>
Subject: [PATCH 1/9] wt-status: split wt_status_print into digestible pieces
Date: Sat, 24 Jul 2010 19:56:26 -0500 [thread overview]
Message-ID: <20100725005626.GA18420@burratino> (raw)
In-Reply-To: <20100725005443.GA18370@burratino>
The result does not fit on a 24-line terminal yet, but it’s
getting close. No functional change intended.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
wt-status.c | 85 ++++++++++++++++++++++++++++++++---------------------------
1 files changed, 46 insertions(+), 39 deletions(-)
diff --git a/wt-status.c b/wt-status.c
index 2f9e33c..b0f17cf 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -604,6 +604,31 @@ static void wt_status_print_verbose(struct wt_status *s)
run_diff_index(&rev, 1);
}
+static void wt_status_print_nochanges(struct wt_status *s)
+{
+ if (s->amend)
+ fprintf(s->fp, "# No changes\n");
+ else if (s->nowarn)
+ ; /* nothing */
+ else if (s->workdir_dirty)
+ printf("no changes added to commit%s\n",
+ advice_status_hints
+ ? " (use \"git add\" and/or \"git commit -a\")" : "");
+ else if (s->untracked.nr)
+ printf("nothing added to commit but untracked files present%s\n",
+ advice_status_hints
+ ? " (use \"git add\" to track)" : "");
+ else if (s->is_initial)
+ printf("nothing to commit%s\n", advice_status_hints
+ ? " (create/copy files and use \"git add\" to track)" : "");
+ else if (!s->show_untracked_files)
+ printf("nothing to commit%s\n", advice_status_hints
+ ? " (use -u to show untracked files)" : "");
+ else
+ printf("nothing to commit%s\n", advice_status_hints
+ ? " (working directory clean)" : "");
+}
+
static void wt_status_print_tracking(struct wt_status *s)
{
struct strbuf sb = STRBUF_INIT;
@@ -623,25 +648,28 @@ static void wt_status_print_tracking(struct wt_status *s)
color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
}
-void wt_status_print(struct wt_status *s)
+static void wt_status_print_onbranch(struct wt_status *s)
{
const char *branch_color = color(WT_STATUS_HEADER, s);
-
- if (s->branch) {
- const char *on_what = "On branch ";
- const char *branch_name = s->branch;
- if (!prefixcmp(branch_name, "refs/heads/"))
- branch_name += 11;
- else if (!strcmp(branch_name, "HEAD")) {
- branch_name = "";
- branch_color = color(WT_STATUS_NOBRANCH, s);
- on_what = "Not currently on any branch.";
- }
- color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "# ");
- color_fprintf_ln(s->fp, branch_color, "%s%s", on_what, branch_name);
- if (!s->is_initial)
- wt_status_print_tracking(s);
+ const char *on_what = "On branch ";
+ const char *branch_name = s->branch;
+ if (!prefixcmp(branch_name, "refs/heads/"))
+ branch_name += 11;
+ else if (!strcmp(branch_name, "HEAD")) {
+ branch_name = "";
+ branch_color = color(WT_STATUS_NOBRANCH, s);
+ on_what = "Not currently on any branch.";
}
+ color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "# ");
+ color_fprintf_ln(s->fp, branch_color, "%s%s", on_what, branch_name);
+ if (!s->is_initial)
+ wt_status_print_tracking(s);
+}
+
+void wt_status_print(struct wt_status *s)
+{
+ if (s->branch)
+ wt_status_print_onbranch(s);
if (s->is_initial) {
color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
@@ -669,29 +697,8 @@ void wt_status_print(struct wt_status *s)
if (s->verbose)
wt_status_print_verbose(s);
- if (!s->commitable) {
- if (s->amend)
- fprintf(s->fp, "# No changes\n");
- else if (s->nowarn)
- ; /* nothing */
- else if (s->workdir_dirty)
- printf("no changes added to commit%s\n",
- advice_status_hints
- ? " (use \"git add\" and/or \"git commit -a\")" : "");
- else if (s->untracked.nr)
- printf("nothing added to commit but untracked files present%s\n",
- advice_status_hints
- ? " (use \"git add\" to track)" : "");
- else if (s->is_initial)
- printf("nothing to commit%s\n", advice_status_hints
- ? " (create/copy files and use \"git add\" to track)" : "");
- else if (!s->show_untracked_files)
- printf("nothing to commit%s\n", advice_status_hints
- ? " (use -u to show untracked files)" : "");
- else
- printf("nothing to commit%s\n", advice_status_hints
- ? " (working directory clean)" : "");
- }
+ if (!s->commitable)
+ wt_status_print_nochanges(s);
}
static void wt_shortstatus_unmerged(int null_termination, struct string_list_item *it,
--
1.7.2.9.ge3789.dirty
next prev parent reply other threads:[~2010-07-25 0:57 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-25 0:54 [RFC/PATCH 0/9] commit: more focused advice in the no-changes-staged case Jonathan Nieder
2010-07-25 0:56 ` Jonathan Nieder [this message]
2010-07-25 0:57 ` [PATCH 2/9] wt-status: split off a function for printing submodule summary Jonathan Nieder
2010-07-25 0:58 ` [PATCH 3/9] commit: split off a function to fetch the default log message Jonathan Nieder
2010-07-25 0:58 ` [PATCH 4/9] commit: split commit -s handling into its own function Jonathan Nieder
2010-07-25 0:59 ` [PATCH 5/9] commit: split off the piece that writes status Jonathan Nieder
2010-07-25 0:59 ` [PATCH 6/9] t7508 (status): modernize style Jonathan Nieder
2010-07-25 8:38 ` Ævar Arnfjörð Bjarmason
2010-07-25 1:00 ` [PATCH 7/9] commit: give empty-commit avoidance code its own function Jonathan Nieder
2010-07-25 1:01 ` [PATCH 8/9] commit --dry-run: give advice on empty amend Jonathan Nieder
2010-07-25 1:02 ` [PATCH 9/9] commit: suppress status summary when no changes staged Jonathan Nieder
2010-08-11 7:11 ` Thomas Rast
2010-08-11 7:30 ` Jonathan Nieder
2010-08-11 7:49 ` [PATCH v2] t6040 (branch tracking): check “status” instead of “commit” Jonathan Nieder
2010-08-12 0:45 ` Ævar Arnfjörð Bjarmason
2010-08-11 12:15 ` [PATCH 9/9] commit: suppress status summary when no changes staged Ævar Arnfjörð Bjarmason
2010-08-11 23:57 ` Jonathan Nieder
2010-08-12 0:05 ` Ævar Arnfjörð Bjarmason
2010-08-12 0:10 ` Jonathan Nieder
2010-07-25 8:54 ` [RFC/PATCH 0/9] commit: more focused advice in the no-changes-staged case Ævar Arnfjörð Bjarmason
2010-07-25 9:22 ` Thomas Rast
2010-07-29 23:51 ` Making error messages stand out (Re: [RFC/PATCH 0/9] commit: more focused advice in the no-changes-staged case) Jonathan Nieder
2010-07-30 18:44 ` Sverre Rabbelier
2010-08-11 8:31 ` [WIP/PATCH 0/4] Re: Making error messages stand out Jonathan Nieder
2010-08-11 8:36 ` [PATCH 1/4] Eliminate “Finished cherry-pick/revert” message Jonathan Nieder
2010-08-11 8:36 ` [PATCH 2/4] Introduce advise() to print hints Jonathan Nieder
2010-08-11 8:37 ` [PATCH 3/4] cherry-pick/revert: Use error() for failure message Jonathan Nieder
2010-08-11 8:37 ` [PATCH 4/4] cherry-pick/revert: Use advise() for hints Jonathan Nieder
2010-08-11 9:21 ` [WIP/PATCH 0/4] Re: Making error messages stand out Nguyen Thai Ngoc Duy
2010-08-11 9:39 ` Matthieu Moy
2010-08-11 9:58 ` Nguyen Thai Ngoc Duy
2010-08-11 17:34 ` Sverre Rabbelier
2010-08-18 14:36 ` [PATCH] tests: fix syntax error in "Use advise() for hints" test Ævar Arnfjörð Bjarmason
2010-08-19 4:30 ` Jonathan Nieder
2010-08-19 12:22 ` Ævar Arnfjörð Bjarmason
2010-08-20 10:13 ` Raja R Harinath
2010-08-20 14:22 ` Ævar Arnfjörð Bjarmason
2010-08-20 17:51 ` Junio C Hamano
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=20100725005626.GA18420@burratino \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=jnareb@gmail.com \
--cc=peff@peff.net \
--cc=trast@student.ethz.ch \
/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;
as well as URLs for NNTP newsgroup(s).