{"thread":{"id":"31836","subject":"[PATCH] status: add --long for default format","startedAt":"2012-10-16T16:22:49Z","lastAt":"2012-10-18T21:20:57Z","messageCount":10,"participants":["Nguyễn Thái Ngọc Duy","Jeff King","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"201352","messageId":"1350404569-9787-1-git-send-email-pclouds@gmail.com","threadId":"31836","inReplyTo":null,"subject":"[PATCH] status: add --long for default format","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-10-16T16:22:49Z","receivedAt":"2012-10-16T16:22:49Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This could be useful when the user sets an alias to \"status --short\"\nand wants to get back the default format temporarily.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Documentation/git-status.txt | 3 +++\n builtin/commit.c             | 2 ++\n 2 files changed, 5 insertions(+)\n\ndiff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\nindex 67e5f53..9f1ef9a 100644\n--- a/Documentation/git-status.txt\n+++ b/Documentation/git-status.txt\n@@ -38,6 +38,9 @@ OPTIONS\n \tacross git versions and regardless of user configuration. See\n \tbelow for details.\n \n+--long::\n+\tGive the output in the long-format. This is the default.\n+\n -u[<mode>]::\n --untracked-files[=<mode>]::\n \tShow untracked files.\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex a17a5df..5adab33 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1159,6 +1159,8 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \t\tOPT_SET_INT(0, \"porcelain\", &status_format,\n \t\t\t    N_(\"machine-readable output\"),\n \t\t\t    STATUS_FORMAT_PORCELAIN),\n+\t\tOPT_SET_INT(0, \"long\", &status_format,\n+\t\t\t    N_(\"show status in long format (default)\"), STATUS_FORMAT_LONG),\n \t\tOPT_BOOLEAN('z', \"null\", &s.null_termination,\n \t\t\t    N_(\"terminate entries with NUL\")),\n \t\t{ OPTION_STRING, 'u', \"untracked-files\", &untracked_files_arg,\n-- \n1.8.0.rc2.21.g0695653\n"},{"id":"201362","messageId":"20121016172204.GB27243@sigill.intra.peff.net","threadId":"31836","inReplyTo":"1350404569-9787-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH] status: add --long for default format","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-10-16T17:22:04Z","receivedAt":"2012-10-16T17:22:04Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Oct 16, 2012 at 11:22:49PM +0700, Nguyen Thai Ngoc Duy wrote:\n\n> This could be useful when the user sets an alias to \"status --short\"\n> and wants to get back the default format temporarily.\n\nMakes sense, but...\n\n> diff --git a/builtin/commit.c b/builtin/commit.c\n> index a17a5df..5adab33 100644\n> --- a/builtin/commit.c\n> +++ b/builtin/commit.c\n> @@ -1159,6 +1159,8 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n>  \t\tOPT_SET_INT(0, \"porcelain\", &status_format,\n>  \t\t\t    N_(\"machine-readable output\"),\n>  \t\t\t    STATUS_FORMAT_PORCELAIN),\n> +\t\tOPT_SET_INT(0, \"long\", &status_format,\n> +\t\t\t    N_(\"show status in long format (default)\"), STATUS_FORMAT_LONG),\n>  \t\tOPT_BOOLEAN('z', \"null\", &s.null_termination,\n>  \t\t\t    N_(\"terminate entries with NUL\")),\n>  \t\t{ OPTION_STRING, 'u', \"untracked-files\", &untracked_files_arg,\n\nI'm pretty sure we use STATUS_FORMAT_LONG elsewhere as a synonym for\n\"the user has not set anything\".\n\nAh, here it is:\n\n  $ git grep -nA1 '== STATUS_FORMAT_LONG'\n  1073:   if (s->null_termination && status_format == STATUS_FORMAT_LONG)\n  1074-           status_format = STATUS_FORMAT_PORCELAIN;\n  --\n  1201:   if (s.null_termination && status_format == STATUS_FORMAT_LONG)\n  1202-           status_format = STATUS_FORMAT_PORCELAIN;\n\nI think you would want something like this. I had originally intended to\nmake it a refactoring patch that would come before yours, but some of\nthe cleanups are tied to actually adding --long. So I think you would\nwant to squash it together with your patch and combine the commit\nmessages.\n\n-- >8 --\nSubject: [PATCH] status: refactor output format to represent \"default\"\n\nWhen deciding which output format to use, we default an\ninternal enum to STATUS_FORMAT_LONG and modify it if\n\"--porcelain\" or \"--short\" is given. If this enum is set to\nLONG, then we know the user has not specified any format,\nand we can kick in default behaviors. This works because\nthere is no \"--long\" which they could use to explicitly\nspecify LONG.\n\nLet's expand the enum to have an explicit STATUS_FORMAT_NONE,\nin preparation for adding \"--long\". Then we can distinguish\nbetween LONG and NONE when setting other defaults. There are\ntwo such cases:\n\n  1. The user has asked for NUL termination. With NONE, we\n     currently default to turning on the porcelain mode.\n     With an explicit --long, we would in theory use NUL\n     termination with the long mode, but it does not support\n     it. So we can just complain and die.\n\n  2. When an output format is given to \"git commit\", we\n     default to \"--dry-run\". This behavior would now kick in\n     when \"--long\" is given, too.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n builtin/commit.c | 23 +++++++++++++++++------\n 1 file changed, 17 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 00ac35b..ec299f4 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -112,10 +112,11 @@ static enum {\n static struct strbuf message = STRBUF_INIT;\n \n static enum {\n+\tSTATUS_FORMAT_NONE = 0,\n \tSTATUS_FORMAT_LONG,\n \tSTATUS_FORMAT_SHORT,\n \tSTATUS_FORMAT_PORCELAIN\n-} status_format = STATUS_FORMAT_LONG;\n+} status_format;\n \n static int mention_abandoned_message;\n static void maybe_mention_abandoned_message(void)\n@@ -464,6 +465,7 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int\n \tcase STATUS_FORMAT_PORCELAIN:\n \t\twt_porcelain_print(s);\n \t\tbreak;\n+\tcase STATUS_FORMAT_NONE:\n \tcase STATUS_FORMAT_LONG:\n \t\twt_status_print(s);\n \t\tbreak;\n@@ -1070,9 +1072,13 @@ static int parse_and_validate_options(int argc, const char *argv[],\n \tif (all && argc > 0)\n \t\tdie(_(\"Paths with -a does not make sense.\"));\n \n-\tif (s->null_termination && status_format == STATUS_FORMAT_LONG)\n-\t\tstatus_format = STATUS_FORMAT_PORCELAIN;\n-\tif (status_format != STATUS_FORMAT_LONG)\n+\tif (s->null_termination) {\n+\t\tif (status_format == STATUS_FORMAT_NONE)\n+\t\t\tstatus_format = STATUS_FORMAT_PORCELAIN;\n+\t\telse if (status_format == STATUS_FORMAT_LONG)\n+\t\t\tdie(\"--long and -z are incompatible\");\n+\t}\n+\tif (status_format != STATUS_FORMAT_NONE)\n \t\tdry_run = 1;\n \n \treturn argc;\n@@ -1198,8 +1204,12 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \t\t\t     builtin_status_usage, 0);\n \tfinalize_colopts(&s.colopts, -1);\n \n-\tif (s.null_termination && status_format == STATUS_FORMAT_LONG)\n-\t\tstatus_format = STATUS_FORMAT_PORCELAIN;\n+\tif (s.null_termination) {\n+\t\tif (status_format == STATUS_FORMAT_NONE)\n+\t\t\tstatus_format = STATUS_FORMAT_PORCELAIN;\n+\t\telse if (status_format == STATUS_FORMAT_LONG)\n+\t\t\tdie(\"--long and -z are incompatible\");\n+\t}\n \n \thandle_untracked_files_arg(&s);\n \tif (show_ignored_in_status)\n@@ -1228,6 +1238,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \tcase STATUS_FORMAT_PORCELAIN:\n \t\twt_porcelain_print(&s);\n \t\tbreak;\n+\tcase STATUS_FORMAT_NONE:\n \tcase STATUS_FORMAT_LONG:\n \t\ts.verbose = verbose;\n \t\ts.ignore_submodule_arg = ignore_submodule_arg;\n-- \n1.8.0.rc2.5.gecca26e\n"},{"id":"201377","messageId":"20121016183233.GE27243@sigill.intra.peff.net","threadId":"31836","inReplyTo":"20121016172204.GB27243@sigill.intra.peff.net","subject":"Re: [PATCH] status: add --long for default format","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-10-16T18:32:33Z","receivedAt":"2012-10-16T18:32:33Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Oct 16, 2012 at 01:22:04PM -0400, Jeff King wrote:\n\n>   2. When an output format is given to \"git commit\", we\n>      default to \"--dry-run\". This behavior would now kick in\n>      when \"--long\" is given, too.\n\nI forgot to mention in my previous message: your patch should probably\nadd \"--long\" to git-commit for consistency.\n\n-Peff\n"},{"id":"201457","messageId":"1350525480-30395-1-git-send-email-pclouds@gmail.com","threadId":"31836","inReplyTo":"1350404569-9787-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 1/2] status: refactor output format to represent \"default\"","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-10-18T01:57:59Z","receivedAt":"2012-10-18T01:57:59Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"From: Jeff King <peff@peff.net>\n\nWhen deciding which output format to use, we default an\ninternal enum to STATUS_FORMAT_LONG and modify it if\n\"--porcelain\" or \"--short\" is given. If this enum is set to\nLONG, then we know the user has not specified any format,\nand we can kick in default behaviors. This works because\nthere is no \"--long\" which they could use to explicitly\nspecify LONG.\n\nLet's expand the enum to have an explicit STATUS_FORMAT_NONE,\nin preparation for adding \"--long\". Then we can distinguish\nbetween LONG and NONE when setting other defaults. There are\ntwo such cases:\n\n  1. The user has asked for NUL termination. With NONE, we\n     currently default to turning on the porcelain mode.\n     With an explicit --long, we would in theory use NUL\n     termination with the long mode, but it does not support\n     it. So we can just complain and die.\n\n  2. When an output format is given to \"git commit\", we\n     default to \"--dry-run\". This behavior would now kick in\n     when \"--long\" is given, too.\n\nSigned-off-by: Jeff King <peff@peff.net>\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Two die()s with --long are moved to the next patch where --long is\n introduced.\n\n builtin/commit.c | 19 +++++++++++++------\n 1 file changed, 13 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex a17a5df..984e29c 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -112,10 +112,11 @@ static const char *only_include_assumed;\n static struct strbuf message = STRBUF_INIT;\n \n static enum {\n+\tSTATUS_FORMAT_NONE = 0,\n \tSTATUS_FORMAT_LONG,\n \tSTATUS_FORMAT_SHORT,\n \tSTATUS_FORMAT_PORCELAIN\n-} status_format = STATUS_FORMAT_LONG;\n+} status_format;\n \n static int opt_parse_m(const struct option *opt, const char *arg, int unset)\n {\n@@ -454,6 +455,7 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int\n \tcase STATUS_FORMAT_PORCELAIN:\n \t\twt_porcelain_print(s);\n \t\tbreak;\n+\tcase STATUS_FORMAT_NONE:\n \tcase STATUS_FORMAT_LONG:\n \t\twt_status_print(s);\n \t\tbreak;\n@@ -1058,9 +1060,11 @@ static int parse_and_validate_options(int argc, const char *argv[],\n \tif (all && argc > 0)\n \t\tdie(_(\"Paths with -a does not make sense.\"));\n \n-\tif (s->null_termination && status_format == STATUS_FORMAT_LONG)\n-\t\tstatus_format = STATUS_FORMAT_PORCELAIN;\n-\tif (status_format != STATUS_FORMAT_LONG)\n+\tif (s->null_termination) {\n+\t\tif (status_format == STATUS_FORMAT_NONE)\n+\t\t\tstatus_format = STATUS_FORMAT_PORCELAIN;\n+\t}\n+\tif (status_format != STATUS_FORMAT_NONE)\n \t\tdry_run = 1;\n \n \treturn argc;\n@@ -1186,8 +1190,10 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \t\t\t     builtin_status_usage, 0);\n \tfinalize_colopts(&s.colopts, -1);\n \n-\tif (s.null_termination && status_format == STATUS_FORMAT_LONG)\n-\t\tstatus_format = STATUS_FORMAT_PORCELAIN;\n+\tif (s.null_termination) {\n+\t\tif (status_format == STATUS_FORMAT_NONE)\n+\t\t\tstatus_format = STATUS_FORMAT_PORCELAIN;\n+\t}\n \n \thandle_untracked_files_arg(&s);\n \tif (show_ignored_in_status)\n@@ -1216,6 +1222,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \tcase STATUS_FORMAT_PORCELAIN:\n \t\twt_porcelain_print(&s);\n \t\tbreak;\n+\tcase STATUS_FORMAT_NONE:\n \tcase STATUS_FORMAT_LONG:\n \t\ts.verbose = verbose;\n \t\ts.ignore_submodule_arg = ignore_submodule_arg;\n-- \n1.8.0.rc2.32.g1729c8c\n"},{"id":"201456","messageId":"1350525480-30395-2-git-send-email-pclouds@gmail.com","threadId":"31836","inReplyTo":"1350525480-30395-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 2/2] status: add --long for default format","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-10-18T01:58:00Z","receivedAt":"2012-10-18T01:58:00Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This could be useful when the user sets an alias to \"status --short\"\nand wants to get the default format back temporarily.\n\ngit-commit also learns --long mostly for consistency as there's little\nchance that someone adds an alias for \"git commit --short\" then wants\na one shot --long output.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Documentation/git-commit.txt |  4 ++++\n Documentation/git-status.txt |  3 +++\n builtin/commit.c             | 10 ++++++++++\n 3 files changed, 17 insertions(+)\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex 9594ac8..3acf2e7 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -109,6 +109,10 @@ OPTIONS\n \tformat. See linkgit:git-status[1] for details. Implies\n \t`--dry-run`.\n \n+--long::\n+\tWhen doing a dry-run, give the output in a the long-format.\n+\tImplies `--dry-run`.\n+\n -z::\n --null::\n \tWhen showing `short` or `porcelain` status output, terminate\ndiff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\nindex 67e5f53..9f1ef9a 100644\n--- a/Documentation/git-status.txt\n+++ b/Documentation/git-status.txt\n@@ -38,6 +38,9 @@ OPTIONS\n \tacross git versions and regardless of user configuration. See\n \tbelow for details.\n \n+--long::\n+\tGive the output in the long-format. This is the default.\n+\n -u[<mode>]::\n --untracked-files[=<mode>]::\n \tShow untracked files.\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 984e29c..1dd2ec5 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1063,6 +1063,8 @@ static int parse_and_validate_options(int argc, const char *argv[],\n \tif (s->null_termination) {\n \t\tif (status_format == STATUS_FORMAT_NONE)\n \t\t\tstatus_format = STATUS_FORMAT_PORCELAIN;\n+\t\telse if (status_format == STATUS_FORMAT_LONG)\n+\t\t\tdie(_(\"--long and -z are incompatible\"));\n \t}\n \tif (status_format != STATUS_FORMAT_NONE)\n \t\tdry_run = 1;\n@@ -1163,6 +1165,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \t\tOPT_SET_INT(0, \"porcelain\", &status_format,\n \t\t\t    N_(\"machine-readable output\"),\n \t\t\t    STATUS_FORMAT_PORCELAIN),\n+\t\tOPT_SET_INT(0, \"long\", &status_format,\n+\t\t\t    N_(\"show status in long format (default)\"),\n+\t\t\t    STATUS_FORMAT_LONG),\n \t\tOPT_BOOLEAN('z', \"null\", &s.null_termination,\n \t\t\t    N_(\"terminate entries with NUL\")),\n \t\t{ OPTION_STRING, 'u', \"untracked-files\", &untracked_files_arg,\n@@ -1193,6 +1198,8 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \tif (s.null_termination) {\n \t\tif (status_format == STATUS_FORMAT_NONE)\n \t\t\tstatus_format = STATUS_FORMAT_PORCELAIN;\n+\t\telse if (status_format == STATUS_FORMAT_LONG)\n+\t\t\tdie(_(\"--long and -z are incompatible\"));\n \t}\n \n \thandle_untracked_files_arg(&s);\n@@ -1393,6 +1400,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOLEAN(0, \"branch\", &s.show_branch, N_(\"show branch information\")),\n \t\tOPT_SET_INT(0, \"porcelain\", &status_format,\n \t\t\t    N_(\"machine-readable output\"), STATUS_FORMAT_PORCELAIN),\n+\t\tOPT_SET_INT(0, \"long\", &status_format,\n+\t\t\t    N_(\"show status in long format (default)\"),\n+\t\t\t    STATUS_FORMAT_LONG),\n \t\tOPT_BOOLEAN('z', \"null\", &s.null_termination,\n \t\t\t    N_(\"terminate entries with NUL\")),\n \t\tOPT_BOOLEAN(0, \"amend\", &amend, N_(\"amend previous commit\")),\n-- \n1.8.0.rc2.32.g1729c8c\n"},{"id":"201458","messageId":"20121018020308.GA24484@sigill.intra.peff.net","threadId":"31836","inReplyTo":"1350525480-30395-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH v2 1/2] status: refactor output format to represent \"default\"","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-10-18T02:03:08Z","receivedAt":"2012-10-18T02:03:08Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Oct 18, 2012 at 08:57:59AM +0700, Nguyen Thai Ngoc Duy wrote:\n\n> From: Jeff King <peff@peff.net>\n> \n> When deciding which output format to use, we default an\n> internal enum to STATUS_FORMAT_LONG and modify it if\n> \"--porcelain\" or \"--short\" is given. If this enum is set to\n> LONG, then we know the user has not specified any format,\n> and we can kick in default behaviors. This works because\n> there is no \"--long\" which they could use to explicitly\n> specify LONG.\n> \n> Let's expand the enum to have an explicit STATUS_FORMAT_NONE,\n> in preparation for adding \"--long\". Then we can distinguish\n> between LONG and NONE when setting other defaults. There are\n> two such cases:\n> \n>   1. The user has asked for NUL termination. With NONE, we\n>      currently default to turning on the porcelain mode.\n>      With an explicit --long, we would in theory use NUL\n>      termination with the long mode, but it does not support\n>      it. So we can just complain and die.\n> \n>   2. When an output format is given to \"git commit\", we\n>      default to \"--dry-run\". This behavior would now kick in\n>      when \"--long\" is given, too.\n> \n> Signed-off-by: Jeff King <peff@peff.net>\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n>  Two die()s with --long are moved to the next patch where --long is\n>  introduced.\n\nI think that is fine to split it like this, but you would want to update\nthe commit message above. Probably just remove those two cases and say\nsomething like:\n\n  Note that you cannot actually trigger STATUS_FORMAT_LONG, as we do\n  not yet have \"--long\"; that will come in a follow-on patch.\n\nAnd then move the reasoning for how \"--long\" works with each case into\nthe commit message of the next patch.\n\nOther than that, the patches look OK to me.\n\n-Peff\n"},{"id":"201512","messageId":"1350569750-26304-1-git-send-email-pclouds@gmail.com","threadId":"31836","inReplyTo":"20121018020308.GA24484@sigill.intra.peff.net","subject":"[PATCH v3] status: refactor output format to represent \"default\" and add --long","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-10-18T14:15:50Z","receivedAt":"2012-10-18T14:15:50Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"From: Jeff King <peff@peff.net>\n\nWhen deciding which output format to use, we default an internal enum\nto STATUS_FORMAT_LONG and modify it if \"--porcelain\" or \"--short\" is\ngiven. If this enum is set to LONG, then we know the user has not\nspecified any format, and we can kick in default behaviors. This works\nbecause there is no \"--long\" which they could use to explicitly\nspecify LONG.\n\nLet's expand the enum to have an explicit STATUS_FORMAT_NONE, in\npreparation for adding \"--long\", which can be used to override --short\nor --porcelain. Then we can distinguish between LONG and NONE when\nsetting other defaults. There are two such cases:\n\n  1. The user has asked for NUL termination. With NONE, we\n     currently default to turning on the porcelain mode.\n     With an explicit --long, we would in theory use NUL\n     termination with the long mode, but it does not support\n     it. So we can just complain and die.\n\n  2. When an output format is given to \"git commit\", we\n     default to \"--dry-run\". This behavior would now kick in\n     when \"--long\" is given, too.\n\nSigned-off-by: Jeff King <peff@peff.net>\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n On Thu, Oct 18, 2012 at 9:03 AM, Jeff King <peff@peff.net> wrote:\n > I think that is fine to split it like this, but you would want to update\n > the commit message above. Probably just remove those two cases and say\n > something like:\n >\n >   Note that you cannot actually trigger STATUS_FORMAT_LONG, as we do\n >   not yet have \"--long\"; that will come in a follow-on patch.\n >\n > And then move the reasoning for how \"--long\" works with each case into\n > the commit message of the next patch.\n\n Nope, it's hard to split the explanation in two (at least to me),\n which may mean that the split does not make sense.\n\n Documentation/git-commit.txt |  4 ++++\n Documentation/git-status.txt |  3 +++\n builtin/commit.c             | 29 +++++++++++++++++++++++------\n 3 files changed, 30 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex 9594ac8..3acf2e7 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -109,6 +109,10 @@ OPTIONS\n \tformat. See linkgit:git-status[1] for details. Implies\n \t`--dry-run`.\n \n+--long::\n+\tWhen doing a dry-run, give the output in a the long-format.\n+\tImplies `--dry-run`.\n+\n -z::\n --null::\n \tWhen showing `short` or `porcelain` status output, terminate\ndiff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\nindex 67e5f53..9f1ef9a 100644\n--- a/Documentation/git-status.txt\n+++ b/Documentation/git-status.txt\n@@ -38,6 +38,9 @@ OPTIONS\n \tacross git versions and regardless of user configuration. See\n \tbelow for details.\n \n+--long::\n+\tGive the output in the long-format. This is the default.\n+\n -u[<mode>]::\n --untracked-files[=<mode>]::\n \tShow untracked files.\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex a17a5df..1dd2ec5 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -112,10 +112,11 @@ static const char *only_include_assumed;\n static struct strbuf message = STRBUF_INIT;\n \n static enum {\n+\tSTATUS_FORMAT_NONE = 0,\n \tSTATUS_FORMAT_LONG,\n \tSTATUS_FORMAT_SHORT,\n \tSTATUS_FORMAT_PORCELAIN\n-} status_format = STATUS_FORMAT_LONG;\n+} status_format;\n \n static int opt_parse_m(const struct option *opt, const char *arg, int unset)\n {\n@@ -454,6 +455,7 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int\n \tcase STATUS_FORMAT_PORCELAIN:\n \t\twt_porcelain_print(s);\n \t\tbreak;\n+\tcase STATUS_FORMAT_NONE:\n \tcase STATUS_FORMAT_LONG:\n \t\twt_status_print(s);\n \t\tbreak;\n@@ -1058,9 +1060,13 @@ static int parse_and_validate_options(int argc, const char *argv[],\n \tif (all && argc > 0)\n \t\tdie(_(\"Paths with -a does not make sense.\"));\n \n-\tif (s->null_termination && status_format == STATUS_FORMAT_LONG)\n-\t\tstatus_format = STATUS_FORMAT_PORCELAIN;\n-\tif (status_format != STATUS_FORMAT_LONG)\n+\tif (s->null_termination) {\n+\t\tif (status_format == STATUS_FORMAT_NONE)\n+\t\t\tstatus_format = STATUS_FORMAT_PORCELAIN;\n+\t\telse if (status_format == STATUS_FORMAT_LONG)\n+\t\t\tdie(_(\"--long and -z are incompatible\"));\n+\t}\n+\tif (status_format != STATUS_FORMAT_NONE)\n \t\tdry_run = 1;\n \n \treturn argc;\n@@ -1159,6 +1165,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \t\tOPT_SET_INT(0, \"porcelain\", &status_format,\n \t\t\t    N_(\"machine-readable output\"),\n \t\t\t    STATUS_FORMAT_PORCELAIN),\n+\t\tOPT_SET_INT(0, \"long\", &status_format,\n+\t\t\t    N_(\"show status in long format (default)\"),\n+\t\t\t    STATUS_FORMAT_LONG),\n \t\tOPT_BOOLEAN('z', \"null\", &s.null_termination,\n \t\t\t    N_(\"terminate entries with NUL\")),\n \t\t{ OPTION_STRING, 'u', \"untracked-files\", &untracked_files_arg,\n@@ -1186,8 +1195,12 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \t\t\t     builtin_status_usage, 0);\n \tfinalize_colopts(&s.colopts, -1);\n \n-\tif (s.null_termination && status_format == STATUS_FORMAT_LONG)\n-\t\tstatus_format = STATUS_FORMAT_PORCELAIN;\n+\tif (s.null_termination) {\n+\t\tif (status_format == STATUS_FORMAT_NONE)\n+\t\t\tstatus_format = STATUS_FORMAT_PORCELAIN;\n+\t\telse if (status_format == STATUS_FORMAT_LONG)\n+\t\t\tdie(_(\"--long and -z are incompatible\"));\n+\t}\n \n \thandle_untracked_files_arg(&s);\n \tif (show_ignored_in_status)\n@@ -1216,6 +1229,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \tcase STATUS_FORMAT_PORCELAIN:\n \t\twt_porcelain_print(&s);\n \t\tbreak;\n+\tcase STATUS_FORMAT_NONE:\n \tcase STATUS_FORMAT_LONG:\n \t\ts.verbose = verbose;\n \t\ts.ignore_submodule_arg = ignore_submodule_arg;\n@@ -1386,6 +1400,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOLEAN(0, \"branch\", &s.show_branch, N_(\"show branch information\")),\n \t\tOPT_SET_INT(0, \"porcelain\", &status_format,\n \t\t\t    N_(\"machine-readable output\"), STATUS_FORMAT_PORCELAIN),\n+\t\tOPT_SET_INT(0, \"long\", &status_format,\n+\t\t\t    N_(\"show status in long format (default)\"),\n+\t\t\t    STATUS_FORMAT_LONG),\n \t\tOPT_BOOLEAN('z', \"null\", &s.null_termination,\n \t\t\t    N_(\"terminate entries with NUL\")),\n \t\tOPT_BOOLEAN(0, \"amend\", &amend, N_(\"amend previous commit\")),\n-- \n1.8.0.rc2.22.gad9383a\n"},{"id":"201524","messageId":"20121018202647.GA31093@sigill.intra.peff.net","threadId":"31836","inReplyTo":"1350569750-26304-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH v3] status: refactor output format to represent \"default\" and add --long","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-10-18T20:26:47Z","receivedAt":"2012-10-18T20:26:47Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Oct 18, 2012 at 09:15:50PM +0700, Nguyen Thai Ngoc Duy wrote:\n\n>  On Thu, Oct 18, 2012 at 9:03 AM, Jeff King <peff@peff.net> wrote:\n>  > I think that is fine to split it like this, but you would want to update\n>  > the commit message above. Probably just remove those two cases and say\n>  > something like:\n>  >\n>  >   Note that you cannot actually trigger STATUS_FORMAT_LONG, as we do\n>  >   not yet have \"--long\"; that will come in a follow-on patch.\n>  >\n>  > And then move the reasoning for how \"--long\" works with each case into\n>  > the commit message of the next patch.\n> \n>  Nope, it's hard to split the explanation in two (at least to me),\n>  which may mean that the split does not make sense.\n\nYeah, that was the same place that I had difficulty when writing the\noriginal. This version looks OK to me.\n\n-Peff\n"},{"id":"201526","messageId":"7vtxtrlbvo.fsf@alter.siamese.dyndns.org","threadId":"31836","inReplyTo":"1350569750-26304-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH v3] status: refactor output format to represent \"default\" and add --long","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-10-18T21:16:11Z","receivedAt":"2012-10-18T21:16:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> From: Jeff King <peff@peff.net>\n>\n> When deciding which output format to use, we default an internal enum\n> to STATUS_FORMAT_LONG and modify it if \"--porcelain\" or \"--short\" is\n> given. If this enum is set to LONG, then we know the user has not\n> specified any format, and we can kick in default behaviors. This works\n> because there is no \"--long\" which they could use to explicitly\n> specify LONG.\n>\n> Let's expand the enum to have an explicit STATUS_FORMAT_NONE, in\n> preparation for adding \"--long\", which can be used to override --short\n> or --porcelain. Then we can distinguish between LONG and NONE when\n> setting other defaults. There are two such cases:\n>\n>   1. The user has asked for NUL termination. With NONE, we\n>      currently default to turning on the porcelain mode.\n>      With an explicit --long, we would in theory use NUL\n>      termination with the long mode, but it does not support\n>      it. So we can just complain and die.\n>\n>   2. When an output format is given to \"git commit\", we\n>      default to \"--dry-run\". This behavior would now kick in\n>      when \"--long\" is given, too.\n>\n> Signed-off-by: Jeff King <peff@peff.net>\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n>  On Thu, Oct 18, 2012 at 9:03 AM, Jeff King <peff@peff.net> wrote:\n>  > I think that is fine to split it like this, but you would want to update\n>  > the commit message above. Probably just remove those two cases and say\n>  > something like:\n>  >\n>  >   Note that you cannot actually trigger STATUS_FORMAT_LONG, as we do\n>  >   not yet have \"--long\"; that will come in a follow-on patch.\n>  >\n>  > And then move the reasoning for how \"--long\" works with each case into\n>  > the commit message of the next patch.\n>\n>  Nope, it's hard to split the explanation in two (at least to me),\n>  which may mean that the split does not make sense.\n\nI guess combining both is fine, but then the commit is no longer \"in\npreparation for adding\" the option, but it already adds \"--long\", I\nwould think.\n\nWill queue.\n\nThanks.\n"},{"id":"201527","messageId":"20121018212057.GA3192@sigill.intra.peff.net","threadId":"31836","inReplyTo":"7vtxtrlbvo.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v3] status: refactor output format to represent \"default\" and add --long","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-10-18T21:20:57Z","receivedAt":"2012-10-18T21:20:57Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Oct 18, 2012 at 02:16:11PM -0700, Junio C Hamano wrote:\n\n> I guess combining both is fine, but then the commit is no longer \"in\n> preparation for adding\" the option, but it already adds \"--long\", I\n> would think.\n\nMaybe a better commit message is:\n\n-- >8 --\nSubject: status: add --long output format option\n\nYou can currently set the output format to --short or\n--porcelain. There is no --long, because we default to it\nalready. However, you may want to override an alias that\nuses \"--short\" to get back to the default.\n\nThis requires a little bit of refactoring, because currently\nwe use STATUS_FORMAT_LONG internally to mean the same as\n\"the user did not specify anything\". By expanding the enum\nto include STATUS_FORMAT_NONE, we can distinguish between\nthe implicit and explicit cases. This effects these\nconditions:\n\n  1. The user has asked for NUL termination. With NONE, we\n     currently default to turning on the porcelain mode.\n     With an explicit --long, we would in theory use NUL\n     termination with the long mode, but it does not support\n     it. So we can just complain and die.\n\n  2. When an output format is given to \"git commit\", we\n     default to \"--dry-run\". This behavior would now kick in\n     when \"--long\" is given, too.\n"}]}