@@ -72,6 +72,15 @@ static int use_editor = 1, initial_commit, in_merge;
7272static const char * only_include_assumed ;
7373static struct strbuf message ;
7474
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+
7584static int opt_parse_m (const struct option * opt , const char * arg , int unset )
7685{
7786 struct strbuf * buf = opt -> value ;
@@ -105,6 +114,12 @@ static struct option builtin_commit_options[] = {
105114 OPT_BOOLEAN ('o' , "only" , & only , "commit only specified files" ),
106115 OPT_BOOLEAN ('n' , "no-verify" , & no_verify , "bypass pre-commit hook" ),
107116 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" ),
108123 OPT_BOOLEAN (0 , "amend" , & amend , "amend previous commit" ),
109124 { 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" },
110125 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
363378 s -> is_initial = get_sha1 (s -> reference , sha1 ) ? 1 : 0 ;
364379
365380 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+ }
367393
368394 return s -> commitable ;
369395}
@@ -821,6 +847,11 @@ static int parse_and_validate_options(int argc, const char *argv[],
821847 else if (interactive && argc > 0 )
822848 die ("Paths with --interactive does not make sense." );
823849
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+
824855 return argc ;
825856}
826857
@@ -991,12 +1022,6 @@ static void short_print(struct wt_status *s, int null_termination)
9911022int cmd_status (int argc , const char * * argv , const char * prefix )
9921023{
9931024 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 ;
10001025 unsigned char sha1 [20 ];
10011026 static struct option builtin_status_options [] = {
10021027 OPT__VERBOSE (& verbose ),
0 commit comments