Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
status: refactor format option parsing
author
Jeff King
<peff@peff.net>
Sat, 5 Sep 2009 08:54:14 +0000
(
04:54
-0400)
committer
Junio C Hamano
<gitster@pobox.com>
Sun, 6 Sep 2009 06:16:27 +0000
(23:16 -0700)
This makes it possible to have more than two formats.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-commit.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
01d8ba1
)
diff --git
a/builtin-commit.c
b/builtin-commit.c
index 5b42179fe7499f80871b09593068eeb6e96c75b1..aa4a3587990c73a2359f33aaab10529789a9e58a 100644
(file)
--- a/
builtin-commit.c
+++ b/
builtin-commit.c
@@
-991,12
+991,16
@@
static void short_print(struct wt_status *s, int null_termination)
int cmd_status(int argc, const char **argv, const char *prefix)
{
struct wt_status s;
int cmd_status(int argc, const char **argv, const char *prefix)
{
struct wt_status s;
- static int null_termination, shortstatus;
+ static int null_termination;
+ static enum {
+ STATUS_FORMAT_LONG,
+ STATUS_FORMAT_SHORT,
+ } status_format = STATUS_FORMAT_LONG;
unsigned char sha1[20];
static struct option builtin_status_options[] = {
OPT__VERBOSE(&verbose),
unsigned char sha1[20];
static struct option builtin_status_options[] = {
OPT__VERBOSE(&verbose),
- OPT_
BOOLEAN('s', "short", &shortstatus
,
- "show status concisely"),
+ OPT_
SET_INT('s', "short", &status_format
,
+ "show status concisely"
, STATUS_FORMAT_SHORT
),
OPT_BOOLEAN('z', "null", &null_termination,
"terminate entries with NUL"),
{ OPTION_STRING, 'u', "untracked-files", &untracked_files_arg,
OPT_BOOLEAN('z', "null", &null_termination,
"terminate entries with NUL"),
{ OPTION_STRING, 'u', "untracked-files", &untracked_files_arg,
@@
-1006,8
+1010,8
@@
int cmd_status(int argc, const char **argv, const char *prefix)
OPT_END(),
};
OPT_END(),
};
- if (null_termination)
- s
hortstatus = 1
;
+ if (null_termination
&& status_format == STATUS_FORMAT_LONG
)
+ s
tatus_format = STATUS_FORMAT_SHORT
;
wt_status_prepare(&s);
git_config(git_status_config, &s);
wt_status_prepare(&s);
git_config(git_status_config, &s);
@@
-1024,9
+1028,11
@@
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);
s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;
wt_status_collect(&s);
- if (shortstatus)
+ switch (status_format) {
+ case STATUS_FORMAT_SHORT:
short_print(&s, null_termination);
short_print(&s, null_termination);
- else {
+ break;
+ case STATUS_FORMAT_LONG:
s.verbose = verbose;
if (s.relative_paths)
s.prefix = prefix;
s.verbose = verbose;
if (s.relative_paths)
s.prefix = prefix;
@@
-1035,6
+1041,7
@@
int cmd_status(int argc, const char **argv, const char *prefix)
if (diff_use_color_default == -1)
diff_use_color_default = git_use_color_default;
wt_status_print(&s);
if (diff_use_color_default == -1)
diff_use_color_default = git_use_color_default;
wt_status_print(&s);
+ break;
}
return 0;
}
}
return 0;
}