@@ -72,6 +72,15 @@ static int use_editor = 1, initial_commit, in_merge;
72
72
static const char * only_include_assumed ;
73
73
static struct strbuf message ;
74
74
75
+ static int null_termination ;
76
+ static enum {
77
+ STATUS_FORMAT_LONG ,
78
+ STATUS_FORMAT_SHORT ,
79
+ STATUS_FORMAT_PORCELAIN ,
80
+ } status_format = STATUS_FORMAT_LONG ;
81
+
82
+ static void short_print (struct wt_status * s , int null_termination );
83
+
75
84
static int opt_parse_m (const struct option * opt , const char * arg , int unset )
76
85
{
77
86
struct strbuf * buf = opt -> value ;
@@ -105,6 +114,12 @@ static struct option builtin_commit_options[] = {
105
114
OPT_BOOLEAN ('o' , "only" , & only , "commit only specified files" ),
106
115
OPT_BOOLEAN ('n' , "no-verify" , & no_verify , "bypass pre-commit hook" ),
107
116
OPT_BOOLEAN (0 , "dry-run" , & dry_run , "show what would be committed" ),
117
+ OPT_SET_INT (0 , "short" , & status_format , "show status concisely" ,
118
+ STATUS_FORMAT_SHORT ),
119
+ OPT_SET_INT (0 , "porcelain" , & status_format ,
120
+ "show porcelain output format" , STATUS_FORMAT_PORCELAIN ),
121
+ OPT_BOOLEAN ('z' , "null" , & null_termination ,
122
+ "terminate entries with NUL" ),
108
123
OPT_BOOLEAN (0 , "amend" , & amend , "amend previous commit" ),
109
124
{ OPTION_STRING , 'u' , "untracked-files" , & untracked_files_arg , "mode" , "show untracked files, optional modes: all, normal, no. (Default: all)" , PARSE_OPT_OPTARG , NULL , (intptr_t )"all" },
110
125
OPT_BOOLEAN (0 , "allow-empty" , & allow_empty , "ok to record an empty change" ),
@@ -363,7 +378,18 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int
363
378
s -> is_initial = get_sha1 (s -> reference , sha1 ) ? 1 : 0 ;
364
379
365
380
wt_status_collect (s );
366
- wt_status_print (s );
381
+
382
+ switch (status_format ) {
383
+ case STATUS_FORMAT_SHORT :
384
+ short_print (s , null_termination );
385
+ break ;
386
+ case STATUS_FORMAT_PORCELAIN :
387
+ short_print (s , null_termination );
388
+ break ;
389
+ case STATUS_FORMAT_LONG :
390
+ wt_status_print (s );
391
+ break ;
392
+ }
367
393
368
394
return s -> commitable ;
369
395
}
@@ -821,6 +847,11 @@ static int parse_and_validate_options(int argc, const char *argv[],
821
847
else if (interactive && argc > 0 )
822
848
die ("Paths with --interactive does not make sense." );
823
849
850
+ if (null_termination && status_format == STATUS_FORMAT_LONG )
851
+ status_format = STATUS_FORMAT_PORCELAIN ;
852
+ if (status_format != STATUS_FORMAT_LONG )
853
+ dry_run = 1 ;
854
+
824
855
return argc ;
825
856
}
826
857
@@ -991,12 +1022,6 @@ static void short_print(struct wt_status *s, int null_termination)
991
1022
int cmd_status (int argc , const char * * argv , const char * prefix )
992
1023
{
993
1024
struct wt_status s ;
994
- static int null_termination ;
995
- static enum {
996
- STATUS_FORMAT_LONG ,
997
- STATUS_FORMAT_SHORT ,
998
- STATUS_FORMAT_PORCELAIN ,
999
- } status_format = STATUS_FORMAT_LONG ;
1000
1025
unsigned char sha1 [20 ];
1001
1026
static struct option builtin_status_options [] = {
1002
1027
OPT__VERBOSE (& verbose ),
0 commit comments