Skip to content

Commit 000f97b

Browse files
drafnelgitster
authored andcommitted
builtin/commit.c: set status_format _after_ option parsing
'git status' should use --porcelain output format when -z is given. It was not doing so since the _effect_ of using -z, namely that null_termination would be set, was being checked _before_ option parsing was performed. So, move the check so that it is performed after option parsing. Signed-off-by: Brandon Casey <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 95b9f9f commit 000f97b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

builtin-commit.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,14 +1039,15 @@ int cmd_status(int argc, const char **argv, const char *prefix)
10391039
OPT_END(),
10401040
};
10411041

1042-
if (null_termination && status_format == STATUS_FORMAT_LONG)
1043-
status_format = STATUS_FORMAT_PORCELAIN;
1044-
10451042
wt_status_prepare(&s);
10461043
git_config(git_status_config, &s);
10471044
argc = parse_options(argc, argv, prefix,
10481045
builtin_status_options,
10491046
builtin_status_usage, 0);
1047+
1048+
if (null_termination && status_format == STATUS_FORMAT_LONG)
1049+
status_format = STATUS_FORMAT_PORCELAIN;
1050+
10501051
handle_untracked_files_arg(&s);
10511052

10521053
if (*argv)

t/t7508-status.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ test_expect_success 'status submodule summary (clean submodule)' '
364364
test_cmp expect output
365365
'
366366

367-
test_expect_failure 'status -z implies porcelain' '
367+
test_expect_success 'status -z implies porcelain' '
368368
git status --porcelain |
369369
perl -pe "s/\012/\000/g" >expect &&
370370
git status -z >output &&

0 commit comments

Comments
 (0)