Skip to content

Commit eeb2535

Browse files
committed
Merge branch 'nd/status-long'
Allow an earlier "--short" option on the command line to be countermanded with the "--long" option for "git status" and "git commit". * nd/status-long: status: add --long output format option
2 parents deb2458 + f3f47a1 commit eeb2535

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

Documentation/git-commit.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ OPTIONS
109109
format. See linkgit:git-status[1] for details. Implies
110110
`--dry-run`.
111111

112+
--long::
113+
When doing a dry-run, give the output in a the long-format.
114+
Implies `--dry-run`.
115+
112116
-z::
113117
--null::
114118
When showing `short` or `porcelain` status output, terminate

Documentation/git-status.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ OPTIONS
3838
across git versions and regardless of user configuration. See
3939
below for details.
4040

41+
--long::
42+
Give the output in the long-format. This is the default.
43+
4144
-u[<mode>]::
4245
--untracked-files[=<mode>]::
4346
Show untracked files.

builtin/commit.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,11 @@ static const char *only_include_assumed;
112112
static struct strbuf message = STRBUF_INIT;
113113

114114
static enum {
115+
STATUS_FORMAT_NONE = 0,
115116
STATUS_FORMAT_LONG,
116117
STATUS_FORMAT_SHORT,
117118
STATUS_FORMAT_PORCELAIN
118-
} status_format = STATUS_FORMAT_LONG;
119+
} status_format;
119120

120121
static int opt_parse_m(const struct option *opt, const char *arg, int unset)
121122
{
@@ -454,6 +455,7 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int
454455
case STATUS_FORMAT_PORCELAIN:
455456
wt_porcelain_print(s);
456457
break;
458+
case STATUS_FORMAT_NONE:
457459
case STATUS_FORMAT_LONG:
458460
wt_status_print(s);
459461
break;
@@ -1058,9 +1060,13 @@ static int parse_and_validate_options(int argc, const char *argv[],
10581060
if (all && argc > 0)
10591061
die(_("Paths with -a does not make sense."));
10601062

1061-
if (s->null_termination && status_format == STATUS_FORMAT_LONG)
1062-
status_format = STATUS_FORMAT_PORCELAIN;
1063-
if (status_format != STATUS_FORMAT_LONG)
1063+
if (s->null_termination) {
1064+
if (status_format == STATUS_FORMAT_NONE)
1065+
status_format = STATUS_FORMAT_PORCELAIN;
1066+
else if (status_format == STATUS_FORMAT_LONG)
1067+
die(_("--long and -z are incompatible"));
1068+
}
1069+
if (status_format != STATUS_FORMAT_NONE)
10641070
dry_run = 1;
10651071

10661072
return argc;
@@ -1159,6 +1165,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)
11591165
OPT_SET_INT(0, "porcelain", &status_format,
11601166
N_("machine-readable output"),
11611167
STATUS_FORMAT_PORCELAIN),
1168+
OPT_SET_INT(0, "long", &status_format,
1169+
N_("show status in long format (default)"),
1170+
STATUS_FORMAT_LONG),
11621171
OPT_BOOLEAN('z', "null", &s.null_termination,
11631172
N_("terminate entries with NUL")),
11641173
{ OPTION_STRING, 'u', "untracked-files", &untracked_files_arg,
@@ -1186,8 +1195,12 @@ int cmd_status(int argc, const char **argv, const char *prefix)
11861195
builtin_status_usage, 0);
11871196
finalize_colopts(&s.colopts, -1);
11881197

1189-
if (s.null_termination && status_format == STATUS_FORMAT_LONG)
1190-
status_format = STATUS_FORMAT_PORCELAIN;
1198+
if (s.null_termination) {
1199+
if (status_format == STATUS_FORMAT_NONE)
1200+
status_format = STATUS_FORMAT_PORCELAIN;
1201+
else if (status_format == STATUS_FORMAT_LONG)
1202+
die(_("--long and -z are incompatible"));
1203+
}
11911204

11921205
handle_untracked_files_arg(&s);
11931206
if (show_ignored_in_status)
@@ -1216,6 +1229,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
12161229
case STATUS_FORMAT_PORCELAIN:
12171230
wt_porcelain_print(&s);
12181231
break;
1232+
case STATUS_FORMAT_NONE:
12191233
case STATUS_FORMAT_LONG:
12201234
s.verbose = verbose;
12211235
s.ignore_submodule_arg = ignore_submodule_arg;
@@ -1386,6 +1400,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
13861400
OPT_BOOLEAN(0, "branch", &s.show_branch, N_("show branch information")),
13871401
OPT_SET_INT(0, "porcelain", &status_format,
13881402
N_("machine-readable output"), STATUS_FORMAT_PORCELAIN),
1403+
OPT_SET_INT(0, "long", &status_format,
1404+
N_("show status in long format (default)"),
1405+
STATUS_FORMAT_LONG),
13891406
OPT_BOOLEAN('z', "null", &s.null_termination,
13901407
N_("terminate entries with NUL")),
13911408
OPT_BOOLEAN(0, "amend", &amend, N_("amend previous commit")),

0 commit comments

Comments
 (0)