From: Anders Melchiorsen <mail@cup.kalibalik.dk>
To: git@vger.kernel.org
Cc: Anders Melchiorsen <mail@cup.kalibalik.dk>
Subject: [RFC PATCH 1/2] wt-status: Split header generation into three functions
Date: Mon, 8 Sep 2008 00:05:02 +0200 [thread overview]
Message-ID: <1220825103-19599-2-git-send-email-mail@cup.kalibalik.dk> (raw)
In-Reply-To: <1220825103-19599-1-git-send-email-mail@cup.kalibalik.dk>
Reorganize header generation so that all header text related to each
block is in one place.
This adds a function, but makes it easier to see what is generated in
each case. It also allows for easy tweaking of individual headers.
---
wt-status.c | 35 ++++++++++++++++++++---------------
1 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/wt-status.c b/wt-status.c
index 889e50f..ceb3a1e 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -22,12 +22,6 @@ static char wt_status_colors[][COLOR_MAXLEN] = {
"\033[31m", /* WT_STATUS_NOBRANCH: red */
};
-static const char use_add_msg[] =
-"use \"git add <file>...\" to update what will be committed";
-static const char use_add_rm_msg[] =
-"use \"git add/rm <file>...\" to update what will be committed";
-static const char use_add_to_include_msg[] =
-"use \"git add <file>...\" to include in what will be committed";
enum untracked_status_type show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
static int parse_status_slot(const char *var, int offset)
@@ -76,12 +70,24 @@ static void wt_status_print_cached_header(struct wt_status *s)
color_fprintf_ln(s->fp, c, "#");
}
-static void wt_status_print_header(struct wt_status *s,
- const char *main, const char *sub)
+static void wt_status_print_dirty_header(struct wt_status *s,
+ int has_deleted)
{
const char *c = color(WT_STATUS_HEADER);
- color_fprintf_ln(s->fp, c, "# %s:", main);
- color_fprintf_ln(s->fp, c, "# (%s)", sub);
+ color_fprintf_ln(s->fp, c, "# Changed but not updated:");
+ if (!has_deleted) {
+ color_fprintf_ln(s->fp, c, "# (use \"git add <file>...\" to update what will be committed)");
+ } else {
+ color_fprintf_ln(s->fp, c, "# (use \"git add/rm <file>...\" to update what will be committed)");
+ }
+ color_fprintf_ln(s->fp, c, "#");
+}
+
+static void wt_status_print_untracked_header(struct wt_status *s)
+{
+ const char *c = color(WT_STATUS_HEADER);
+ color_fprintf_ln(s->fp, c, "# Untracked files:");
+ color_fprintf_ln(s->fp, c, "# (use \"git add <file>...\" to include in what will be committed)");
color_fprintf_ln(s->fp, c, "#");
}
@@ -166,14 +172,14 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q,
struct wt_status *s = data;
int i;
if (q->nr) {
- const char *msg = use_add_msg;
+ int has_deleted = 0;
s->workdir_dirty = 1;
for (i = 0; i < q->nr; i++)
if (q->queue[i]->status == DIFF_STATUS_DELETED) {
- msg = use_add_rm_msg;
+ has_deleted = 1;
break;
}
- wt_status_print_header(s, "Changed but not updated", msg);
+ wt_status_print_dirty_header(s, has_deleted);
}
for (i = 0; i < q->nr; i++)
wt_status_print_filepair(s, WT_STATUS_CHANGED, q->queue[i]);
@@ -291,8 +297,7 @@ static void wt_status_print_untracked(struct wt_status *s)
}
if (!shown_header) {
s->workdir_untracked = 1;
- wt_status_print_header(s, "Untracked files",
- use_add_to_include_msg);
+ wt_status_print_untracked_header(s);
shown_header = 1;
}
color_fprintf(s->fp, color(WT_STATUS_HEADER), "#\t");
--
1.6.0.1.dirty
next prev parent reply other threads:[~2008-09-07 22:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-07 22:05 [RFC PATCH 0/2] Teach how to discard changes in the working directory Anders Melchiorsen
2008-09-07 22:05 ` Anders Melchiorsen [this message]
2008-09-07 22:05 ` [RFC PATCH 2/2] wt-status: " Anders Melchiorsen
2008-09-07 22:48 ` [RFC PATCH 0/2] " Junio C Hamano
2008-09-07 23:09 ` Pieter de Bie
2008-09-07 23:32 ` 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=1220825103-19599-2-git-send-email-mail@cup.kalibalik.dk \
--to=mail@cup.kalibalik.dk \
--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;
as well as URLs for NNTP newsgroup(s).