Merge branch 'bc/maint-status-z-to-use-porcelain'
authorJunio C Hamano <gitster@pobox.com>
Mon, 6 Jun 2011 18:40:08 +0000 (11:40 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 6 Jun 2011 18:40:08 +0000 (11:40 -0700)
* bc/maint-status-z-to-use-porcelain:
  builtin/commit.c: set status_format _after_ option parsing
  t7508: demonstrate status's failure to use --porcelain format with -z

Conflicts:
builtin/commit.c

builtin/commit.c
t/t7508-status.sh

index 5286432f39b87e03a08cc86bb622b6ca3b911365..e1af9b19f0be71484ae9341762dc2bf89cabb70c 100644 (file)
@@ -1207,9 +1207,6 @@ int cmd_status(int argc, const char **argv, const char *prefix)
        if (argc == 2 && !strcmp(argv[1], "-h"))
                usage_with_options(builtin_status_usage, builtin_status_options);
 
-       if (null_termination && status_format == STATUS_FORMAT_LONG)
-               status_format = STATUS_FORMAT_PORCELAIN;
-
        wt_status_prepare(&s);
        gitmodules_config();
        git_config(git_status_config, &s);
@@ -1217,6 +1214,10 @@ int cmd_status(int argc, const char **argv, const char *prefix)
        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 (show_ignored_in_status)
                s.show_ignored_files = 1;
index cd6e2c5e871230a43f504e165498139d8ec7a3d2..1fdfbd38654a83771f677f2219403e3713abef51 100755 (executable)
@@ -780,6 +780,13 @@ test_expect_success 'status -s submodule summary (clean submodule)' '
        test_cmp expect output
 '
 
+test_expect_success 'status -z implies porcelain' '
+       git status --porcelain |
+       perl -pe "s/\012/\000/g" >expect &&
+       git status -z >output &&
+       test_cmp expect output
+'
+
 cat >expect <<EOF
 # On branch master
 # Changes to be committed: