@@ -112,12 +112,14 @@ static int show_ignored_in_status, have_option_m;
112
112
static const char * only_include_assumed ;
113
113
static struct strbuf message = STRBUF_INIT ;
114
114
115
- static enum {
115
+ static enum status_format {
116
116
STATUS_FORMAT_NONE = 0 ,
117
117
STATUS_FORMAT_LONG ,
118
118
STATUS_FORMAT_SHORT ,
119
- STATUS_FORMAT_PORCELAIN
120
- } status_format ;
119
+ STATUS_FORMAT_PORCELAIN ,
120
+
121
+ STATUS_FORMAT_UNSPECIFIED
122
+ } status_format = STATUS_FORMAT_UNSPECIFIED ;
121
123
122
124
static int opt_parse_m (const struct option * opt , const char * arg , int unset )
123
125
{
@@ -460,6 +462,9 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int
460
462
case STATUS_FORMAT_PORCELAIN :
461
463
wt_porcelain_print (s );
462
464
break ;
465
+ case STATUS_FORMAT_UNSPECIFIED :
466
+ die ("BUG: finalize_deferred_config() should have been called" );
467
+ break ;
463
468
case STATUS_FORMAT_NONE :
464
469
case STATUS_FORMAT_LONG :
465
470
wt_status_print (s );
@@ -961,6 +966,42 @@ static const char *read_commit_message(const char *name)
961
966
return logmsg_reencode (commit , NULL , out_enc );
962
967
}
963
968
969
+ /*
970
+ * Enumerate what needs to be propagated when --porcelain
971
+ * is not in effect here.
972
+ */
973
+ static struct status_deferred_config {
974
+ enum status_format status_format ;
975
+ int show_branch ;
976
+ } status_deferred_config = {
977
+ STATUS_FORMAT_UNSPECIFIED ,
978
+ -1 /* unspecified */
979
+ };
980
+
981
+ static void finalize_deferred_config (struct wt_status * s )
982
+ {
983
+ int use_deferred_config = (status_format != STATUS_FORMAT_PORCELAIN &&
984
+ !s -> null_termination );
985
+
986
+ if (s -> null_termination ) {
987
+ if (status_format == STATUS_FORMAT_NONE ||
988
+ status_format == STATUS_FORMAT_UNSPECIFIED )
989
+ status_format = STATUS_FORMAT_PORCELAIN ;
990
+ else if (status_format == STATUS_FORMAT_LONG )
991
+ die (_ ("--long and -z are incompatible" ));
992
+ }
993
+
994
+ if (use_deferred_config && status_format == STATUS_FORMAT_UNSPECIFIED )
995
+ status_format = status_deferred_config .status_format ;
996
+ if (status_format == STATUS_FORMAT_UNSPECIFIED )
997
+ status_format = STATUS_FORMAT_NONE ;
998
+
999
+ if (use_deferred_config && s -> show_branch < 0 )
1000
+ s -> show_branch = status_deferred_config .show_branch ;
1001
+ if (s -> show_branch < 0 )
1002
+ s -> show_branch = 0 ;
1003
+ }
1004
+
964
1005
static int parse_and_validate_options (int argc , const char * argv [],
965
1006
const struct option * options ,
966
1007
const char * const usage [],
@@ -971,6 +1012,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
971
1012
int f = 0 ;
972
1013
973
1014
argc = parse_options (argc , argv , prefix , options , usage , 0 );
1015
+ finalize_deferred_config (s );
974
1016
975
1017
if (force_author && !strchr (force_author , '>' ))
976
1018
force_author = find_author_by_nickname (force_author );
@@ -1055,12 +1097,6 @@ static int parse_and_validate_options(int argc, const char *argv[],
1055
1097
if (all && argc > 0 )
1056
1098
die (_ ("Paths with -a does not make sense." ));
1057
1099
1058
- if (s -> null_termination ) {
1059
- if (status_format == STATUS_FORMAT_NONE )
1060
- status_format = STATUS_FORMAT_PORCELAIN ;
1061
- else if (status_format == STATUS_FORMAT_LONG )
1062
- die (_ ("--long and -z are incompatible" ));
1063
- }
1064
1100
if (status_format != STATUS_FORMAT_NONE )
1065
1101
dry_run = 1 ;
1066
1102
@@ -1113,6 +1149,17 @@ static int git_status_config(const char *k, const char *v, void *cb)
1113
1149
s -> submodule_summary = -1 ;
1114
1150
return 0 ;
1115
1151
}
1152
+ if (!strcmp (k , "status.short" )) {
1153
+ if (git_config_bool (k , v ))
1154
+ status_deferred_config .status_format = STATUS_FORMAT_SHORT ;
1155
+ else
1156
+ status_deferred_config .status_format = STATUS_FORMAT_NONE ;
1157
+ return 0 ;
1158
+ }
1159
+ if (!strcmp (k , "status.branch" )) {
1160
+ status_deferred_config .show_branch = git_config_bool (k , v );
1161
+ return 0 ;
1162
+ }
1116
1163
if (!strcmp (k , "status.color" ) || !strcmp (k , "color.status" )) {
1117
1164
s -> use_color = git_config_colorbool (k , v );
1118
1165
return 0 ;
@@ -1155,8 +1202,8 @@ int cmd_status(int argc, const char **argv, const char *prefix)
1155
1202
OPT__VERBOSE (& verbose , N_ ("be verbose" )),
1156
1203
OPT_SET_INT ('s' , "short" , & status_format ,
1157
1204
N_ ("show status concisely" ), STATUS_FORMAT_SHORT ),
1158
- OPT_BOOLEAN ('b' , "branch" , & s .show_branch ,
1159
- N_ ("show branch information" )),
1205
+ OPT_BOOL ('b' , "branch" , & s .show_branch ,
1206
+ N_ ("show branch information" )),
1160
1207
OPT_SET_INT (0 , "porcelain" , & status_format ,
1161
1208
N_ ("machine-readable output" ),
1162
1209
STATUS_FORMAT_PORCELAIN ),
@@ -1189,13 +1236,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
1189
1236
builtin_status_options ,
1190
1237
builtin_status_usage , 0 );
1191
1238
finalize_colopts (& s .colopts , -1 );
1192
-
1193
- if (s .null_termination ) {
1194
- if (status_format == STATUS_FORMAT_NONE )
1195
- status_format = STATUS_FORMAT_PORCELAIN ;
1196
- else if (status_format == STATUS_FORMAT_LONG )
1197
- die (_ ("--long and -z are incompatible" ));
1198
- }
1239
+ finalize_deferred_config (& s );
1199
1240
1200
1241
handle_untracked_files_arg (& s );
1201
1242
if (show_ignored_in_status )
@@ -1224,6 +1265,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)
1224
1265
case STATUS_FORMAT_PORCELAIN :
1225
1266
wt_porcelain_print (& s );
1226
1267
break ;
1268
+ case STATUS_FORMAT_UNSPECIFIED :
1269
+ die ("BUG: finalize_deferred_config() should have been called" );
1270
+ break ;
1227
1271
case STATUS_FORMAT_NONE :
1228
1272
case STATUS_FORMAT_LONG :
1229
1273
s .verbose = verbose ;
@@ -1392,7 +1436,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
1392
1436
OPT_BOOLEAN (0 , "dry-run" , & dry_run , N_ ("show what would be committed" )),
1393
1437
OPT_SET_INT (0 , "short" , & status_format , N_ ("show status concisely" ),
1394
1438
STATUS_FORMAT_SHORT ),
1395
- OPT_BOOLEAN (0 , "branch" , & s .show_branch , N_ ("show branch information" )),
1439
+ OPT_BOOL (0 , "branch" , & s .show_branch , N_ ("show branch information" )),
1396
1440
OPT_SET_INT (0 , "porcelain" , & status_format ,
1397
1441
N_ ("machine-readable output" ), STATUS_FORMAT_PORCELAIN ),
1398
1442
OPT_SET_INT (0 , "long" , & status_format ,
@@ -1433,6 +1477,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
1433
1477
wt_status_prepare (& s );
1434
1478
gitmodules_config ();
1435
1479
git_config (git_commit_config , & s );
1480
+ status_format = STATUS_FORMAT_NONE ; /* Ignore status.short */
1436
1481
determine_whence (& s );
1437
1482
s .colopts = 0 ;
1438
1483
0 commit comments