From: Jeff King <peff@peff.net>
To: David Aguilar <davvid@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>, Johannes Sixt <j6t@kdbg.org>,
bill lam <cbill.lam@gmail.com>, git <git@vger.kernel.org>
Subject: [PATCH/RFC 3/6] status: refactor short-mode printing to its own function
Date: Sat, 5 Sep 2009 04:53:48 -0400 [thread overview]
Message-ID: <20090905085348.GC13157@coredump.intra.peff.net> (raw)
In-Reply-To: <20090905084809.GA13073@coredump.intra.peff.net>
We want to be able to call it from multiple places.
Signed-off-by: Jeff King <peff@peff.net>
---
I am tempted to move all of the short-printing code to its own file, and
move "cmd_status" to its own builtin-status.c, as well. I don't know if
that is a cleanup that makes sense to others, as well, or if it is too
much churn for too little good.
builtin-commit.c | 45 +++++++++++++++++++++++++--------------------
1 files changed, 25 insertions(+), 20 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index 812470e..5b42179 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -966,11 +966,32 @@ static void short_untracked(int null_termination, struct string_list_item *it,
}
}
+static void short_print(struct wt_status *s, int null_termination)
+{
+ int i;
+ for (i = 0; i < s->change.nr; i++) {
+ struct wt_status_change_data *d;
+ struct string_list_item *it;
+
+ it = &(s->change.items[i]);
+ d = it->util;
+ if (d->stagemask)
+ short_unmerged(null_termination, it, s);
+ else
+ short_status(null_termination, it, s);
+ }
+ for (i = 0; i < s->untracked.nr; i++) {
+ struct string_list_item *it;
+
+ it = &(s->untracked.items[i]);
+ short_untracked(null_termination, it, s);
+ }
+}
+
int cmd_status(int argc, const char **argv, const char *prefix)
{
struct wt_status s;
static int null_termination, shortstatus;
- int i;
unsigned char sha1[20];
static struct option builtin_status_options[] = {
OPT__VERBOSE(&verbose),
@@ -1003,25 +1024,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)
s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;
wt_status_collect(&s);
- if (shortstatus) {
- for (i = 0; i < s.change.nr; i++) {
- struct wt_status_change_data *d;
- struct string_list_item *it;
-
- it = &(s.change.items[i]);
- d = it->util;
- if (d->stagemask)
- short_unmerged(null_termination, it, &s);
- else
- short_status(null_termination, it, &s);
- }
- for (i = 0; i < s.untracked.nr; i++) {
- struct string_list_item *it;
-
- it = &(s.untracked.items[i]);
- short_untracked(null_termination, it, &s);
- }
- } else {
+ if (shortstatus)
+ short_print(&s, null_termination);
+ else {
s.verbose = verbose;
if (s.relative_paths)
s.prefix = prefix;
--
1.6.4.2.418.g1a1d3.dirty
next prev parent reply other threads:[~2009-09-05 8:53 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-01 14:52 unmerged files listed in the beginning of git-status bill lam
2009-09-01 16:42 ` Junio C Hamano
2009-09-01 19:40 ` Johannes Sixt
2009-09-01 20:13 ` [PATCH] status: list unmerged files after staged files Johannes Sixt
2009-09-01 20:38 ` Junio C Hamano
2009-09-01 21:25 ` [PATCH v2] status: list unmerged files last Johannes Sixt
2009-09-02 0:18 ` Junio C Hamano
2009-09-02 0:39 ` bill lam
2009-09-02 1:15 ` Jeff King
2009-09-02 4:26 ` Junio C Hamano
2009-09-02 5:12 ` Jeff King
2009-09-02 5:26 ` Junio C Hamano
2009-09-02 5:28 ` Jeff King
2009-09-02 10:07 ` David Aguilar
2009-09-02 17:59 ` Jeff King
2009-09-03 1:12 ` David Aguilar
2009-09-05 6:28 ` Jeff King
2009-09-05 8:48 ` Jeff King
2009-09-05 8:50 ` [PATCH/RFC 1/6] status: typo fix in usage Jeff King
2009-09-05 8:52 ` [PATCH/RFC 2/6] docs: note that status configuration affects only long format Jeff King
2009-09-06 8:04 ` Junio C Hamano
2009-09-05 8:53 ` Jeff King [this message]
2009-09-06 8:05 ` [PATCH/RFC 3/6] status: refactor short-mode printing to its own function Junio C Hamano
2009-09-05 8:54 ` [PATCH/RFC 4/6] status: refactor format option parsing Jeff King
2009-09-05 8:55 ` [PATCH/RFC 5/6] status: add --porcelain output format Jeff King
2009-09-05 8:59 ` [PATCH/RFC 6/6] commit: support alternate status formats Jeff King
2009-09-05 9:08 ` [PATCH v2] status: list unmerged files last Jeff King
2009-09-02 19:19 ` Johannes Sixt
2009-09-02 12:48 ` Mark Brown
2009-09-02 18:00 ` Jeff King
2009-09-02 18:39 ` Mark Brown
2009-09-05 9:04 ` Jeff King
2009-09-05 11:39 ` Mark Brown
2009-09-02 9:04 ` unmerged files listed in the beginning of git-status bill lam
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=20090905085348.GC13157@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=cbill.lam@gmail.com \
--cc=davvid@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j6t@kdbg.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).