{"thread":{"id":"32082","subject":"[RFC PATCH 0/1] status: Allow for short-form output by default","startedAt":"2012-11-11T22:53:02Z","lastAt":"2012-11-12T21:17:42Z","messageCount":3,"participants":["Thomas Adam","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"202928","messageId":"1352674383-23654-1-git-send-email-thomas@xteddy.org","threadId":"32082","inReplyTo":null,"subject":"[RFC PATCH 0/1] status: Allow for short-form output by default","fromName":"Thomas Adam","fromEmail":"thomas@xteddy.org","sentAt":"2012-11-11T22:53:02Z","receivedAt":"2012-11-11T22:53:02Z","isPatch":true,"sender":{"key":"thomas@xteddy.org","avatar":"https://gravatar.com/avatar/e7256db4738e501e5d2e84f00bb0bd99503165729573848a03330301fc2adc4a?d=mp&s=160"},"body":"Hi,\n\nIt was asked recently whether git status could output the short-form instead\nof the long output (via its \"-sb\" options).  To that end, I've created a\nrough POC on how this might look.  It's deliberately lacking documentation;\nI was curious to know whether:\n\nstatus.shortwithbranch = true\n\nWas going to cut it.  Likewise, I was unsure if instead there should  be two\nseparate options, one for just short (i.e. '-s') also?\n\nWhat do others think?\n\nISTR reading on this list recently the addition of a \"--long\" option to git\nstatus?  I'm wondering how this would relate to that, if at all?\n\nKindly,\n\nThomas Adam (1):\n  status: Allow for short-form via config option\n\n builtin/commit.c | 12 ++++++++++++\n 1 file changed, 12 insertions(+)\n\n-- \n1.7.11.4\n"},{"id":"202929","messageId":"1352674383-23654-2-git-send-email-thomas@xteddy.org","threadId":"32082","inReplyTo":"1352674383-23654-1-git-send-email-thomas@xteddy.org","subject":"[RFC PATCH 1/1] status: Allow for short-form via config option","fromName":"Thomas Adam","fromEmail":"thomas@xteddy.org","sentAt":"2012-11-11T22:53:03Z","receivedAt":"2012-11-11T22:53:03Z","isPatch":true,"sender":{"key":"thomas@xteddy.org","avatar":"https://gravatar.com/avatar/e7256db4738e501e5d2e84f00bb0bd99503165729573848a03330301fc2adc4a?d=mp&s=160"},"body":"It is currently not possible to use the short-form output of git status\nwithout declaring an alias to do so.\n\nThis isn't always desirable therfore, define a git config option which can\nbe set to display the short-form:  status.shortwithbranch\n\nSigned-off-by: Thomas Adam <thomas@xteddy.org>\n---\n builtin/commit.c | 12 ++++++++++++\n 1 file changed, 12 insertions(+)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex a17a5df..552a9f1 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1142,6 +1142,18 @@ static int git_status_config(const char *k, const char *v, void *cb)\n \t\t\treturn error(_(\"Invalid untracked files mode '%s'\"), v);\n \t\treturn 0;\n \t}\n+\n+\tif (!strcmp(k, \"status.shortwithbranch\")) {\n+\t\tif (git_config_bool(k, v)) {\n+\t\t\tif (!v)\n+\t\t\t\treturn config_error_nonbool(k);\n+\t\t\telse if(!strcmp(v, \"true\")) {\n+\t\t\t\tstatus_format = STATUS_FORMAT_SHORT;\n+\t\t\t\ts->show_branch = 1;\n+\t\t\t}\n+\t\t\treturn 0;\n+\t\t}\n+\t}\n \treturn git_diff_ui_config(k, v, NULL);\n }\n \n-- \n1.7.11.4\n"},{"id":"203001","messageId":"20121112211742.GJ4623@sigill.intra.peff.net","threadId":"32082","inReplyTo":"1352674383-23654-2-git-send-email-thomas@xteddy.org","subject":"Re: [RFC PATCH 1/1] status: Allow for short-form via config option","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-11-12T21:17:42Z","receivedAt":"2012-11-12T21:17:42Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Nov 11, 2012 at 10:53:03PM +0000, Thomas Adam wrote:\n\n> It is currently not possible to use the short-form output of git status\n> without declaring an alias to do so.\n> \n> This isn't always desirable therfore, define a git config option which can\n> be set to display the short-form:  status.shortwithbranch\n\nWe usually try to avoid booleans for selection among options, even if\nthere is currently only one useful option. That way, it makes it easier\nto extend later when another option presents itself.  So having\n\"status.format\" that you could set to \"short\", \"long\", or \"porcelain\"\nwould make more sense (although \"short\" is likely to be the only useful\none currently).\n\nAnd then we can have a separate boolean like \"status.branch\" to show the\nbranch by default when showing short format. That would would naturally\nextend to more booleans as other options are added (Phil Hord's recent\n\"show tree state\" patches come to mind).\n\nWe also need to consider the impact of options on scripts. I think\nstatus.format should be OK, since any script calling \"git status\" would\nhave to explicitly pass \"--porcelain\" already, which would override this\noption. But we would want to make sure that \"status.branch\" would not\naffect the porcelain.\n\n> ---\n>  builtin/commit.c | 12 ++++++++++++\n>  1 file changed, 12 insertions(+)\n\nIt would need documentation, and tests would be good both to make sure\nthe feature works, but also to demonstrate that it does not break\n--porcelain.\n\n> diff --git a/builtin/commit.c b/builtin/commit.c\n> index a17a5df..552a9f1 100644\n> --- a/builtin/commit.c\n> +++ b/builtin/commit.c\n> @@ -1142,6 +1142,18 @@ static int git_status_config(const char *k, const char *v, void *cb)\n>  \t\t\treturn error(_(\"Invalid untracked files mode '%s'\"), v);\n>  \t\treturn 0;\n>  \t}\n> +\n> +\tif (!strcmp(k, \"status.shortwithbranch\")) {\n> +\t\tif (git_config_bool(k, v)) {\n> +\t\t\tif (!v)\n> +\t\t\t\treturn config_error_nonbool(k);\n> +\t\t\telse if(!strcmp(v, \"true\")) {\n> +\t\t\t\tstatus_format = STATUS_FORMAT_SHORT;\n> +\t\t\t\ts->show_branch = 1;\n> +\t\t\t}\n> +\t\t\treturn 0;\n> +\t\t}\n> +\t}\n\nI'm not sure what is going on with the extra nonbool and \"true\" check.\nShouldn't it just be:\n\n  if (git_config_bool(k, v)) {\n          status_format = STATUS_FORMAT_SHORT;\n          s->show_branch = 1;\n  }\n  else {\n          /* what do we do when it is false? */\n  }\n  return 0;\n\nIf we follow my suggestions above, then it would be more like:\n\n  if (!strcmp(k, \"status.format\")) {\n          if (!v)\n                  return config_error_nonbool(k);\n          return parse_status_format(v, &status_format);\n  }\n  if (!strcmp(k, \"status.branch\")) {\n          s->show_branch = git_config_bool(k, v);\n          return 0;\n  }\n\nbut that would still have to resolve the setting of show_branch when\n--porcelain is in use. I think you would need to store the\nconfig-derived value separately, and then only fill it into\ns->show_branch if no value was given on the command-line _and_ we are\nnot showing the porcelain format.\n\n-Peff\n"}]}