Skip to content

Commit

Permalink
builtin/commit.c: set status_format _after_ option parsing
Browse files Browse the repository at this point in the history
'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 <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Brandon Casey authored and Junio C Hamano committed May 29, 2011
1 parent 95b9f9f commit 000f97b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions builtin-commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1039,14 +1039,15 @@ int cmd_status(int argc, const char **argv, const char *prefix)
OPT_END(),
};

if (null_termination && status_format == STATUS_FORMAT_LONG)
status_format = STATUS_FORMAT_PORCELAIN;

wt_status_prepare(&s);
git_config(git_status_config, &s);
argc = parse_options(argc, argv, prefix,
builtin_status_options,
builtin_status_usage, 0);

if (null_termination && status_format == STATUS_FORMAT_LONG)
status_format = STATUS_FORMAT_PORCELAIN;

handle_untracked_files_arg(&s);

if (*argv)
Expand Down
2 changes: 1 addition & 1 deletion t/t7508-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ test_expect_success 'status submodule summary (clean submodule)' '
test_cmp expect output
'

test_expect_failure 'status -z implies porcelain' '
test_expect_success 'status -z implies porcelain' '
git status --porcelain |
perl -pe "s/\012/\000/g" >expect &&
git status -z >output &&
Expand Down

0 comments on commit 000f97b

Please sign in to comment.