{"thread":{"id":"30442","subject":"[PATCH] correct git-status Porcelain Format documentation","startedAt":"2012-05-06T13:29:59Z","lastAt":"2012-05-08T17:52:18Z","messageCount":16,"participants":["Jeff King","Junio C Hamano","Nguyen Thai Ngoc Duy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"190911","messageId":"20120506132959.GA28214@sigill.intra.peff.net","threadId":"30442","inReplyTo":null,"subject":"[PATCH] correct git-status Porcelain Format documentation","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-05-06T13:29:59Z","receivedAt":"2012-05-06T13:29:59Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"From: Zak Johnson <zakj@nox.cx>\n\nThe existing documentation implies that \"git status --porcelain\" has a branch\nline while \"git status --porcelain -z\" does not; in fact, neither includes a\nbranch line.\n\nSigned-off-by: Zak Johnson <zakj@nox.cx>\n---\nThis was forward to me by the original author, who had trouble posting\nto the list. So I'm trying it (I didn't see anything from the taboo list\nin the patch, but we'll see...).\n\nThe patch itself looks obviously correct and describes the current\nbehavior. But I have to wonder: the --short format will also not produce\nthe branch line unless you provide \"-b\". So why is it that the porcelain\nformat does not respect \"-b\", since anybody who asked for it would\nobviously be expecting to find and parse it?\n\nShould this bit of documentation be dropped in favor of just making \"-b\"\nwork properly?\n\n Documentation/git-status.txt | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\nindex 2883a28..3e12020 100644\n--- a/Documentation/git-status.txt\n+++ b/Documentation/git-status.txt\n@@ -176,6 +176,8 @@ format, with a few exceptions:\n 2. The user's status.relativePaths configuration is not respected; paths\n    shown will always be relative to the repository root.\n \n+3. There is no branch line.\n+\n There is also an alternate -z format recommended for machine parsing. In\n that format, the status field is the same, but some other things\n change.  First, the '\\->' is omitted from rename entries and the field\n@@ -184,7 +186,7 @@ order is reversed (e.g 'from \\-> to' becomes 'to from'). Second, a NUL\n and the terminating newline (but a space still separates the status\n field from the first filename).  Third, filenames containing special\n characters are not specially formatted; no quoting or\n-backslash-escaping is performed. Fourth, there is no branch line.\n+backslash-escaping is performed.\n \n CONFIGURATION\n -------------\n-- \n1.7.10.1.14.gb97aca1\n"},{"id":"190914","messageId":"20120506135141.GA17176@sigill.intra.peff.net","threadId":"30442","inReplyTo":"20120506132959.GA28214@sigill.intra.peff.net","subject":"Re: [PATCH] correct git-status Porcelain Format documentation","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-05-06T13:51:42Z","receivedAt":"2012-05-06T13:51:42Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"[+cc Zak, who I forgot in the first email]\n\nOn Sun, May 06, 2012 at 09:29:59AM -0400, Jeff King wrote:\n\n> From: Zak Johnson <zakj@nox.cx>\n> \n> The existing documentation implies that \"git status --porcelain\" has a branch\n> line while \"git status --porcelain -z\" does not; in fact, neither includes a\n> branch line.\n> \n> Signed-off-by: Zak Johnson <zakj@nox.cx>\n> ---\n> This was forward to me by the original author, who had trouble posting\n> to the list. So I'm trying it (I didn't see anything from the taboo list\n> in the patch, but we'll see...).\n> \n> The patch itself looks obviously correct and describes the current\n> behavior. But I have to wonder: the --short format will also not produce\n> the branch line unless you provide \"-b\". So why is it that the porcelain\n> format does not respect \"-b\", since anybody who asked for it would\n> obviously be expecting to find and parse it?\n> \n> Should this bit of documentation be dropped in favor of just making \"-b\"\n> work properly?\n\nSo that patch could look like the one below. But that brings up new\nconfusion.\n\nWhat should \"git status --porcelain -z -b\" look like? With my patch, it\nprints the branch-line with only a newline, not respecting the NUL\ntermination. Which sounds like a bug, except that's what happens _now_\nwith \"git status --short -z -b\".  Which seems like a bug to me, but\nmaybe somebody is relying on that. It seems kind of broken to me.\n\nAlso, while looking at the documentation, we say of \"-z\": \"This implies\nthe --porcelain output format if no other format is given\". But the only\nother format you could give is \"--short\", since there is no way to ask\nfor the long output (and nor do we handle NUL-termination in that code,\nanyway). Should this be simplified to just \"this implies porcelain\"?\nThat would technically break somebody who wanted their\nstatus.relativePaths config option respected. But it kind of seems crazy\nto me.\n\n-- >8 --\nSubject: [PATCH] status: respect \"-b\" for porcelain format\n\nThere is no reason not to, as the user has to explicitly ask\nfor it, so we are not breaking compatibility by doing so.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n Documentation/git-status.txt | 2 +-\n builtin/commit.c             | 4 ++--\n t/t7508-status.sh            | 8 ++++++--\n wt-status.c                  | 5 +++--\n wt-status.h                  | 2 +-\n 5 files changed, 13 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\nindex 2883a28..67e5f53 100644\n--- a/Documentation/git-status.txt\n+++ b/Documentation/git-status.txt\n@@ -184,7 +184,7 @@ order is reversed (e.g 'from \\-> to' becomes 'to from'). Second, a NUL\n and the terminating newline (but a space still separates the status\n field from the first filename).  Third, filenames containing special\n characters are not specially formatted; no quoting or\n-backslash-escaping is performed. Fourth, there is no branch line.\n+backslash-escaping is performed.\n \n CONFIGURATION\n -------------\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex a876a73..0e898e6 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -504,7 +504,7 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int\n \t\twt_shortstatus_print(s, null_termination, status_show_branch);\n \t\tbreak;\n \tcase STATUS_FORMAT_PORCELAIN:\n-\t\twt_porcelain_print(s, null_termination);\n+\t\twt_porcelain_print(s, null_termination, status_show_branch);\n \t\tbreak;\n \tcase STATUS_FORMAT_LONG:\n \t\twt_status_print(s);\n@@ -1287,7 +1287,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \t\twt_shortstatus_print(&s, null_termination, status_show_branch);\n \t\tbreak;\n \tcase STATUS_FORMAT_PORCELAIN:\n-\t\twt_porcelain_print(&s, null_termination);\n+\t\twt_porcelain_print(&s, null_termination, status_show_branch);\n \t\tbreak;\n \tcase STATUS_FORMAT_LONG:\n \t\ts.verbose = verbose;\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex 8f5cfac..695b6a8 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -671,11 +671,15 @@ test_expect_success 'status --porcelain ignores color.status' '\n git config --unset color.status\n git config --unset color.ui\n \n-test_expect_success 'status --porcelain ignores -b' '\n+test_expect_success 'status --porcelain respects -b' '\n \n \tgit status --porcelain -b >output &&\n+\t{\n+\t\techo \"## master\" &&\n+\t\tcat expect\n+\t} >tmp &&\n+\tmv tmp expect &&\n \ttest_cmp expect output\n-\n '\n \n cat >expect <<\\EOF\ndiff --git a/wt-status.c b/wt-status.c\nindex eeef17e..7d2dbcd 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -973,10 +973,11 @@ void wt_shortstatus_print(struct wt_status *s, int null_termination, int show_br\n \t}\n }\n \n-void wt_porcelain_print(struct wt_status *s, int null_termination)\n+void wt_porcelain_print(struct wt_status *s, int null_termination,\n+\t\t\tint show_branch)\n {\n \ts->use_color = 0;\n \ts->relative_paths = 0;\n \ts->prefix = NULL;\n-\twt_shortstatus_print(s, null_termination, 0);\n+\twt_shortstatus_print(s, null_termination, show_branch);\n }\ndiff --git a/wt-status.h b/wt-status.h\nindex 6dd7207..b8e8758 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -74,7 +74,7 @@ void wt_status_print(struct wt_status *s);\n void wt_status_collect(struct wt_status *s);\n \n void wt_shortstatus_print(struct wt_status *s, int null_termination, int show_branch);\n-void wt_porcelain_print(struct wt_status *s, int null_termination);\n+void wt_porcelain_print(struct wt_status *s, int null_termination, int show_branch);\n \n void status_printf_ln(struct wt_status *s, const char *color, const char *fmt, ...)\n \t;\n-- \n1.7.10.1.14.gb97aca1\n"},{"id":"191016","messageId":"7vsjfb6f7y.fsf@alter.siamese.dyndns.org","threadId":"30442","inReplyTo":"20120506132959.GA28214@sigill.intra.peff.net","subject":"Re: [PATCH] correct git-status Porcelain Format documentation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-05-07T18:03:29Z","receivedAt":"2012-05-07T18:03:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> The patch itself looks obviously correct and describes the current\n> behavior. But I have to wonder: the --short format will also not produce\n> the branch line unless you provide \"-b\". So why is it that the porcelain\n> format does not respect \"-b\", since anybody who asked for it would\n> obviously be expecting to find and parse it?\n>\n> Should this bit of documentation be dropped in favor of just making \"-b\"\n> work properly?\n\nI would say so.  Also \"branch line\" was an undefined term and I had to\nread the whole thing to find out what the updated documentation was\ntalking about; we may want to consistently say \"branch and tracking info\"\nas the earlier part of the document says.\n"},{"id":"191017","messageId":"7vobpz6ewg.fsf@alter.siamese.dyndns.org","threadId":"30442","inReplyTo":"20120506135141.GA17176@sigill.intra.peff.net","subject":"Re: [PATCH] correct git-status Porcelain Format documentation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-05-07T18:10:23Z","receivedAt":"2012-05-07T18:10:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> What should \"git status --porcelain -z -b\" look like? With my patch, it\n> prints the branch-line with only a newline, not respecting the NUL\n> termination. Which sounds like a bug, except that's what happens _now_\n> with \"git status --short -z -b\".  Which seems like a bug to me, but\n> maybe somebody is relying on that. It seems kind of broken to me.\n\nIt is broken; and it is not a problem if somebody relied on a broken\noutput without giving --porcelain in a script and such a script needs to\nbe updated.  If we are updating the code to give \"## <branch>\" in the\noutput under the \"--porcelain\", let's do that right from the beginning.\n\n> Also, while looking at the documentation, we say of \"-z\": \"This implies\n> the --porcelain output format if no other format is given\". But the only\n> other format you could give is \"--short\", since there is no way to ask\n> for the long output (and nor do we handle NUL-termination in that code,\n> anyway).\n\n... nor do we define long porcelain format to begin with.\n\n> Should this be simplified to just \"this implies porcelain\"?\n>\n> That would technically break somebody who wanted their\n> status.relativePaths config option respected. But it kind of seems crazy\n> to me.\n\nI do not think it is worth changing it.  It is not too much touble to\nspell \"status --porcelain -z <whatever else>\" in a Porcelain script only\nonce and forget about it.\n"},{"id":"191018","messageId":"20120507181348.GA26977@sigill.intra.peff.net","threadId":"30442","inReplyTo":"7vobpz6ewg.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] correct git-status Porcelain Format documentation","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-05-07T18:13:48Z","receivedAt":"2012-05-07T18:13:48Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, May 07, 2012 at 11:10:23AM -0700, Junio C Hamano wrote:\n\n> Jeff King <peff@peff.net> writes:\n> \n> > What should \"git status --porcelain -z -b\" look like? With my patch, it\n> > prints the branch-line with only a newline, not respecting the NUL\n> > termination. Which sounds like a bug, except that's what happens _now_\n> > with \"git status --short -z -b\".  Which seems like a bug to me, but\n> > maybe somebody is relying on that. It seems kind of broken to me.\n> \n> It is broken; and it is not a problem if somebody relied on a broken\n> output without giving --porcelain in a script and such a script needs to\n> be updated.  If we are updating the code to give \"## <branch>\" in the\n> output under the \"--porcelain\", let's do that right from the beginning.\n\nOK, that matches my feelings.\n\n> > Should this be simplified to just \"this implies porcelain\"?\n> >\n> > That would technically break somebody who wanted their\n> > status.relativePaths config option respected. But it kind of seems crazy\n> > to me.\n> \n> I do not think it is worth changing it.  It is not too much touble to\n> spell \"status --porcelain -z <whatever else>\" in a Porcelain script only\n> once and forget about it.\n\nOK. I think it makes it conceptually simpler, but of the problems I\nlisted, that is the least bug-like.\n\nI'll prepare a series to fix \"-b -z\" and \"-b --porcelain\".\n\n-Peff\n"},{"id":"191035","messageId":"20120507212125.GA19532@sigill.intra.peff.net","threadId":"30442","inReplyTo":"20120507181348.GA26977@sigill.intra.peff.net","subject":"Re: [PATCH] correct git-status Porcelain Format documentation","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-05-07T21:21:25Z","receivedAt":"2012-05-07T21:21:25Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, May 07, 2012 at 02:13:48PM -0400, Jeff King wrote:\n\n> I'll prepare a series to fix \"-b -z\" and \"-b --porcelain\".\n\nHere's that series:\n\n  [1/5]: commit: refactor option parsing\n  [2/5]: status: refactor colopts handling\n  [3/5]: status: refactor null_termination option\n  [4/5]: status: fix null termination with \"-b\"\n  [5/5]: status: respect \"-b\" for porcelain format\n\nPatches 1 and 3 are cleanups to aid 4 and 5, which are the real fixes.\nPatch 2 is an optional cleanup I noticed while in the area.\n\n-Peff\n"},{"id":"191036","messageId":"20120507212208.GA19567@sigill.intra.peff.net","threadId":"30442","inReplyTo":"20120507212125.GA19532@sigill.intra.peff.net","subject":"[PATCH 1/5] commit: refactor option parsing","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-05-07T21:22:08Z","receivedAt":"2012-05-07T21:22:08Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"The options are declared as a static global, but really they\nneed only be accessible from cmd_commit. Putting them there\nwill allow us to directly reference local variables in the\noptions list, which will facilitate further cleanups.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n builtin/commit.c | 113 ++++++++++++++++++++++++++++---------------------------\n 1 file changed, 57 insertions(+), 56 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex a876a73..5f48e8a 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -131,59 +131,6 @@ static int opt_parse_m(const struct option *opt, const char *arg, int unset)\n \treturn 0;\n }\n \n-static struct option builtin_commit_options[] = {\n-\tOPT__QUIET(&quiet, \"suppress summary after successful commit\"),\n-\tOPT__VERBOSE(&verbose, \"show diff in commit message template\"),\n-\n-\tOPT_GROUP(\"Commit message options\"),\n-\tOPT_FILENAME('F', \"file\", &logfile, \"read message from file\"),\n-\tOPT_STRING(0, \"author\", &force_author, \"author\", \"override author for commit\"),\n-\tOPT_STRING(0, \"date\", &force_date, \"date\", \"override date for commit\"),\n-\tOPT_CALLBACK('m', \"message\", &message, \"message\", \"commit message\", opt_parse_m),\n-\tOPT_STRING('c', \"reedit-message\", &edit_message, \"commit\", \"reuse and edit message from specified commit\"),\n-\tOPT_STRING('C', \"reuse-message\", &use_message, \"commit\", \"reuse message from specified commit\"),\n-\tOPT_STRING(0, \"fixup\", &fixup_message, \"commit\", \"use autosquash formatted message to fixup specified commit\"),\n-\tOPT_STRING(0, \"squash\", &squash_message, \"commit\", \"use autosquash formatted message to squash specified commit\"),\n-\tOPT_BOOLEAN(0, \"reset-author\", &renew_authorship, \"the commit is authored by me now (used with -C/-c/--amend)\"),\n-\tOPT_BOOLEAN('s', \"signoff\", &signoff, \"add Signed-off-by:\"),\n-\tOPT_FILENAME('t', \"template\", &template_file, \"use specified template file\"),\n-\tOPT_BOOL('e', \"edit\", &edit_flag, \"force edit of commit\"),\n-\tOPT_STRING(0, \"cleanup\", &cleanup_arg, \"default\", \"how to strip spaces and #comments from message\"),\n-\tOPT_BOOLEAN(0, \"status\", &include_status, \"include status in commit message template\"),\n-\t{ OPTION_STRING, 'S', \"gpg-sign\", &sign_commit, \"key id\",\n-\t  \"GPG sign commit\", PARSE_OPT_OPTARG, NULL, (intptr_t) \"\" },\n-\t/* end commit message options */\n-\n-\tOPT_GROUP(\"Commit contents options\"),\n-\tOPT_BOOLEAN('a', \"all\", &all, \"commit all changed files\"),\n-\tOPT_BOOLEAN('i', \"include\", &also, \"add specified files to index for commit\"),\n-\tOPT_BOOLEAN(0, \"interactive\", &interactive, \"interactively add files\"),\n-\tOPT_BOOLEAN('p', \"patch\", &patch_interactive, \"interactively add changes\"),\n-\tOPT_BOOLEAN('o', \"only\", &only, \"commit only specified files\"),\n-\tOPT_BOOLEAN('n', \"no-verify\", &no_verify, \"bypass pre-commit hook\"),\n-\tOPT_BOOLEAN(0, \"dry-run\", &dry_run, \"show what would be committed\"),\n-\tOPT_SET_INT(0, \"short\", &status_format, \"show status concisely\",\n-\t\t    STATUS_FORMAT_SHORT),\n-\tOPT_BOOLEAN(0, \"branch\", &status_show_branch, \"show branch information\"),\n-\tOPT_SET_INT(0, \"porcelain\", &status_format,\n-\t\t    \"machine-readable output\", STATUS_FORMAT_PORCELAIN),\n-\tOPT_BOOLEAN('z', \"null\", &null_termination,\n-\t\t    \"terminate entries with NUL\"),\n-\tOPT_BOOLEAN(0, \"amend\", &amend, \"amend previous commit\"),\n-\tOPT_BOOLEAN(0, \"no-post-rewrite\", &no_post_rewrite, \"bypass post-rewrite hook\"),\n-\t{ OPTION_STRING, 'u', \"untracked-files\", &untracked_files_arg, \"mode\", \"show untracked files, optional modes: all, normal, no. (Default: all)\", PARSE_OPT_OPTARG, NULL, (intptr_t)\"all\" },\n-\t/* end commit contents options */\n-\n-\t{ OPTION_BOOLEAN, 0, \"allow-empty\", &allow_empty, NULL,\n-\t  \"ok to record an empty change\",\n-\t  PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },\n-\t{ OPTION_BOOLEAN, 0, \"allow-empty-message\", &allow_empty_message, NULL,\n-\t  \"ok to record a change with an empty message\",\n-\t  PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },\n-\n-\tOPT_END()\n-};\n-\n static void determine_whence(struct wt_status *s)\n {\n \tif (file_exists(git_path(\"MERGE_HEAD\")))\n@@ -1037,6 +984,7 @@ static const char *read_commit_message(const char *name)\n }\n \n static int parse_and_validate_options(int argc, const char *argv[],\n+\t\t\t\t      const struct option *options,\n \t\t\t\t      const char * const usage[],\n \t\t\t\t      const char *prefix,\n \t\t\t\t      struct commit *current_head,\n@@ -1044,8 +992,7 @@ static int parse_and_validate_options(int argc, const char *argv[],\n {\n \tint f = 0;\n \n-\targc = parse_options(argc, argv, prefix, builtin_commit_options, usage,\n-\t\t\t     0);\n+\targc = parse_options(argc, argv, prefix, options, usage, 0);\n \n \tif (force_author && !strchr(force_author, '>'))\n \t\tforce_author = find_author_by_nickname(force_author);\n@@ -1422,6 +1369,59 @@ static int run_rewrite_hook(const unsigned char *oldsha1,\n \n int cmd_commit(int argc, const char **argv, const char *prefix)\n {\n+\tstatic struct option builtin_commit_options[] = {\n+\t\tOPT__QUIET(&quiet, \"suppress summary after successful commit\"),\n+\t\tOPT__VERBOSE(&verbose, \"show diff in commit message template\"),\n+\n+\t\tOPT_GROUP(\"Commit message options\"),\n+\t\tOPT_FILENAME('F', \"file\", &logfile, \"read message from file\"),\n+\t\tOPT_STRING(0, \"author\", &force_author, \"author\", \"override author for commit\"),\n+\t\tOPT_STRING(0, \"date\", &force_date, \"date\", \"override date for commit\"),\n+\t\tOPT_CALLBACK('m', \"message\", &message, \"message\", \"commit message\", opt_parse_m),\n+\t\tOPT_STRING('c', \"reedit-message\", &edit_message, \"commit\", \"reuse and edit message from specified commit\"),\n+\t\tOPT_STRING('C', \"reuse-message\", &use_message, \"commit\", \"reuse message from specified commit\"),\n+\t\tOPT_STRING(0, \"fixup\", &fixup_message, \"commit\", \"use autosquash formatted message to fixup specified commit\"),\n+\t\tOPT_STRING(0, \"squash\", &squash_message, \"commit\", \"use autosquash formatted message to squash specified commit\"),\n+\t\tOPT_BOOLEAN(0, \"reset-author\", &renew_authorship, \"the commit is authored by me now (used with -C/-c/--amend)\"),\n+\t\tOPT_BOOLEAN('s', \"signoff\", &signoff, \"add Signed-off-by:\"),\n+\t\tOPT_FILENAME('t', \"template\", &template_file, \"use specified template file\"),\n+\t\tOPT_BOOL('e', \"edit\", &edit_flag, \"force edit of commit\"),\n+\t\tOPT_STRING(0, \"cleanup\", &cleanup_arg, \"default\", \"how to strip spaces and #comments from message\"),\n+\t\tOPT_BOOLEAN(0, \"status\", &include_status, \"include status in commit message template\"),\n+\t\t{ OPTION_STRING, 'S', \"gpg-sign\", &sign_commit, \"key id\",\n+\t\t  \"GPG sign commit\", PARSE_OPT_OPTARG, NULL, (intptr_t) \"\" },\n+\t\t/* end commit message options */\n+\n+\t\tOPT_GROUP(\"Commit contents options\"),\n+\t\tOPT_BOOLEAN('a', \"all\", &all, \"commit all changed files\"),\n+\t\tOPT_BOOLEAN('i', \"include\", &also, \"add specified files to index for commit\"),\n+\t\tOPT_BOOLEAN(0, \"interactive\", &interactive, \"interactively add files\"),\n+\t\tOPT_BOOLEAN('p', \"patch\", &patch_interactive, \"interactively add changes\"),\n+\t\tOPT_BOOLEAN('o', \"only\", &only, \"commit only specified files\"),\n+\t\tOPT_BOOLEAN('n', \"no-verify\", &no_verify, \"bypass pre-commit hook\"),\n+\t\tOPT_BOOLEAN(0, \"dry-run\", &dry_run, \"show what would be committed\"),\n+\t\tOPT_SET_INT(0, \"short\", &status_format, \"show status concisely\",\n+\t\t\t    STATUS_FORMAT_SHORT),\n+\t\tOPT_BOOLEAN(0, \"branch\", &status_show_branch, \"show branch information\"),\n+\t\tOPT_SET_INT(0, \"porcelain\", &status_format,\n+\t\t\t    \"machine-readable output\", STATUS_FORMAT_PORCELAIN),\n+\t\tOPT_BOOLEAN('z', \"null\", &null_termination,\n+\t\t\t    \"terminate entries with NUL\"),\n+\t\tOPT_BOOLEAN(0, \"amend\", &amend, \"amend previous commit\"),\n+\t\tOPT_BOOLEAN(0, \"no-post-rewrite\", &no_post_rewrite, \"bypass post-rewrite hook\"),\n+\t\t{ OPTION_STRING, 'u', \"untracked-files\", &untracked_files_arg, \"mode\", \"show untracked files, optional modes: all, normal, no. (Default: all)\", PARSE_OPT_OPTARG, NULL, (intptr_t)\"all\" },\n+\t\t/* end commit contents options */\n+\n+\t\t{ OPTION_BOOLEAN, 0, \"allow-empty\", &allow_empty, NULL,\n+\t\t  \"ok to record an empty change\",\n+\t\t  PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },\n+\t\t{ OPTION_BOOLEAN, 0, \"allow-empty-message\", &allow_empty_message, NULL,\n+\t\t  \"ok to record a change with an empty message\",\n+\t\t  PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },\n+\n+\t\tOPT_END()\n+\t};\n+\n \tstruct strbuf sb = STRBUF_INIT;\n \tstruct strbuf author_ident = STRBUF_INIT;\n \tconst char *index_file, *reflog_msg;\n@@ -1449,7 +1449,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\tif (!current_head || parse_commit(current_head))\n \t\t\tdie(_(\"could not parse HEAD commit\"));\n \t}\n-\targc = parse_and_validate_options(argc, argv, builtin_commit_usage,\n+\targc = parse_and_validate_options(argc, argv, builtin_commit_options,\n+\t\t\t\t\t  builtin_commit_usage,\n \t\t\t\t\t  prefix, current_head, &s);\n \tif (dry_run)\n \t\treturn dry_run_commit(argc, argv, prefix, current_head, &s);\n-- \n1.7.10.1.12.gd79f7ab\n"},{"id":"191037","messageId":"20120507212333.GB19567@sigill.intra.peff.net","threadId":"30442","inReplyTo":"20120507212125.GA19532@sigill.intra.peff.net","subject":"[PATCH 2/5] status: refactor colopts handling","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-05-07T21:23:33Z","receivedAt":"2012-05-07T21:23:33Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"The current code reads the config and command-line options\ninto a separate \"colopts\" variable, and then copies the\ncontents of that variable into the \"struct wt_status\". We\ncan eliminate the extra variable and copy just write\nstraight into the wt_status struct.\n\nThis simplifies the \"status\" code a little bit.\nUnfortunately, it makes the \"commit\" code one line more\ncomplex; a side effect of the separate variable was that\n\"commit\" did not copy the colopts variable, so any\ncolumn.status configuration had no effect.\n\nThe result still ends up cleaner, though. In the previous\nversion, it was unclear whether commit simply forgot to copy\nthe colopt variable, or whether it was intentional. Now it\nexplicitly turns off column options. Furthermore, if commit\nlater learns to respect column.status, this will make the\nend result simpler. I punted on just adding that feature\nnow, because it was sufficiently non-obvious that it should\nnot go into a refactoring patch.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nFor the reasons mentioned above, this ended up as a less impressive\ncleanup than I had hoped. I think it's still worth doing, but I won't be\ntoo sad if it gets dropped.\n\n builtin/commit.c | 13 ++++++-------\n wt-status.h      |  2 +-\n 2 files changed, 7 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 5f48e8a..1a69cb0 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -89,7 +89,6 @@ static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;\n static int no_post_rewrite, allow_empty_message;\n static char *untracked_files_arg, *force_date, *ignore_submodule_arg;\n static char *sign_commit;\n-static unsigned int colopts;\n \n /*\n  * The default commit message cleanup mode will remove the lines\n@@ -1123,7 +1122,7 @@ static int git_status_config(const char *k, const char *v, void *cb)\n \tstruct wt_status *s = cb;\n \n \tif (!prefixcmp(k, \"column.\"))\n-\t\treturn git_column_config(k, v, \"status\", &colopts);\n+\t\treturn git_column_config(k, v, \"status\", &s->colopts);\n \tif (!strcmp(k, \"status.submodulesummary\")) {\n \t\tint is_bool;\n \t\ts->submodule_summary = git_config_bool_or_int(k, v, &is_bool);\n@@ -1166,7 +1165,7 @@ static int git_status_config(const char *k, const char *v, void *cb)\n \n int cmd_status(int argc, const char **argv, const char *prefix)\n {\n-\tstruct wt_status s;\n+\tstatic struct wt_status s;\n \tint fd;\n \tunsigned char sha1[20];\n \tstatic struct option builtin_status_options[] = {\n@@ -1189,7 +1188,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \t\t{ OPTION_STRING, 0, \"ignore-submodules\", &ignore_submodule_arg, \"when\",\n \t\t  \"ignore changes to submodules, optional when: all, dirty, untracked. (Default: all)\",\n \t\t  PARSE_OPT_OPTARG, NULL, (intptr_t)\"all\" },\n-\t\tOPT_COLUMN(0, \"column\", &colopts, \"list untracked files in columns\"),\n+\t\tOPT_COLUMN(0, \"column\", &s.colopts, \"list untracked files in columns\"),\n \t\tOPT_END(),\n \t};\n \n@@ -1203,8 +1202,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \targc = parse_options(argc, argv, prefix,\n \t\t\t     builtin_status_options,\n \t\t\t     builtin_status_usage, 0);\n-\tfinalize_colopts(&colopts, -1);\n-\ts.colopts = colopts;\n+\tfinalize_colopts(&s.colopts, -1);\n \n \tif (null_termination && status_format == STATUS_FORMAT_LONG)\n \t\tstatus_format = STATUS_FORMAT_PORCELAIN;\n@@ -1369,6 +1367,7 @@ static int run_rewrite_hook(const unsigned char *oldsha1,\n \n int cmd_commit(int argc, const char **argv, const char *prefix)\n {\n+\tstatic struct wt_status s;\n \tstatic struct option builtin_commit_options[] = {\n \t\tOPT__QUIET(&quiet, \"suppress summary after successful commit\"),\n \t\tOPT__VERBOSE(&verbose, \"show diff in commit message template\"),\n@@ -1431,7 +1430,6 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \tstruct commit_list *parents = NULL, **pptr = &parents;\n \tstruct stat statbuf;\n \tint allow_fast_forward = 1;\n-\tstruct wt_status s;\n \tstruct commit *current_head = NULL;\n \tstruct commit_extra_header *extra = NULL;\n \n@@ -1441,6 +1439,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \twt_status_prepare(&s);\n \tgit_config(git_commit_config, &s);\n \tdetermine_whence(&s);\n+\ts.colopts = 0;\n \n \tif (get_sha1(\"HEAD\", sha1))\n \t\tcurrent_head = NULL;\ndiff --git a/wt-status.h b/wt-status.h\nindex 6dd7207..5386077 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -56,7 +56,7 @@ struct wt_status {\n \tenum untracked_status_type show_untracked_files;\n \tconst char *ignore_submodule_arg;\n \tchar color_palette[WT_STATUS_MAXSLOT][COLOR_MAXLEN];\n-\tint colopts;\n+\tunsigned colopts;\n \n \t/* These are computed during processing of the individual sections */\n \tint commitable;\n-- \n1.7.10.1.12.gd79f7ab\n"},{"id":"191038","messageId":"20120507212423.GC19567@sigill.intra.peff.net","threadId":"30442","inReplyTo":"20120507212125.GA19532@sigill.intra.peff.net","subject":"[PATCH 3/5] status: refactor null_termination option","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-05-07T21:24:23Z","receivedAt":"2012-05-07T21:24:23Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"This option is passed separately to the wt_status printing\nfunctions, whereas every other formatting option is\ncontained in the wt_status struct itself. Let's do the same\nhere, so we can avoid passing it around through the call\nstack.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n builtin/commit.c | 17 ++++++++---------\n wt-status.c      | 26 +++++++++++++-------------\n wt-status.h      |  5 +++--\n 3 files changed, 24 insertions(+), 24 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 1a69cb0..11271c0 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -110,7 +110,6 @@ static int show_ignored_in_status;\n static const char *only_include_assumed;\n static struct strbuf message = STRBUF_INIT;\n \n-static int null_termination;\n static enum {\n \tSTATUS_FORMAT_LONG,\n \tSTATUS_FORMAT_SHORT,\n@@ -447,10 +446,10 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int\n \n \tswitch (status_format) {\n \tcase STATUS_FORMAT_SHORT:\n-\t\twt_shortstatus_print(s, null_termination, status_show_branch);\n+\t\twt_shortstatus_print(s, status_show_branch);\n \t\tbreak;\n \tcase STATUS_FORMAT_PORCELAIN:\n-\t\twt_porcelain_print(s, null_termination);\n+\t\twt_porcelain_print(s);\n \t\tbreak;\n \tcase STATUS_FORMAT_LONG:\n \t\twt_status_print(s);\n@@ -1076,7 +1075,7 @@ 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 (null_termination && status_format == STATUS_FORMAT_LONG)\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 \t\tdry_run = 1;\n@@ -1177,7 +1176,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \t\tOPT_SET_INT(0, \"porcelain\", &status_format,\n \t\t\t    \"machine-readable output\",\n \t\t\t    STATUS_FORMAT_PORCELAIN),\n-\t\tOPT_BOOLEAN('z', \"null\", &null_termination,\n+\t\tOPT_BOOLEAN('z', \"null\", &s.null_termination,\n \t\t\t    \"terminate entries with NUL\"),\n \t\t{ OPTION_STRING, 'u', \"untracked-files\", &untracked_files_arg,\n \t\t  \"mode\",\n@@ -1204,7 +1203,7 @@ 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 (null_termination && status_format == STATUS_FORMAT_LONG)\n+\tif (s.null_termination && status_format == STATUS_FORMAT_LONG)\n \t\tstatus_format = STATUS_FORMAT_PORCELAIN;\n \n \thandle_untracked_files_arg(&s);\n@@ -1229,10 +1228,10 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \n \tswitch (status_format) {\n \tcase STATUS_FORMAT_SHORT:\n-\t\twt_shortstatus_print(&s, null_termination, status_show_branch);\n+\t\twt_shortstatus_print(&s, status_show_branch);\n \t\tbreak;\n \tcase STATUS_FORMAT_PORCELAIN:\n-\t\twt_porcelain_print(&s, null_termination);\n+\t\twt_porcelain_print(&s);\n \t\tbreak;\n \tcase STATUS_FORMAT_LONG:\n \t\ts.verbose = verbose;\n@@ -1404,7 +1403,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOLEAN(0, \"branch\", &status_show_branch, \"show branch information\"),\n \t\tOPT_SET_INT(0, \"porcelain\", &status_format,\n \t\t\t    \"machine-readable output\", STATUS_FORMAT_PORCELAIN),\n-\t\tOPT_BOOLEAN('z', \"null\", &null_termination,\n+\t\tOPT_BOOLEAN('z', \"null\", &s.null_termination,\n \t\t\t    \"terminate entries with NUL\"),\n \t\tOPT_BOOLEAN(0, \"amend\", &amend, \"amend previous commit\"),\n \t\tOPT_BOOLEAN(0, \"no-post-rewrite\", &no_post_rewrite, \"bypass post-rewrite hook\"),\ndiff --git a/wt-status.c b/wt-status.c\nindex eeef17e..284dc61 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -801,7 +801,7 @@ void wt_status_print(struct wt_status *s)\n \t}\n }\n \n-static void wt_shortstatus_unmerged(int null_termination, struct string_list_item *it,\n+static void wt_shortstatus_unmerged(struct string_list_item *it,\n \t\t\t   struct wt_status *s)\n {\n \tstruct wt_status_change_data *d = it->util;\n@@ -817,7 +817,7 @@ static void wt_shortstatus_unmerged(int null_termination, struct string_list_ite\n \tcase 7: how = \"UU\"; break; /* both modified */\n \t}\n \tcolor_fprintf(s->fp, color(WT_STATUS_UNMERGED, s), \"%s\", how);\n-\tif (null_termination) {\n+\tif (s->null_termination) {\n \t\tfprintf(stdout, \" %s%c\", it->string, 0);\n \t} else {\n \t\tstruct strbuf onebuf = STRBUF_INIT;\n@@ -828,7 +828,7 @@ static void wt_shortstatus_unmerged(int null_termination, struct string_list_ite\n \t}\n }\n \n-static void wt_shortstatus_status(int null_termination, struct string_list_item *it,\n+static void wt_shortstatus_status(struct string_list_item *it,\n \t\t\t struct wt_status *s)\n {\n \tstruct wt_status_change_data *d = it->util;\n@@ -842,7 +842,7 @@ static void wt_shortstatus_status(int null_termination, struct string_list_item\n \telse\n \t\tputchar(' ');\n \tputchar(' ');\n-\tif (null_termination) {\n+\tif (s->null_termination) {\n \t\tfprintf(stdout, \"%s%c\", it->string, 0);\n \t\tif (d->head_path)\n \t\t\tfprintf(stdout, \"%s%c\", d->head_path, 0);\n@@ -870,10 +870,10 @@ static void wt_shortstatus_status(int null_termination, struct string_list_item\n \t}\n }\n \n-static void wt_shortstatus_other(int null_termination, struct string_list_item *it,\n+static void wt_shortstatus_other(struct string_list_item *it,\n \t\t\t\t struct wt_status *s, const char *sign)\n {\n-\tif (null_termination) {\n+\tif (s->null_termination) {\n \t\tfprintf(stdout, \"%s %s%c\", sign, it->string, 0);\n \t} else {\n \t\tstruct strbuf onebuf = STRBUF_INIT;\n@@ -941,7 +941,7 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)\n \tcolor_fprintf_ln(s->fp, header_color, \"]\");\n }\n \n-void wt_shortstatus_print(struct wt_status *s, int null_termination, int show_branch)\n+void wt_shortstatus_print(struct wt_status *s, int show_branch)\n {\n \tint i;\n \n@@ -955,28 +955,28 @@ void wt_shortstatus_print(struct wt_status *s, int null_termination, int show_br\n \t\tit = &(s->change.items[i]);\n \t\td = it->util;\n \t\tif (d->stagemask)\n-\t\t\twt_shortstatus_unmerged(null_termination, it, s);\n+\t\t\twt_shortstatus_unmerged(it, s);\n \t\telse\n-\t\t\twt_shortstatus_status(null_termination, it, s);\n+\t\t\twt_shortstatus_status(it, s);\n \t}\n \tfor (i = 0; i < s->untracked.nr; i++) {\n \t\tstruct string_list_item *it;\n \n \t\tit = &(s->untracked.items[i]);\n-\t\twt_shortstatus_other(null_termination, it, s, \"??\");\n+\t\twt_shortstatus_other(it, s, \"??\");\n \t}\n \tfor (i = 0; i < s->ignored.nr; i++) {\n \t\tstruct string_list_item *it;\n \n \t\tit = &(s->ignored.items[i]);\n-\t\twt_shortstatus_other(null_termination, it, s, \"!!\");\n+\t\twt_shortstatus_other(it, s, \"!!\");\n \t}\n }\n \n-void wt_porcelain_print(struct wt_status *s, int null_termination)\n+void wt_porcelain_print(struct wt_status *s)\n {\n \ts->use_color = 0;\n \ts->relative_paths = 0;\n \ts->prefix = NULL;\n-\twt_shortstatus_print(s, null_termination, 0);\n+\twt_shortstatus_print(s, 0);\n }\ndiff --git a/wt-status.h b/wt-status.h\nindex 5386077..26dd21a 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -57,6 +57,7 @@ struct wt_status {\n \tconst char *ignore_submodule_arg;\n \tchar color_palette[WT_STATUS_MAXSLOT][COLOR_MAXLEN];\n \tunsigned colopts;\n+\tint null_termination;\n \n \t/* These are computed during processing of the individual sections */\n \tint commitable;\n@@ -73,8 +74,8 @@ void wt_status_prepare(struct wt_status *s);\n void wt_status_print(struct wt_status *s);\n void wt_status_collect(struct wt_status *s);\n \n-void wt_shortstatus_print(struct wt_status *s, int null_termination, int show_branch);\n-void wt_porcelain_print(struct wt_status *s, int null_termination);\n+void wt_shortstatus_print(struct wt_status *s, int show_branch);\n+void wt_porcelain_print(struct wt_status *s);\n \n void status_printf_ln(struct wt_status *s, const char *color, const char *fmt, ...)\n \t;\n-- \n1.7.10.1.12.gd79f7ab\n"},{"id":"191039","messageId":"20120507212438.GD19567@sigill.intra.peff.net","threadId":"30442","inReplyTo":"20120507212125.GA19532@sigill.intra.peff.net","subject":"[PATCH 4/5] status: fix null termination with \"-b\"","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-05-07T21:24:38Z","receivedAt":"2012-05-07T21:24:38Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"When the \"-z\" option is given to status, we are supposed to\nNUL-terminate each record. However, the \"-b\" code to show\nthe tracking branch did not respect this, and always ended\nwith a newline.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n t/t7508-status.sh | 9 +++++++++\n wt-status.c       | 7 ++++---\n 2 files changed, 13 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex 8f5cfac..f60f49b 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -295,6 +295,15 @@ test_expect_success 'status -s -b' '\n \n '\n \n+test_expect_success 'status -s -z -b' '\n+\ttr \"\\\\n\" Q <expect >expect.q &&\n+\tmv expect.q expect &&\n+\tgit status -s -z -b >output &&\n+\tnul_to_q <output >output.q &&\n+\tmv output.q output &&\n+\ttest_cmp expect output\n+'\n+\n test_expect_success 'setup dir3' '\n \tmkdir dir3 &&\n \t: >dir3/untracked1 &&\ndiff --git a/wt-status.c b/wt-status.c\nindex 284dc61..21c0d4d 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -913,8 +913,8 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)\n \tif (s->is_initial)\n \t\tcolor_fprintf(s->fp, header_color, _(\"Initial commit on \"));\n \tif (!stat_tracking_info(branch, &num_ours, &num_theirs)) {\n-\t\tcolor_fprintf_ln(s->fp, branch_color_local,\n-\t\t\t\"%s\", branch_name);\n+\t\tcolor_fprintf(s->fp, branch_color_local, \"%s\", branch_name);\n+\t\tfputc(s->null_termination ? '\\0' : '\\n', s->fp);\n \t\treturn;\n \t}\n \n@@ -938,7 +938,8 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)\n \t\tcolor_fprintf(s->fp, branch_color_remote, \"%d\", num_theirs);\n \t}\n \n-\tcolor_fprintf_ln(s->fp, header_color, \"]\");\n+\tcolor_fprintf(s->fp, header_color, \"]\");\n+\tfputc(s->null_termination ? '\\0' : '\\n', s->fp);\n }\n \n void wt_shortstatus_print(struct wt_status *s, int show_branch)\n-- \n1.7.10.1.12.gd79f7ab\n"},{"id":"191040","messageId":"20120507212504.GE19567@sigill.intra.peff.net","threadId":"30442","inReplyTo":"20120507212125.GA19532@sigill.intra.peff.net","subject":"[PATCH 5/5] status: respect \"-b\" for porcelain format","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-05-07T21:25:04Z","receivedAt":"2012-05-07T21:25:04Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"There is no reason not to, as the user has to explicitly ask\nfor it, so we are not breaking compatibility by doing so. We\ncan do this simply by moving the \"show_branch\" flag into\nthe wt_status struct. As a bonus, this saves us from passing\nit explicitly, simplifying the code.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n builtin/commit.c  | 9 ++++-----\n t/t7508-status.sh | 7 ++++++-\n wt-status.c       | 6 +++---\n wt-status.h       | 3 ++-\n 4 files changed, 15 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 11271c0..a2ec73d 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -115,7 +115,6 @@ static enum {\n \tSTATUS_FORMAT_SHORT,\n \tSTATUS_FORMAT_PORCELAIN\n } status_format = STATUS_FORMAT_LONG;\n-static int status_show_branch;\n \n static int opt_parse_m(const struct option *opt, const char *arg, int unset)\n {\n@@ -446,7 +445,7 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int\n \n \tswitch (status_format) {\n \tcase STATUS_FORMAT_SHORT:\n-\t\twt_shortstatus_print(s, status_show_branch);\n+\t\twt_shortstatus_print(s);\n \t\tbreak;\n \tcase STATUS_FORMAT_PORCELAIN:\n \t\twt_porcelain_print(s);\n@@ -1171,7 +1170,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \t\tOPT__VERBOSE(&verbose, \"be verbose\"),\n \t\tOPT_SET_INT('s', \"short\", &status_format,\n \t\t\t    \"show status concisely\", STATUS_FORMAT_SHORT),\n-\t\tOPT_BOOLEAN('b', \"branch\", &status_show_branch,\n+\t\tOPT_BOOLEAN('b', \"branch\", &s.show_branch,\n \t\t\t    \"show branch information\"),\n \t\tOPT_SET_INT(0, \"porcelain\", &status_format,\n \t\t\t    \"machine-readable output\",\n@@ -1228,7 +1227,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \n \tswitch (status_format) {\n \tcase STATUS_FORMAT_SHORT:\n-\t\twt_shortstatus_print(&s, status_show_branch);\n+\t\twt_shortstatus_print(&s);\n \t\tbreak;\n \tcase STATUS_FORMAT_PORCELAIN:\n \t\twt_porcelain_print(&s);\n@@ -1400,7 +1399,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOLEAN(0, \"dry-run\", &dry_run, \"show what would be committed\"),\n \t\tOPT_SET_INT(0, \"short\", &status_format, \"show status concisely\",\n \t\t\t    STATUS_FORMAT_SHORT),\n-\t\tOPT_BOOLEAN(0, \"branch\", &status_show_branch, \"show branch information\"),\n+\t\tOPT_BOOLEAN(0, \"branch\", &s.show_branch, \"show branch information\"),\n \t\tOPT_SET_INT(0, \"porcelain\", &status_format,\n \t\t\t    \"machine-readable output\", STATUS_FORMAT_PORCELAIN),\n \t\tOPT_BOOLEAN('z', \"null\", &s.null_termination,\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex f60f49b..28e1848 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -680,9 +680,14 @@ test_expect_success 'status --porcelain ignores color.status' '\n git config --unset color.status\n git config --unset color.ui\n \n-test_expect_success 'status --porcelain ignores -b' '\n+test_expect_success 'status --porcelain respects -b' '\n \n \tgit status --porcelain -b >output &&\n+\t{\n+\t\techo \"## master\" &&\n+\t\tcat expect\n+\t} >tmp &&\n+\tmv tmp expect &&\n \ttest_cmp expect output\n \n '\ndiff --git a/wt-status.c b/wt-status.c\nindex 21c0d4d..dd6d8c4 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -942,11 +942,11 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)\n \tfputc(s->null_termination ? '\\0' : '\\n', s->fp);\n }\n \n-void wt_shortstatus_print(struct wt_status *s, int show_branch)\n+void wt_shortstatus_print(struct wt_status *s)\n {\n \tint i;\n \n-\tif (show_branch)\n+\tif (s->show_branch)\n \t\twt_shortstatus_print_tracking(s);\n \n \tfor (i = 0; i < s->change.nr; i++) {\n@@ -979,5 +979,5 @@ void wt_porcelain_print(struct wt_status *s)\n \ts->use_color = 0;\n \ts->relative_paths = 0;\n \ts->prefix = NULL;\n-\twt_shortstatus_print(s, 0);\n+\twt_shortstatus_print(s);\n }\ndiff --git a/wt-status.h b/wt-status.h\nindex 26dd21a..14aa9f7 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -58,6 +58,7 @@ struct wt_status {\n \tchar color_palette[WT_STATUS_MAXSLOT][COLOR_MAXLEN];\n \tunsigned colopts;\n \tint null_termination;\n+\tint show_branch;\n \n \t/* These are computed during processing of the individual sections */\n \tint commitable;\n@@ -74,7 +75,7 @@ void wt_status_prepare(struct wt_status *s);\n void wt_status_print(struct wt_status *s);\n void wt_status_collect(struct wt_status *s);\n \n-void wt_shortstatus_print(struct wt_status *s, int show_branch);\n+void wt_shortstatus_print(struct wt_status *s);\n void wt_porcelain_print(struct wt_status *s);\n \n void status_printf_ln(struct wt_status *s, const char *color, const char *fmt, ...)\n-- \n1.7.10.1.12.gd79f7ab\n"},{"id":"191041","messageId":"20120507212836.GA19753@sigill.intra.peff.net","threadId":"30442","inReplyTo":"20120507212504.GE19567@sigill.intra.peff.net","subject":"Re: [PATCH 5/5] status: respect \"-b\" for porcelain format","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-05-07T21:28:36Z","receivedAt":"2012-05-07T21:28:36Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, May 07, 2012 at 05:25:04PM -0400, Jeff King wrote:\n\n> There is no reason not to, as the user has to explicitly ask\n> for it, so we are not breaking compatibility by doing so. We\n> can do this simply by moving the \"show_branch\" flag into\n> the wt_status struct. As a bonus, this saves us from passing\n> it explicitly, simplifying the code.\n\nI forgot this, which should probably be squashed in:\n\n-- >8 --\nSubject: status: fix \"--porcelain -z -b\" documentation\n\nIt is no longer the case that \"-z\" will not respect \"-b\".\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n Documentation/git-status.txt | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\nindex 2883a28..67e5f53 100644\n--- a/Documentation/git-status.txt\n+++ b/Documentation/git-status.txt\n@@ -184,7 +184,7 @@ order is reversed (e.g 'from \\-> to' becomes 'to from'). Second, a NUL\n and the terminating newline (but a space still separates the status\n field from the first filename).  Third, filenames containing special\n characters are not specially formatted; no quoting or\n-backslash-escaping is performed. Fourth, there is no branch line.\n+backslash-escaping is performed.\n \n CONFIGURATION\n -------------\n-- \n1.7.10.1.12.gd79f7ab\n"},{"id":"191065","messageId":"7vtxzrz2za.fsf@alter.siamese.dyndns.org","threadId":"30442","inReplyTo":"20120507212836.GA19753@sigill.intra.peff.net","subject":"Re: [PATCH 5/5] status: respect \"-b\" for porcelain format","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-05-08T04:55:05Z","receivedAt":"2012-05-08T04:55:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Mon, May 07, 2012 at 05:25:04PM -0400, Jeff King wrote:\n>\n>> There is no reason not to, as the user has to explicitly ask\n>> for it, so we are not breaking compatibility by doing so. We\n>> can do this simply by moving the \"show_branch\" flag into\n>> the wt_status struct. As a bonus, this saves us from passing\n>> it explicitly, simplifying the code.\n>\n> I forgot this, which should probably be squashed in:\n>\n> -- >8 --\n> Subject: status: fix \"--porcelain -z -b\" documentation\n>\n> It is no longer the case that \"-z\" will not respect \"-b\".\n>\n> Signed-off-by: Jeff King <peff@peff.net>\n\nAll patches looked good.  I thought that this deserved to eventually land\non 'maint', so I did my usual \"am first to master primarily to populate\nthe object database with exact blob objects, then rebase the result to\n'maint' while resolving conflicts both textual and semantic, and finally\nattempt to merge it back to 'master'\" dance to come up with a two topic\nbranches.  The result is queued in 'pu'.\n\nThanks.\n"},{"id":"191075","messageId":"20120508090407.GA31286@sigill.intra.peff.net","threadId":"30442","inReplyTo":"7vtxzrz2za.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 5/5] status: respect \"-b\" for porcelain format","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-05-08T09:04:07Z","receivedAt":"2012-05-08T09:04:07Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, May 07, 2012 at 09:55:05PM -0700, Junio C Hamano wrote:\n\n> All patches looked good.  I thought that this deserved to eventually land\n> on 'maint', so I did my usual \"am first to master primarily to populate\n> the object database with exact blob objects, then rebase the result to\n> 'maint' while resolving conflicts both textual and semantic, and finally\n> attempt to merge it back to 'master'\" dance to come up with a two topic\n> branches.  The result is queued in 'pu'.\n\nI eyeballed the result. It all looks good except for patch 2 (refactor\ncolopts handling), which now has a totally bogus commit message. Since\ncolopts came much later, the only thing left in the patch is the\nmovement of the local \"struct wt_status s\" in cmd_{commit,status} to a\nstatic at the top of each function (so that it can be referenced\ndirectly by the options list).\n\nProbably that patch (94f98829) should just be squashed into its parent.\nAnd then the colopts bits can be moved to the very end, after the rest\nof it, and be a part of only the non-maint topic.\n\nI've pushed that result out to the jk/{maint-,}status-porcelain-z-b\nbranches at git://github.com/peff/git.git if that helps.\n\n-Peff\n"},{"id":"191089","messageId":"CACsJy8ADt0C=gyom8R15GoM+_6oHDvWasMgSqnwbiKqnXGwxug@mail.gmail.com","threadId":"30442","inReplyTo":"20120507212333.GB19567@sigill.intra.peff.net","subject":"Re: [PATCH 2/5] status: refactor colopts handling","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-05-08T13:27:45Z","receivedAt":"2012-05-08T13:27:45Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, May 8, 2012 at 4:23 AM, Jeff King <peff@peff.net> wrote:\n> The current code reads the config and command-line options\n> into a separate \"colopts\" variable, and then copies the\n> contents of that variable into the \"struct wt_status\". We\n> can eliminate the extra variable and copy just write\n> straight into the wt_status struct.\n>\n> This simplifies the \"status\" code a little bit.\n> Unfortunately, it makes the \"commit\" code one line more\n> complex; a side effect of the separate variable was that\n> \"commit\" did not copy the colopts variable, so any\n> column.status configuration had no effect.\n>\n> The result still ends up cleaner, though. In the previous\n> version, it was unclear whether commit simply forgot to copy\n> the colopt variable, or whether it was intentional. Now it\n> explicitly turns off column options. Furthermore, if commit\n> later learns to respect column.status, this will make the\n> end result simpler. I punted on just adding that feature\n> now, because it was sufficiently non-obvious that it should\n> not go into a refactoring patch.\n>\n> Signed-off-by: Jeff King <peff@peff.net>\n> ---\n> For the reasons mentioned above, this ended up as a less impressive\n> cleanup than I had hoped. I think it's still worth doing, but I won't be\n> too sad if it gets dropped.\n\nI'm neutral. But this patch reduces one line so it wins a \"yes\" from me.\n\n>  builtin/commit.c | 13 ++++++-------\n>  wt-status.h      |  2 +-\n>  2 files changed, 7 insertions(+), 8 deletions(-)\n-- \nDuy\n"},{"id":"191139","messageId":"7vtxzqv9v1.fsf@alter.siamese.dyndns.org","threadId":"30442","inReplyTo":"20120508090407.GA31286@sigill.intra.peff.net","subject":"Re: [PATCH 5/5] status: respect \"-b\" for porcelain format","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-05-08T17:52:18Z","receivedAt":"2012-05-08T17:52:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> Probably that patch (94f98829) should just be squashed into its parent.\n> And then the colopts bits can be moved to the very end, after the rest\n> of it, and be a part of only the non-maint topic.\n\nMakes sense.  Thanks.\n\n>\n> I've pushed that result out to the jk/{maint-,}status-porcelain-z-b\n> branches at git://github.com/peff/git.git if that helps.\n>\n> -Peff\n"}]}