{"thread":{"id":"31922","subject":"[PATCHv2] git-status: show short sequencer state","startedAt":"2012-10-23T20:02:53Z","lastAt":"2012-11-14T19:57:35Z","messageCount":26,"participants":["Phil Hord","Jeff King","Junio C Hamano","Ramkumar Ramachandra"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"201746","messageId":"1351022574-27869-1-git-send-email-hordp@cisco.com","threadId":"31922","inReplyTo":null,"subject":"[PATCHv2] git-status: show short sequencer state","fromName":"Phil Hord","fromEmail":"hordp@cisco.com","sentAt":"2012-10-23T20:02:53Z","receivedAt":"2012-10-23T20:02:53Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"Updated per Matthieu's comments, adding Sign-off and fixing my prefix to have a little \"v2\" on the end.\n\nSorry for the extra noise.\n\nPhil\n"},{"id":"201747","messageId":"1351022574-27869-2-git-send-email-hordp@cisco.com","threadId":"31922","inReplyTo":"1351022574-27869-1-git-send-email-hordp@cisco.com","subject":"[PATCHv2] git-status: show short sequencer state","fromName":"Phil Hord","fromEmail":"hordp@cisco.com","sentAt":"2012-10-23T20:02:54Z","receivedAt":"2012-10-23T20:02:54Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"Recently git-status learned to display the state of the git\nsequencer in long form to help the user remember an interrupted\ncommand.  This information is also useful in short form to\nhumans and scripts, but no option is available to boil it down.\n\nTeach git-status to report the sequencer state in short form\nusing a new --sequencer (-S) switch.  Output zero or more\nsimple state token strings indicating the deduced state of the\ngit sequencer.\n\nIntroduce a common function to determine the current sequencer\nstate so the regular status function and this short version can\nshare common code.\n\nAdd a substate to wt_status_state to track more detailed\ninformation about a state, such as \"conflicted\" or \"resolved\".\nMove the am_empty_patch flage out of wt_status_state and into\nthis new substate.\n\nState token strings which may be emitted and their meanings:\n    merge              a git-merge is in progress\n    am                 a git-am is in progress\n    rebase             a git-rebase is in progress\n    rebase-interactive a git-rebase--interactive is in progress\n    cherry-pick        a git-cherry-pick is in progress\n    bisect             a git-bisect is in progress\n    conflicted         there are unresolved conflicts\n    resolved           conflicts have been resolved\n    editing            interactive rebase stopped to edit a commit\n    edited             interactive rebase edit has been edited\n    splitting          interactive rebase, commit is being split\n\nI also considered adding these tokens, but I decided it was not\nappropriate since these changes are not sequencer-related.  But\nit is possible I am being too short-sighted or have chosen the\nswitch name poorly.\n    clean\n    index\n    modified\n    untracked\n\nSigned-off-by: Phil Hord <hordp@cisco.com>\n---\n Documentation/git-status.txt |  18 +++++++\n builtin/commit.c             |  12 ++++-\n wt-status.c                  | 125 +++++++++++++++++++++++++++++++++++--------\n wt-status.h                  |  14 ++++-\n 4 files changed, 145 insertions(+), 24 deletions(-)\n\ndiff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\nindex 67e5f53..31ffabd 100644\n--- a/Documentation/git-status.txt\n+++ b/Documentation/git-status.txt\n@@ -38,6 +38,24 @@ OPTIONS\n \tacross git versions and regardless of user configuration. See\n \tbelow for details.\n \n+-S::\n+--sequence::\n+\tShow the git sequencer status. This shows zero or more tokens\n+\tdescribing the state of several git sequence operations. Each\n+\ttoken is separated by a newline.\n++\n+\tmerge              a merge is in progress\n+\tam                 an am is in progress\n+\trebase             a rebase is in progress\n+\trebase-interactive an interactive rebase is in progress\n+\tcherry-pick        a cherry-pick is in progress\n+\tbisect             a bisect is in progress\n+\tconflicted         there are unresolved conflicts\n+\tresolved           conflicts have been resolved\n+\tediting            interactive rebase stopped to edit a commit\n+\tedited             interactive rebase edit has been edited\n+\tsplitting          interactive rebase, commit is being split\n+\n -u[<mode>]::\n --untracked-files[=<mode>]::\n \tShow untracked files.\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex a17a5df..9706ed9 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -114,7 +114,8 @@ static struct strbuf message = STRBUF_INIT;\n static enum {\n \tSTATUS_FORMAT_LONG,\n \tSTATUS_FORMAT_SHORT,\n-\tSTATUS_FORMAT_PORCELAIN\n+\tSTATUS_FORMAT_PORCELAIN,\n+\tSTATUS_FORMAT_SEQUENCER\n } status_format = STATUS_FORMAT_LONG;\n \n static int opt_parse_m(const struct option *opt, const char *arg, int unset)\n@@ -454,6 +455,9 @@ 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_SEQUENCER:\n+\t\twt_sequencer_print(s);\n+\t\tbreak;\n \tcase STATUS_FORMAT_LONG:\n \t\twt_status_print(s);\n \t\tbreak;\n@@ -1156,6 +1160,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \t\t\t    N_(\"show status concisely\"), STATUS_FORMAT_SHORT),\n \t\tOPT_BOOLEAN('b', \"branch\", &s.show_branch,\n \t\t\t    N_(\"show branch information\")),\n+\t\tOPT_SET_INT('S', \"sequence\", &status_format,\n+\t\t\t\tN_(\"show sequencer state\"),\n+\t\t\t\tSTATUS_FORMAT_SEQUENCER),\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@@ -1216,6 +1223,9 @@ 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_SEQUENCER:\n+\t\twt_sequencer_print(&s);\n+\t\tbreak;\n \tcase STATUS_FORMAT_LONG:\n \t\ts.verbose = verbose;\n \t\ts.ignore_submodule_arg = ignore_submodule_arg;\ndiff --git a/wt-status.c b/wt-status.c\nindex 2a9658b..81d91e3 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -781,7 +781,7 @@ static void show_merge_in_progress(struct wt_status *s,\n \t\t\t\tstruct wt_status_state *state,\n \t\t\t\tconst char *color)\n {\n-\tif (has_unmerged(s)) {\n+\tif (state->substate == WT_SUBSTATE_CONFLICTED) {\n \t\tstatus_printf_ln(s, color, _(\"You have unmerged paths.\"));\n \t\tif (advice_status_hints)\n \t\t\tstatus_printf_ln(s, color,\n@@ -802,11 +802,11 @@ static void show_am_in_progress(struct wt_status *s,\n {\n \tstatus_printf_ln(s, color,\n \t\t_(\"You are in the middle of an am session.\"));\n-\tif (state->am_empty_patch)\n+\tif (state->substate == WT_SUBSTATE_AM_EMPTY)\n \t\tstatus_printf_ln(s, color,\n \t\t\t_(\"The current patch is empty.\"));\n \tif (advice_status_hints) {\n-\t\tif (!state->am_empty_patch)\n+\t\tif (state->substate == WT_SUBSTATE_CONFLICTED)\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (fix conflicts and then run \\\"git am --resolved\\\")\"));\n \t\tstatus_printf_ln(s, color,\n@@ -867,9 +867,7 @@ static void show_rebase_in_progress(struct wt_status *s,\n \t\t\t\tstruct wt_status_state *state,\n \t\t\t\tconst char *color)\n {\n-\tstruct stat st;\n-\n-\tif (has_unmerged(s)) {\n+\tif (state->substate == WT_SUBSTATE_CONFLICTED) {\n \t\tstatus_printf_ln(s, color, _(\"You are currently rebasing.\"));\n \t\tif (advice_status_hints) {\n \t\t\tstatus_printf_ln(s, color,\n@@ -879,19 +877,19 @@ static void show_rebase_in_progress(struct wt_status *s,\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (use \\\"git rebase --abort\\\" to check out the original branch)\"));\n \t\t}\n-\t} else if (state->rebase_in_progress || !stat(git_path(\"MERGE_MSG\"), &st)) {\n+\t} else if (state->substate == WT_SUBSTATE_RESOLVED) {\n \t\tstatus_printf_ln(s, color, _(\"You are currently rebasing.\"));\n \t\tif (advice_status_hints)\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (all conflicts fixed: run \\\"git rebase --continue\\\")\"));\n-\t} else if (split_commit_in_progress(s)) {\n+\t} else if (state->substate == WT_SUBSTATE_SPLITTING) {\n \t\tstatus_printf_ln(s, color, _(\"You are currently splitting a commit during a rebase.\"));\n \t\tif (advice_status_hints)\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (Once your working directory is clean, run \\\"git rebase --continue\\\")\"));\n \t} else {\n \t\tstatus_printf_ln(s, color, _(\"You are currently editing a commit during a rebase.\"));\n-\t\tif (advice_status_hints && !s->amend) {\n+\t\tif (advice_status_hints && state->substate == WT_SUBSTATE_EDITING) {\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (use \\\"git commit --amend\\\" to amend the current commit)\"));\n \t\t\tstatus_printf_ln(s, color,\n@@ -907,7 +905,7 @@ static void show_cherry_pick_in_progress(struct wt_status *s,\n {\n \tstatus_printf_ln(s, color, _(\"You are currently cherry-picking.\"));\n \tif (advice_status_hints) {\n-\t\tif (has_unmerged(s))\n+\t\tif (state->substate == WT_SUBSTATE_CONFLICTED)\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (fix conflicts and run \\\"git commit\\\")\"));\n \t\telse\n@@ -928,34 +926,68 @@ static void show_bisect_in_progress(struct wt_status *s,\n \twt_status_print_trailer(s);\n }\n \n-static void wt_status_print_state(struct wt_status *s)\n+static void wt_status_get_state(struct wt_status *s , struct wt_status_state *state)\n {\n-\tconst char *state_color = color(WT_STATUS_HEADER, s);\n-\tstruct wt_status_state state;\n \tstruct stat st;\n \n-\tmemset(&state, 0, sizeof(state));\n+\tmemset(state, 0, sizeof(*state));\n \n+\t// Determine main sequencer activity\n \tif (!stat(git_path(\"MERGE_HEAD\"), &st)) {\n-\t\tstate.merge_in_progress = 1;\n+\t\tstate->merge_in_progress = 1;\n \t} else if (!stat(git_path(\"rebase-apply\"), &st)) {\n \t\tif (!stat(git_path(\"rebase-apply/applying\"), &st)) {\n-\t\t\tstate.am_in_progress = 1;\n+\t\t\tstate->am_in_progress = 1;\n \t\t\tif (!stat(git_path(\"rebase-apply/patch\"), &st) && !st.st_size)\n-\t\t\t\tstate.am_empty_patch = 1;\n+\t\t\t\tstate->substate = WT_SUBSTATE_AM_EMPTY;\n+\t\t\telse\n+\t\t\t\tstate->substate = WT_SUBSTATE_CONFLICTED;\n \t\t} else {\n-\t\t\tstate.rebase_in_progress = 1;\n+\t\t\tstate->rebase_in_progress = 1;\n \t\t}\n \t} else if (!stat(git_path(\"rebase-merge\"), &st)) {\n \t\tif (!stat(git_path(\"rebase-merge/interactive\"), &st))\n-\t\t\tstate.rebase_interactive_in_progress = 1;\n+\t\t\tstate->rebase_interactive_in_progress = 1;\n \t\telse\n-\t\t\tstate.rebase_in_progress = 1;\n+\t\t\tstate->rebase_in_progress = 1;\n \t} else if (!stat(git_path(\"CHERRY_PICK_HEAD\"), &st)) {\n-\t\tstate.cherry_pick_in_progress = 1;\n+\t\tstate->cherry_pick_in_progress = 1;\n \t}\n \tif (!stat(git_path(\"BISECT_LOG\"), &st))\n-\t\tstate.bisect_in_progress = 1;\n+\t\tstate->bisect_in_progress = 1;\n+\n+\t// Check for unmerged files\n+\tif (state->rebase_in_progress || state->rebase_interactive_in_progress ||\n+\t\t\tstate->cherry_pick_in_progress || state->merge_in_progress) {\n+\t\tif (has_unmerged(s)) {\n+\t\t\tstate->substate = WT_SUBSTATE_CONFLICTED;\n+\t\t} else {\n+\t\t\tstate->substate = WT_SUBSTATE_RESOLVED;\n+\t\t}\n+\t}\n+\n+\t// Interactive Rebase is more nuanced\n+\tif (state->rebase_interactive_in_progress && state->substate != WT_SUBSTATE_CONFLICTED) {\n+\t\tif (!stat(git_path(\"MERGE_MSG\"), &st)) {\n+\t\t\tstate->substate = WT_SUBSTATE_RESOLVED;\n+\t\t} else if (split_commit_in_progress(s)) {\n+\t\t\tstate->substate = WT_SUBSTATE_SPLITTING;\n+\t\t} else {\n+\t\t\tif (s->amend) {\n+\t\t\t\tstate->substate = WT_SUBSTATE_EDITED;\n+\t\t\t} else {\n+\t\t\t\tstate->substate = WT_SUBSTATE_EDITING;\n+\t\t\t}\n+\t\t}\n+\t}\n+}\n+\n+static void wt_status_print_state(struct wt_status *s)\n+{\n+\tconst char *state_color = color(WT_STATUS_HEADER, s);\n+\tstruct wt_status_state state;\n+\n+\twt_status_get_state(s, &state);\n \n \tif (state.merge_in_progress)\n \t\tshow_merge_in_progress(s, &state, state_color);\n@@ -1192,6 +1224,55 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)\n \tfputc(s->null_termination ? '\\0' : '\\n', s->fp);\n }\n \n+static void wt_print_token(struct wt_status *s, const char *token)\n+{\n+\tfprintf(s->fp, \"%s\", token);\n+\tfputc(s->null_termination ? '\\0' : '\\n', s->fp);\n+}\n+\n+void wt_sequencer_print(struct wt_status *s)\n+{\n+\tstruct wt_status_state state;\n+\n+\twt_status_get_state(s, &state);\n+\n+\tif (state.merge_in_progress)\n+\t\twt_print_token(s, \"merge\");\n+\tif (state.am_in_progress)\n+\t\twt_print_token(s, \"am\");\n+\tif (state.rebase_in_progress)\n+\t\twt_print_token(s, \"rebase\");\n+\tif (state.rebase_interactive_in_progress)\n+\t\twt_print_token(s, \"rebase-interactive\");\n+\tif (state.cherry_pick_in_progress)\n+\t\twt_print_token(s, \"cherry-pick\");\n+\tif (state.bisect_in_progress)\n+\t\twt_print_token(s, \"bisect\");\n+\n+\tswitch (state.substate) {\n+\tcase WT_SUBSTATE_NOMINAL:\n+\t\tbreak;\n+\tcase WT_SUBSTATE_CONFLICTED:\n+\t\twt_print_token(s, \"conflicted\");\n+\t\tbreak;\n+\tcase WT_SUBSTATE_RESOLVED:\n+\t\twt_print_token(s, \"resolved\");\n+\t\tbreak;\n+\tcase WT_SUBSTATE_EDITED:\n+\t\twt_print_token(s, \"edited\");\n+\t\tbreak;\n+\tcase WT_SUBSTATE_EDITING:\n+\t\twt_print_token(s, \"editing\");\n+\t\tbreak;\n+\tcase WT_SUBSTATE_SPLITTING:\n+\t\twt_print_token(s, \"splitting\");\n+\t\tbreak;\n+\tcase WT_SUBSTATE_AM_EMPTY:\n+\t\twt_print_token(s, \"am-empty\");\n+\t\tbreak;\n+\t}\n+}\n+\n void wt_shortstatus_print(struct wt_status *s)\n {\n \tint i;\ndiff --git a/wt-status.h b/wt-status.h\nindex 236b41f..900889c 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -59,6 +59,7 @@ struct wt_status {\n \tunsigned colopts;\n \tint null_termination;\n \tint show_branch;\n+\tint show_sequencer;\n \n \t/* These are computed during processing of the individual sections */\n \tint commitable;\n@@ -71,14 +72,24 @@ struct wt_status {\n \tstruct string_list ignored;\n };\n \n+enum wt_status_substate {\n+\tWT_SUBSTATE_NOMINAL = 0,\n+\tWT_SUBSTATE_CONFLICTED,\n+\tWT_SUBSTATE_RESOLVED,\n+\tWT_SUBSTATE_SPLITTING,\n+\tWT_SUBSTATE_EDITING,\n+\tWT_SUBSTATE_EDITED,\n+\tWT_SUBSTATE_AM_EMPTY,\n+};\n+\n struct wt_status_state {\n \tint merge_in_progress;\n \tint am_in_progress;\n-\tint am_empty_patch;\n \tint rebase_in_progress;\n \tint rebase_interactive_in_progress;\n \tint cherry_pick_in_progress;\n \tint bisect_in_progress;\n+\tenum wt_status_substate substate;\n };\n \n void wt_status_prepare(struct wt_status *s);\n@@ -86,6 +97,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);\n+void wt_sequencer_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.8.0.2.gc921d59.dirty\n"},{"id":"201876","messageId":"20121025092919.GG8390@sigill.intra.peff.net","threadId":"31922","inReplyTo":"1351022574-27869-2-git-send-email-hordp@cisco.com","subject":"Re: [PATCHv2] git-status: show short sequencer state","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-10-25T09:29:19Z","receivedAt":"2012-10-25T09:29:19Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Oct 23, 2012 at 04:02:54PM -0400, Phil Hord wrote:\n\n> Teach git-status to report the sequencer state in short form\n> using a new --sequencer (-S) switch.  Output zero or more\n> simple state token strings indicating the deduced state of the\n> git sequencer.\n> \n> Introduce a common function to determine the current sequencer\n> state so the regular status function and this short version can\n> share common code.\n> \n> Add a substate to wt_status_state to track more detailed\n> information about a state, such as \"conflicted\" or \"resolved\".\n> Move the am_empty_patch flage out of wt_status_state and into\n\nThis patch ended up quite long. It might be a little easier to review\nif it were broken into refactoring steps (I have not looked at it too\nclosely yet, but it seems like the three paragraphs above could each be\ntheir own commit).\n\n> State token strings which may be emitted and their meanings:\n>     merge              a git-merge is in progress\n>     am                 a git-am is in progress\n>     rebase             a git-rebase is in progress\n>     rebase-interactive a git-rebase--interactive is in progress\n\nA minor nit, but you might want to update this list from the one in the\ndocumentation.\n\n> diff --git a/builtin/commit.c b/builtin/commit.c\n> index a17a5df..9706ed9 100644\n> --- a/builtin/commit.c\n> +++ b/builtin/commit.c\n> @@ -114,7 +114,8 @@ static struct strbuf message = STRBUF_INIT;\n>  static enum {\n>  \tSTATUS_FORMAT_LONG,\n>  \tSTATUS_FORMAT_SHORT,\n> -\tSTATUS_FORMAT_PORCELAIN\n> +\tSTATUS_FORMAT_PORCELAIN,\n> +\tSTATUS_FORMAT_SEQUENCER\n>  } status_format = STATUS_FORMAT_LONG;\n\nHmm. So the new format is its own distinct output format. I could not\nsay \"I would like to see short status, and by the way, show me the\nsequencer state\", as you can with \"-b\". Is it possible to do this (or\neven desirable; getting the sequencer state should be way cheaper, so\nconflating the two may not be what some callers want).\n\nNot complaining, just wondering about the intended use cases.\n\nAlso, does there need to be a --porcelain version of this output? It\nseems like we can have multiple words (e.g., in a merge, with conflicted\nentries). If there is no arbitrary data, we do not have to worry about\ndelimiters and quoting.  But I wonder if we would ever want to expand\nthe information to include arbitrary strings, at which point we would\nwant NUL delimiters; should we start with that now?\n\n> +\t// Determine main sequencer activity\n\nPlease avoid C99 comments (there are others in the patch, too).\n\n> +void wt_sequencer_print(struct wt_status *s)\n> +{\n> +\tstruct wt_status_state state;\n> +\n> +\twt_status_get_state(s, &state);\n> +\n> +\tif (state.merge_in_progress)\n> +\t\twt_print_token(s, \"merge\");\n> +\tif (state.am_in_progress)\n> +\t\twt_print_token(s, \"am\");\n> +\tif (state.rebase_in_progress)\n> +\t\twt_print_token(s, \"rebase\");\n> +\tif (state.rebase_interactive_in_progress)\n> +\t\twt_print_token(s, \"rebase-interactive\");\n> +\tif (state.cherry_pick_in_progress)\n> +\t\twt_print_token(s, \"cherry-pick\");\n> +\tif (state.bisect_in_progress)\n> +\t\twt_print_token(s, \"bisect\");\n> +\n> +\tswitch (state.substate) {\n> +\tcase WT_SUBSTATE_NOMINAL:\n> +\t\tbreak;\n> +\tcase WT_SUBSTATE_CONFLICTED:\n> +\t\twt_print_token(s, \"conflicted\");\n> +\t\tbreak;\n> +\tcase WT_SUBSTATE_RESOLVED:\n> +\t\twt_print_token(s, \"resolved\");\n> +\t\tbreak;\n> +\tcase WT_SUBSTATE_EDITED:\n> +\t\twt_print_token(s, \"edited\");\n> +\t\tbreak;\n> +\tcase WT_SUBSTATE_EDITING:\n> +\t\twt_print_token(s, \"editing\");\n> +\t\tbreak;\n> +\tcase WT_SUBSTATE_SPLITTING:\n> +\t\twt_print_token(s, \"splitting\");\n> +\t\tbreak;\n> +\tcase WT_SUBSTATE_AM_EMPTY:\n> +\t\twt_print_token(s, \"am-empty\");\n> +\t\tbreak;\n> +\t}\n> +}\n\nIt is clear from this code that some tokens can happen together, and\nsome are mutually exclusive. Should the documentation talk about that,\nor do we want to literally keep it as a list of tags?\n\n-Peff\n"},{"id":"201907","messageId":"5089633C.8030307@cisco.com","threadId":"31922","inReplyTo":"20121025092919.GG8390@sigill.intra.peff.net","subject":"Re: [PATCHv2] git-status: show short sequencer state","fromName":"Phil Hord","fromEmail":"hordp@cisco.com","sentAt":"2012-10-25T16:05:16Z","receivedAt":"2012-10-25T16:05:16Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"\nJeff King wrote:\n> On Tue, Oct 23, 2012 at 04:02:54PM -0400, Phil Hord wrote:\n>\n>> Teach git-status to report the sequencer state in short form\n>> using a new --sequencer (-S) switch.  Output zero or more\n>> simple state token strings indicating the deduced state of the\n>> git sequencer.\n>>\n>> Introduce a common function to determine the current sequencer\n>> state so the regular status function and this short version can\n>> share common code.\n>>\n>> Add a substate to wt_status_state to track more detailed\n>> information about a state, such as \"conflicted\" or \"resolved\".\n>> Move the am_empty_patch flage out of wt_status_state and into\n> This patch ended up quite long. It might be a little easier to review\n> if it were broken into refactoring steps (I have not looked at it too\n> closely yet, but it seems like the three paragraphs above could each be\n> their own commit).\n\nI can do that.\n\n>> State token strings which may be emitted and their meanings:\n>>     merge              a git-merge is in progress\n>>     am                 a git-am is in progress\n>>     rebase             a git-rebase is in progress\n>>     rebase-interactive a git-rebase--interactive is in progress\n> A minor nit, but you might want to update this list from the one in the\n> documentation.\n\nI considered it, but I also considered the audience; then I took the\neasier path.  I'll look again.\n\n>> diff --git a/builtin/commit.c b/builtin/commit.c\n>> index a17a5df..9706ed9 100644\n>> --- a/builtin/commit.c\n>> +++ b/builtin/commit.c\n>> @@ -114,7 +114,8 @@ static struct strbuf message = STRBUF_INIT;\n>>  static enum {\n>>  \tSTATUS_FORMAT_LONG,\n>>  \tSTATUS_FORMAT_SHORT,\n>> -\tSTATUS_FORMAT_PORCELAIN\n>> +\tSTATUS_FORMAT_PORCELAIN,\n>> +\tSTATUS_FORMAT_SEQUENCER\n>>  } status_format = STATUS_FORMAT_LONG;\n> Hmm. So the new format is its own distinct output format. I could not\n> say \"I would like to see short status, and by the way, show me the\n> sequencer state\", as you can with \"-b\". Is it possible to do this (or\n> even desirable; getting the sequencer state should be way cheaper, so\n> conflating the two may not be what some callers want).\n>\n> Not complaining, just wondering about the intended use cases.\n\nOriginally I did place this output in the short-format display.  I\nparticularly want this info to be available for scripts. But it feels\n\"right\" to include it with the short status, since the long-form is\nalready available with 'git status --no-short'.\n\nSince there may be more than one line reported, I did not feel there was\na simple way to contain these details in with the short status.  For\nbranch this is a simple decision as the reported branch will take\nexactly one line.\n\n  git status -b -s\n  ## master\n   M Foo\n\nBut for sequencer state, this seemed like it could be too convoluted or\nmight encourage too much reliance line-counting:\n\n  git status -b -s -S\n  ## master\n  ## merge\n  ## conflicted\n   M Foo\n\nMaybe a different line-prefix would help make this clearer:\n\n  git status -b -s -S\n  ## master\n  #! merge\n  #! conflicted\n   M Foo\n\nIt seemed to me this was someone else's itch and I might not scratch it\nproperly.  But I am willing to try if you think this is more useful than\ndistracting.\n\n> Also, does there need to be a --porcelain version of this output? It\n> seems like we can have multiple words (e.g., in a merge, with conflicted\n> entries). If there is no arbitrary data, we do not have to worry about\n> delimiters and quoting.  But I wonder if we would ever want to expand\n> the information to include arbitrary strings, at which point we would\n> want NUL delimiters; should we start with that now?\n\nThis works, though I haven't tested it on v2:\n\n   git status -S -z\n\n\n>> +\t// Determine main sequencer activity\n> Please avoid C99 comments (there are others in the patch, too).\n\nThanks.\n\n>> +void wt_sequencer_print(struct wt_status *s)\n>> +{\n>> +\tstruct wt_status_state state;\n>> +\n>> +\twt_status_get_state(s, &state);\n>> +\n>> +\tif (state.merge_in_progress)\n>> +\t\twt_print_token(s, \"merge\");\n>> +\tif (state.am_in_progress)\n>> +\t\twt_print_token(s, \"am\");\n>> +\tif (state.rebase_in_progress)\n>> +\t\twt_print_token(s, \"rebase\");\n>> +\tif (state.rebase_interactive_in_progress)\n>> +\t\twt_print_token(s, \"rebase-interactive\");\n>> +\tif (state.cherry_pick_in_progress)\n>> +\t\twt_print_token(s, \"cherry-pick\");\n>> +\tif (state.bisect_in_progress)\n>> +\t\twt_print_token(s, \"bisect\");\n>> +\n>> +\tswitch (state.substate) {\n>> +\tcase WT_SUBSTATE_NOMINAL:\n>> +\t\tbreak;\n>> +\tcase WT_SUBSTATE_CONFLICTED:\n>> +\t\twt_print_token(s, \"conflicted\");\n>> +\t\tbreak;\n>> +\tcase WT_SUBSTATE_RESOLVED:\n>> +\t\twt_print_token(s, \"resolved\");\n>> +\t\tbreak;\n>> +\tcase WT_SUBSTATE_EDITED:\n>> +\t\twt_print_token(s, \"edited\");\n>> +\t\tbreak;\n>> +\tcase WT_SUBSTATE_EDITING:\n>> +\t\twt_print_token(s, \"editing\");\n>> +\t\tbreak;\n>> +\tcase WT_SUBSTATE_SPLITTING:\n>> +\t\twt_print_token(s, \"splitting\");\n>> +\t\tbreak;\n>> +\tcase WT_SUBSTATE_AM_EMPTY:\n>> +\t\twt_print_token(s, \"am-empty\");\n>> +\t\tbreak;\n>> +\t}\n>> +}\n> It is clear from this code that some tokens can happen together, and\n> some are mutually exclusive. Should the documentation talk about that,\n> or do we want to literally keep it as a list of tags?\n>\n> -Peff\n\nI want to literally keep it as a list of tags.  This code does not\npresume any exclusivity in the main state and I I do not think it\nshould.  I can imagine being in a \"rebase cherry-pick conflicted\" state,\neven though the current wt_status_get_state function does not allow\ndetecting it.  I think that function is overly restrictive, but it was\nnot important to me yet.\n\nPerhaps it is useful to indicate that the substate values are mutually\nexclusive, but I also feel like this is an implementation detail.  It is\npossible to be in \"rebase-interactive edited conflicted\" state, but it\nis not possible for this code to tell you that. But should we document\nthat fact and thus restrict future improvement in this area?  My first\ninclination is to say no, that we should leave this open.  But on the\nother hand, I can see how someone could be confused if their expected\ntoken never appeared only because another one took precedence.\n\nMaybe the exclusive states should be explicit in the implementation. \nMaybe I should not have a substate at all but each of these substates\nshould be a separate boolean (or ternary).  Something like this:\n\n struct wt_status_state {\n        int merge_in_progress;\n        int am_in_progress;\n+       int am_empty_patch;\n-       int rebase_in_progress;\n-       int rebase_interactive_in_progress;\n+       int rebase_in_progress;       /* 0=no, 1=normal, 2=interactive */\n        int cherry_pick_in_progress;\n        int bisect_in_progress;\n        enum wt_status_substate substate;\n+       int conflicts;                    /* 0=none, 1=yes, 2=resolved */\n+       int editing;                      /* 0=no, 1=editing, 2=edited */\n };\n\nMy primary motivation is to standardize the detection of these various\nstates so scripts do not need to know, for example, to look for the\npresence of '$GIT_DIR/rebase-merge' or that a zero-length\n'$GIT_DIR/rebase-apply/patch' is significant.  An immediate need is to\nshow some tags in my shell prompt when my current state is not clean. \nThe current patch meets this latter need well.  If I add the output of\n$(git status -S) to my prompt, I see nothing when I am \"clean\" and I see\n_something_ when I am not.\n\nBut the former need is not so clear.  A script today which is interested\nin an interactive rebase may simply say $(git status -S | grep\n\"^rebase-interactive$\").  But a new flavor of rebase in the future could\nmuddy the waters.  Maybe there is a need for another reporting state\nwhich provides a definitive answer on all possible tokens.  Consider\nthat I am in an interactive-rebase which has encountered a conflict. \n\n1. Simple state, useful for humans and prompts:\n\n  $ git status -S    \n  rebase-interactive\n  conflicted\n\n\n2. More details for scripts who may not care to distinguish between\ninclusive things like \"rebase\" and \"rebase-interactive\":\n\n  $ git status -S=detailed\n  rebase\n  rebase-interactive\n  conflicted\n\n\n3. Complete disambiguation:\n\n  git status -S=all\n  no-merge\n  no-am\n  rebase\n  rebase-interactive\n  no-cherry-pick\n  no-bisect\n  conflicted\n  no-resolved\n  no-edited\n  no-editing\n  no-splitting\n  no-am-empty\n\nNow a script interested in a condition can check for it explicitly in\ntwo forms: \"condition\" and \"no-condition\".  If neither is found, he can\nassume that his token is obsolete (possibly it was replaced with\nsomething more explicit).  And if his goal is to detect any kind of\nrebase, he can look for the \"rebase\" token rather than worrying about\nits myriad types.\n\nBut at this point I feel overwhelmed by the possibilities.  Uncertainty\ncomes from trying to scratch someone else's itch.  But at the same time,\nI do want to make this status-detector appealing as \"The One True Way to\ncheck git's state\" to avoid more deviating implementations in the future.\n\nAnd so I am conflicted.\n\nI apologize for being so long-winded on this.  Thanks for playing\nalong.  I welcome your thoughts and advice.\n\nPhil\n"},{"id":"202131","messageId":"CABURp0o7b5aZV6jNM=DSweh-8zVgGppxVsXisAcoNk7TxHrdgQ@mail.gmail.com","threadId":"31922","inReplyTo":"5089633C.8030307@cisco.com","subject":"Re: [PATCHv2] git-status: show short sequencer state","fromName":"Phil Hord","fromEmail":"phil.hord@gmail.com","sentAt":"2012-10-29T18:05:14Z","receivedAt":"2012-10-29T18:05:14Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"On Thu, Oct 25, 2012 at 12:05 PM, Phil Hord <hordp@cisco.com> wrote:\n>\n> Jeff King wrote:\n>> On Tue, Oct 23, 2012 at 04:02:54PM -0400, Phil Hord wrote:\n>>\n>>> Teach git-status to report the sequencer state in short form\n>>> using a new --sequencer (-S) switch.  Output zero or more\n>>> simple state token strings indicating the deduced state of the\n>>> git sequencer.\n>>>\n>>> Introduce a common function to determine the current sequencer\n>>> state so the regular status function and this short version can\n>>> share common code.\n>>>\n>>> Add a substate to wt_status_state to track more detailed\n>>> information about a state, such as \"conflicted\" or \"resolved\".\n>>> Move the am_empty_patch flage out of wt_status_state and into\n>> This patch ended up quite long. It might be a little easier to review\n>> if it were broken into refactoring steps (I have not looked at it too\n>> closely yet, but it seems like the three paragraphs above could each be\n>> their own commit).\n\nI'm currently splitting this out into a series and reconsidering some\nof it along the way.  I need some guidance.\n\nI want to support these two modes:\n\n  A.  'git status --short' with sequence tokens added:\n       ## conflicted\n       ## merge\n       ?? untracked-workdir-file\n       etc.\n\n  B.  Same as (A) but without workdir status:\n       ## conflicted\n       ## merge\n\nThe user who wants 'A' would initiate it like this:\n    git status --sequencer\n  or\n    git status -S\n\nHow do I spell the options for 'B'?  I have come up with these three\npossibilities:\n    git --sequencer-only   # Another switch\n    git --sequencer=only   # An OPTARG parser\n    git -S -S           # like git-diff -C -C, an OPT_COUNTUP\n\nThe first one is easy but weird, imho.\nThe second seems silly for just one type of option.\nThe last one is cheap to implement, but harder to explain in Documentation/\n\nAny opinions?\n\nPhil\n"},{"id":"202143","messageId":"20121029214103.GD20513@sigill.intra.peff.net","threadId":"31922","inReplyTo":"CABURp0o7b5aZV6jNM=DSweh-8zVgGppxVsXisAcoNk7TxHrdgQ@mail.gmail.com","subject":"Re: [PATCHv2] git-status: show short sequencer state","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-10-29T21:41:03Z","receivedAt":"2012-10-29T21:41:03Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Oct 29, 2012 at 02:05:14PM -0400, Phil Hord wrote:\n\n> I'm currently splitting this out into a series and reconsidering some\n> of it along the way.  I need some guidance.\n> \n> I want to support these two modes:\n> \n>   A.  'git status --short' with sequence tokens added:\n>        ## conflicted\n>        ## merge\n>        ?? untracked-workdir-file\n>        etc.\n> \n>   B.  Same as (A) but without workdir status:\n>        ## conflicted\n>        ## merge\n> \n> The user who wants 'A' would initiate it like this:\n>     git status --sequencer\n>   or\n>     git status -S\n> \n> How do I spell the options for 'B'?  I have come up with these three\n> possibilities:\n>     git --sequencer-only   # Another switch\n>     git --sequencer=only   # An OPTARG parser\n>     git -S -S           # like git-diff -C -C, an OPT_COUNTUP\n\nMight it be easier to spell 'A' as:\n\n  git status --short -S\n\nand B as:\n\n  git status -S\n\nthis is sort of like how \"-b\" works (except you cannot currently ask for\nit separately, but arguably you could). If we have a proliferation of\nsuch options, then we might need config to help turn them on all the\ntime (I'd guess people are probably already using aliases to do this).\n\n-Peff\n"},{"id":"202150","messageId":"CABURp0qBRvZQvnBbOraQ7c7DRg8v0TjnY+MOGYaWnWwjCqi23Q@mail.gmail.com","threadId":"31922","inReplyTo":"20121029214103.GD20513@sigill.intra.peff.net","subject":"Re: [PATCHv2] git-status: show short sequencer state","fromName":"Phil Hord","fromEmail":"phil.hord@gmail.com","sentAt":"2012-10-29T22:26:44Z","receivedAt":"2012-10-29T22:26:44Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"On Mon, Oct 29, 2012 at 5:41 PM, Jeff King <peff@peff.net> wrote:\n> On Mon, Oct 29, 2012 at 02:05:14PM -0400, Phil Hord wrote:\n>\n>> I'm currently splitting this out into a series and reconsidering some\n>> of it along the way.  I need some guidance.\n>>\n>> I want to support these two modes:\n>>\n>>   A.  'git status --short' with sequence tokens added:\n>>        ## conflicted\n>>        ## merge\n>>        ?? untracked-workdir-file\n>>        etc.\n>>\n>>   B.  Same as (A) but without workdir status:\n>>        ## conflicted\n>>        ## merge\n>>\n>> The user who wants 'A' would initiate it like this:\n>>     git status --sequencer\n>>   or\n>>     git status -S\n>>\n>> How do I spell the options for 'B'?  I have come up with these three\n>> possibilities:\n>>     git --sequencer-only   # Another switch\n>>     git --sequencer=only   # An OPTARG parser\n>>     git -S -S           # like git-diff -C -C, an OPT_COUNTUP\n>\n> Might it be easier to spell 'A' as:\n>\n>   git status --short -S\n>\n> and B as:\n>\n>   git status -S\n>\n> this is sort of like how \"-b\" works (except you cannot currently ask for\n> it separately, but arguably you could). If we have a proliferation of\n> such options, then we might need config to help turn them on all the\n> time (I'd guess people are probably already using aliases to do this).\n\nI think I like this path.\n\nI expect a common idiom to be 'git status -S --porcelain --null', and\nboth --porcelain and --null imply --short.  I think I can still do The\nRight Thing, but the code is starting to spaghettify.  I'll take a\ncrack at it.\n\nThanks.\n\nP\n"},{"id":"202155","messageId":"1351553513-20385-1-git-send-email-hordp@cisco.com","threadId":"31922","inReplyTo":"CABURp0qBRvZQvnBbOraQ7c7DRg8v0TjnY+MOGYaWnWwjCqi23Q@mail.gmail.com","subject":"[PATCHv2 0/3] git-status short sequencer state info","fromName":"Phil Hord","fromEmail":"hordp@cisco.com","sentAt":"2012-10-29T23:31:50Z","receivedAt":"2012-10-29T23:31:50Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"V2 of this patch breaks it into a series, cleans up some gaffes,\nand adds more flexible display options.  I still need to add some\ntests.  Until I do that, maybe this should be considered a WIP.\n\n [PATCHv2 1/3] Refactor print_state into get_state\n [PATCHv2 2/3] wt-status: More state retrieval abstraction\n [PATCHv2 3/3] git-status: show short sequencer state\n"},{"id":"202156","messageId":"1351553513-20385-2-git-send-email-hordp@cisco.com","threadId":"31922","inReplyTo":"1351553513-20385-1-git-send-email-hordp@cisco.com","subject":"[PATCHv2 1/3] Refactor print_state into get_state","fromName":"Phil Hord","fromEmail":"hordp@cisco.com","sentAt":"2012-10-29T23:31:51Z","receivedAt":"2012-10-29T23:31:51Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"Recently git-status learned to display the state of the git\nsequencer in long form to help the user remember an interrupted\ncommand.  This information is useful to other callers who do\nnot want it printed in the same way.\n\nSplit the new print_state function into separate get_state and\nprint_state functions so others can get this state info and\nshare common code.\n\nSigned-off-by: Phil Hord <hordp@cisco.com>\n---\n wt-status.c | 31 +++++++++++++++++++------------\n 1 file changed, 19 insertions(+), 12 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex 2a9658b..760f52b 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -928,34 +928,41 @@ static void show_bisect_in_progress(struct wt_status *s,\n \twt_status_print_trailer(s);\n }\n \n-static void wt_status_print_state(struct wt_status *s)\n+static void wt_status_get_state(struct wt_status *s , struct wt_status_state *state)\n {\n-\tconst char *state_color = color(WT_STATUS_HEADER, s);\n-\tstruct wt_status_state state;\n \tstruct stat st;\n \n-\tmemset(&state, 0, sizeof(state));\n+\tmemset(state, 0, sizeof(*state));\n \n+\t/* Determine sequencer activity */\n \tif (!stat(git_path(\"MERGE_HEAD\"), &st)) {\n-\t\tstate.merge_in_progress = 1;\n+\t\tstate->merge_in_progress = 1;\n \t} else if (!stat(git_path(\"rebase-apply\"), &st)) {\n \t\tif (!stat(git_path(\"rebase-apply/applying\"), &st)) {\n-\t\t\tstate.am_in_progress = 1;\n+\t\t\tstate->am_in_progress = 1;\n \t\t\tif (!stat(git_path(\"rebase-apply/patch\"), &st) && !st.st_size)\n-\t\t\t\tstate.am_empty_patch = 1;\n+\t\t\t\tstate->am_empty_patch = 1;\n \t\t} else {\n-\t\t\tstate.rebase_in_progress = 1;\n+\t\t\tstate->rebase_in_progress = 1;\n \t\t}\n \t} else if (!stat(git_path(\"rebase-merge\"), &st)) {\n \t\tif (!stat(git_path(\"rebase-merge/interactive\"), &st))\n-\t\t\tstate.rebase_interactive_in_progress = 1;\n+\t\t\tstate->rebase_interactive_in_progress = 1;\n \t\telse\n-\t\t\tstate.rebase_in_progress = 1;\n+\t\t\tstate->rebase_in_progress = 1;\n \t} else if (!stat(git_path(\"CHERRY_PICK_HEAD\"), &st)) {\n-\t\tstate.cherry_pick_in_progress = 1;\n+\t\tstate->cherry_pick_in_progress = 1;\n \t}\n \tif (!stat(git_path(\"BISECT_LOG\"), &st))\n-\t\tstate.bisect_in_progress = 1;\n+\t\tstate->bisect_in_progress = 1;\n+}\n+\n+static void wt_status_print_state(struct wt_status *s)\n+{\n+\tconst char *state_color = color(WT_STATUS_HEADER, s);\n+\tstruct wt_status_state state;\n+\n+\twt_status_get_state(s, &state);\n \n \tif (state.merge_in_progress)\n \t\tshow_merge_in_progress(s, &state, state_color);\n-- \n1.8.0.3.gde9c7d5.dirty\n"},{"id":"202157","messageId":"1351553513-20385-3-git-send-email-hordp@cisco.com","threadId":"31922","inReplyTo":"1351553513-20385-1-git-send-email-hordp@cisco.com","subject":"[PATCHv2 2/3] wt-status: More state retrieval abstraction","fromName":"Phil Hord","fromEmail":"hordp@cisco.com","sentAt":"2012-10-29T23:31:52Z","receivedAt":"2012-10-29T23:31:52Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"wt_status_print_state retrieves some sequencer state\ninformation via wt_status_get_state, but other state\ninformation it deduces on its own.  Replaces these\n\"local knowledge\" deductions with wt_status variables\nso we can share more common code in the future.\n---\n wt-status.c | 16 +++++++++-------\n wt-status.h |  3 +++\n 2 files changed, 12 insertions(+), 7 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex 760f52b..a888120 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -781,7 +781,7 @@ static void show_merge_in_progress(struct wt_status *s,\n \t\t\t\tstruct wt_status_state *state,\n \t\t\t\tconst char *color)\n {\n-\tif (has_unmerged(s)) {\n+\tif (state->has_unmerged) {\n \t\tstatus_printf_ln(s, color, _(\"You have unmerged paths.\"));\n \t\tif (advice_status_hints)\n \t\t\tstatus_printf_ln(s, color,\n@@ -867,9 +867,7 @@ static void show_rebase_in_progress(struct wt_status *s,\n \t\t\t\tstruct wt_status_state *state,\n \t\t\t\tconst char *color)\n {\n-\tstruct stat st;\n-\n-\tif (has_unmerged(s)) {\n+\tif (state->has_unmerged) {\n \t\tstatus_printf_ln(s, color, _(\"You are currently rebasing.\"));\n \t\tif (advice_status_hints) {\n \t\t\tstatus_printf_ln(s, color,\n@@ -879,12 +877,12 @@ static void show_rebase_in_progress(struct wt_status *s,\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (use \\\"git rebase --abort\\\" to check out the original branch)\"));\n \t\t}\n-\t} else if (state->rebase_in_progress || !stat(git_path(\"MERGE_MSG\"), &st)) {\n+\t} else if (state->rebase_in_progress || state->commit_is_pending) {\n \t\tstatus_printf_ln(s, color, _(\"You are currently rebasing.\"));\n \t\tif (advice_status_hints)\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (all conflicts fixed: run \\\"git rebase --continue\\\")\"));\n-\t} else if (split_commit_in_progress(s)) {\n+\t} else if (state->split_in_progress) {\n \t\tstatus_printf_ln(s, color, _(\"You are currently splitting a commit during a rebase.\"));\n \t\tif (advice_status_hints)\n \t\t\tstatus_printf_ln(s, color,\n@@ -907,7 +905,7 @@ static void show_cherry_pick_in_progress(struct wt_status *s,\n {\n \tstatus_printf_ln(s, color, _(\"You are currently cherry-picking.\"));\n \tif (advice_status_hints) {\n-\t\tif (has_unmerged(s))\n+\t\tif (state->has_unmerged)\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (fix conflicts and run \\\"git commit\\\")\"));\n \t\telse\n@@ -955,6 +953,10 @@ static void wt_status_get_state(struct wt_status *s , struct wt_status_state *st\n \t}\n \tif (!stat(git_path(\"BISECT_LOG\"), &st))\n \t\tstate->bisect_in_progress = 1;\n+\n+\tstate->has_unmerged = has_unmerged(s);\n+\tstate->split_in_progress = split_commit_in_progress(s);\n+\tstate->commit_is_pending = !stat(git_path(\"MERGE_MSG\"), &st);\n }\n \n static void wt_status_print_state(struct wt_status *s)\ndiff --git a/wt-status.h b/wt-status.h\nindex 236b41f..0b866a2 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -79,6 +79,9 @@ struct wt_status_state {\n \tint rebase_interactive_in_progress;\n \tint cherry_pick_in_progress;\n \tint bisect_in_progress;\n+\tint split_in_progress;\n+\tint has_unmerged;\n+\tint commit_is_pending;\n };\n \n void wt_status_prepare(struct wt_status *s);\n-- \n1.8.0.3.gde9c7d5.dirty\n"},{"id":"202158","messageId":"1351553513-20385-4-git-send-email-hordp@cisco.com","threadId":"31922","inReplyTo":"1351553513-20385-1-git-send-email-hordp@cisco.com","subject":"[PATCHv2 3/3] git-status: show short sequencer state","fromName":"Phil Hord","fromEmail":"hordp@cisco.com","sentAt":"2012-10-29T23:31:53Z","receivedAt":"2012-10-29T23:31:53Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"Teach git-status to report the sequencer state in short form\nusing a new --sequencer (-S) switch.  Output zero or more\nsimple state token strings indicating the deduced state of the\ngit sequencer.\n\nSequencer state info tokens are displayed in \"short\"\nform.  'git status --short -S' will show the normal short\nstatus including the sequencer tokens.  'git status -S'\nwithout --short will show only the new sequencer information\ntokens in whatever the requested format is.\n\nState token strings which may be emitted and their meanings:\n    merge              a merge is in progress\n    am                 an am is in progress\n    am-is-empty        the am patch is empty\n    rebase             a rebase is in progress\n    rebase-interactive an interactive rebase is in progress\n    cherry-pick        a cherry-pick is in progress\n    bisect             a bisect is in progress\n    conflicted         there are unresolved conflicts\n    commit-pending     a commit operation is waiting to be completed\n    splitting          interactive rebase, commit is being split\n\nI also considered adding these tokens, but I decided it was not\nappropriate since these changes are not sequencer-related.  But\nit is possible I am being too short-sighted or have chosen the\nswitch name poorly.\n    changed-index  Changes exist in the index\n    changed-files  Changes exist in the working directory\n    untracked      New files exist in the working directory\n\nSigned-off-by: Phil Hord <hordp@cisco.com>\n---\n Documentation/git-status.txt | 16 ++++++++++++++++\n builtin/commit.c             | 14 ++++++++++++++\n wt-status.c                  | 35 +++++++++++++++++++++++++++++++++++\n wt-status.h                  |  7 +++++++\n 4 files changed, 72 insertions(+)\n\ndiff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\nindex 67e5f53..7a699f1 100644\n--- a/Documentation/git-status.txt\n+++ b/Documentation/git-status.txt\n@@ -38,6 +38,22 @@ OPTIONS\n \tacross git versions and regardless of user configuration. See\n \tbelow for details.\n \n+-S::\n+--sequence::\n+\tShow the git sequencer status. This shows zero or more strings\n+\tdescribing the state of the git sequencer.\n++\n+\tmerge              a merge is in progress\n+\tam                 an am is in progress\n+\tam-is-empty        the am patch is empty\n+\trebase             a rebase is in progress\n+\trebase-interactive an interactive rebase is in progress\n+\tcherry-pick        a cherry-pick is in progress\n+\tbisect             a bisect is in progress\n+\tconflicted         there are unresolved conflicts\n+\tcommit-pending     a commit operation is waiting to be completed\n+\tsplitting          interactive rebase, commit is being split\n+\n -u[<mode>]::\n --untracked-files[=<mode>]::\n \tShow untracked files.\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex a17a5df..bf16cc6 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1060,6 +1060,11 @@ static int parse_and_validate_options(int argc, const char *argv[],\n \n \tif (s->null_termination && status_format == STATUS_FORMAT_LONG)\n \t\tstatus_format = STATUS_FORMAT_PORCELAIN;\n+\tif (s->show_sequencer && status_format != STATUS_FORMAT_SHORT) {\n+\t\ts->show_sequencer = SHOW_SEQUENCER_ONLY;\n+\t\tif (status_format == STATUS_FORMAT_LONG)\n+\t\t\tstatus_format = STATUS_FORMAT_SHORT;\n+\t}\n \tif (status_format != STATUS_FORMAT_LONG)\n \t\tdry_run = 1;\n \n@@ -1156,6 +1161,8 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \t\t\t    N_(\"show status concisely\"), STATUS_FORMAT_SHORT),\n \t\tOPT_BOOLEAN('b', \"branch\", &s.show_branch,\n \t\t\t    N_(\"show branch information\")),\n+\t\tOPT_SET_INT('S', \"sequencer\", &s.show_sequencer,\n+\t\t\t\tN_(\"show sequencer state information\"), SHOW_SEQUENCER_YES),\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@@ -1188,6 +1195,11 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \n \tif (s.null_termination && status_format == STATUS_FORMAT_LONG)\n \t\tstatus_format = STATUS_FORMAT_PORCELAIN;\n+\tif (s.show_sequencer && status_format != STATUS_FORMAT_SHORT) {\n+\t\ts.show_sequencer = SHOW_SEQUENCER_ONLY;\n+\t\tif (status_format == STATUS_FORMAT_LONG)\n+\t\t\tstatus_format = STATUS_FORMAT_SHORT;\n+\t}\n \n \thandle_untracked_files_arg(&s);\n \tif (show_ignored_in_status)\n@@ -1384,6 +1396,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\tOPT_SET_INT(0, \"short\", &status_format, N_(\"show status concisely\"),\n \t\t\t    STATUS_FORMAT_SHORT),\n \t\tOPT_BOOLEAN(0, \"branch\", &s.show_branch, N_(\"show branch information\")),\n+\t\tOPT_SET_INT(0, \"sequencer\", &s.show_sequencer,\n+\t\t\t    N_(\"show sequencer state information\"), SHOW_SEQUENCER_YES),\n \t\tOPT_SET_INT(0, \"porcelain\", &status_format,\n \t\t\t    N_(\"machine-readable output\"), STATUS_FORMAT_PORCELAIN),\n \t\tOPT_BOOLEAN('z', \"null\", &s.null_termination,\ndiff --git a/wt-status.c b/wt-status.c\nindex a888120..aee9745 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1201,6 +1201,34 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)\n \tfputc(s->null_termination ? '\\0' : '\\n', s->fp);\n }\n \n+static void wt_print_token(struct wt_status *s, const char * token_color, const char *token, int active)\n+{\n+\tif (active) {\n+\t\tcolor_fprintf(s->fp, token_color, \"## %s\", token);\n+\t\tfputc(s->null_termination ? '\\0' : '\\n', s->fp);\n+\t}\n+}\n+\n+static void wt_sequencer_print(struct wt_status *s)\n+{\n+\tstruct wt_status_state state;\n+\tconst char *header_color = color(WT_STATUS_HEADER, s);\n+\n+\twt_status_get_state(s, &state);\n+\n+\twt_print_token(s, header_color, \"merge\", state.merge_in_progress);\n+\twt_print_token(s, header_color, \"am\", state.am_in_progress);\n+\twt_print_token(s, header_color, \"rebase\", state.rebase_in_progress);\n+\twt_print_token(s, header_color, \"rebase-interactive\", state.rebase_interactive_in_progress);\n+\twt_print_token(s, header_color, \"cherry-pick\", state.cherry_pick_in_progress);\n+\twt_print_token(s, header_color, \"bisect\", state.bisect_in_progress);\n+\twt_print_token(s, header_color, \"am-empty\", state.am_empty_patch);\n+\n+\twt_print_token(s, header_color, \"conflicted\", state.has_unmerged);\n+\twt_print_token(s, header_color, \"commit-pending\", state.commit_is_pending);\n+\twt_print_token(s, header_color, \"splitting\", state.split_in_progress);\n+}\n+\n void wt_shortstatus_print(struct wt_status *s)\n {\n \tint i;\n@@ -1208,6 +1236,13 @@ void wt_shortstatus_print(struct wt_status *s)\n \tif (s->show_branch)\n \t\twt_shortstatus_print_tracking(s);\n \n+\tif (s->show_sequencer)\n+\t{\n+\t\twt_sequencer_print(s);\n+\t\tif (s->show_sequencer == SHOW_SEQUENCER_ONLY)\n+\t\t\treturn;\n+\t}\n+\n \tfor (i = 0; i < s->change.nr; i++) {\n \t\tstruct wt_status_change_data *d;\n \t\tstruct string_list_item *it;\ndiff --git a/wt-status.h b/wt-status.h\nindex 0b866a2..df4b36d 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -24,6 +24,12 @@ enum untracked_status_type {\n \tSHOW_ALL_UNTRACKED_FILES\n };\n \n+enum sequencer_status_type {\n+\tSHOW_SEQUENCER_NO=0,\n+\tSHOW_SEQUENCER_YES,\n+\tSHOW_SEQUENCER_ONLY\n+};\n+\n /* from where does this commit originate */\n enum commit_whence {\n \tFROM_COMMIT,     /* normal */\n@@ -59,6 +65,7 @@ struct wt_status {\n \tunsigned colopts;\n \tint null_termination;\n \tint show_branch;\n+\tenum sequencer_status_type show_sequencer;\n \n \t/* These are computed during processing of the individual sections */\n \tint commitable;\n-- \n1.8.0.3.gde9c7d5.dirty\n"},{"id":"202714","messageId":"1352487385-5929-1-git-send-email-hordp@cisco.com","threadId":"31922","inReplyTo":"1351553513-20385-1-git-send-email-hordp@cisco.com","subject":"[PATCHv3 0/4] git-status short sequencer state info","fromName":"Phil Hord","fromEmail":"hordp@cisco.com","sentAt":"2012-11-09T18:56:21Z","receivedAt":"2012-11-09T18:56:21Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"I think this series is fairly complete at this point. I am still\nmissing some tests in 4/4, but only because I am not sure how to\ninduce those conditions.  Maybe I should enlist help from $(git-blame).\n\n [PATCHv3 1/4] Refactor print_state into get_state\n [PATCHv3 2/4] wt-status: More state retrieval abstraction\n [PATCHv3 3/4] git-status: show short sequencer state\n [PATCHv3 4/4] Add tests for git-status --sequencer\n"},{"id":"202715","messageId":"1352487385-5929-2-git-send-email-hordp@cisco.com","threadId":"31922","inReplyTo":"1352487385-5929-1-git-send-email-hordp@cisco.com","subject":"[PATCHv3 1/4] Refactor print_state into get_state","fromName":"Phil Hord","fromEmail":"hordp@cisco.com","sentAt":"2012-11-09T18:56:22Z","receivedAt":"2012-11-09T18:56:22Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"Recently git-status learned to display the state of the git\nsequencer in long form to help the user remember an interrupted\ncommand.  This information is useful to other callers who do\nnot want it printed in the same way.\n\nSplit the new print_state function into separate get_state and\nprint_state functions so others can get this state info and\nshare common code.\n\nSigned-off-by: Phil Hord <hordp@cisco.com>\n---\n wt-status.c | 31 +++++++++++++++++++------------\n 1 file changed, 19 insertions(+), 12 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex 2a9658b..760f52b 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -928,34 +928,41 @@ static void show_bisect_in_progress(struct wt_status *s,\n \twt_status_print_trailer(s);\n }\n \n-static void wt_status_print_state(struct wt_status *s)\n+static void wt_status_get_state(struct wt_status *s , struct wt_status_state *state)\n {\n-\tconst char *state_color = color(WT_STATUS_HEADER, s);\n-\tstruct wt_status_state state;\n \tstruct stat st;\n \n-\tmemset(&state, 0, sizeof(state));\n+\tmemset(state, 0, sizeof(*state));\n \n+\t/* Determine sequencer activity */\n \tif (!stat(git_path(\"MERGE_HEAD\"), &st)) {\n-\t\tstate.merge_in_progress = 1;\n+\t\tstate->merge_in_progress = 1;\n \t} else if (!stat(git_path(\"rebase-apply\"), &st)) {\n \t\tif (!stat(git_path(\"rebase-apply/applying\"), &st)) {\n-\t\t\tstate.am_in_progress = 1;\n+\t\t\tstate->am_in_progress = 1;\n \t\t\tif (!stat(git_path(\"rebase-apply/patch\"), &st) && !st.st_size)\n-\t\t\t\tstate.am_empty_patch = 1;\n+\t\t\t\tstate->am_empty_patch = 1;\n \t\t} else {\n-\t\t\tstate.rebase_in_progress = 1;\n+\t\t\tstate->rebase_in_progress = 1;\n \t\t}\n \t} else if (!stat(git_path(\"rebase-merge\"), &st)) {\n \t\tif (!stat(git_path(\"rebase-merge/interactive\"), &st))\n-\t\t\tstate.rebase_interactive_in_progress = 1;\n+\t\t\tstate->rebase_interactive_in_progress = 1;\n \t\telse\n-\t\t\tstate.rebase_in_progress = 1;\n+\t\t\tstate->rebase_in_progress = 1;\n \t} else if (!stat(git_path(\"CHERRY_PICK_HEAD\"), &st)) {\n-\t\tstate.cherry_pick_in_progress = 1;\n+\t\tstate->cherry_pick_in_progress = 1;\n \t}\n \tif (!stat(git_path(\"BISECT_LOG\"), &st))\n-\t\tstate.bisect_in_progress = 1;\n+\t\tstate->bisect_in_progress = 1;\n+}\n+\n+static void wt_status_print_state(struct wt_status *s)\n+{\n+\tconst char *state_color = color(WT_STATUS_HEADER, s);\n+\tstruct wt_status_state state;\n+\n+\twt_status_get_state(s, &state);\n \n \tif (state.merge_in_progress)\n \t\tshow_merge_in_progress(s, &state, state_color);\n-- \n1.8.0.3.gde9c7d5.dirty\n"},{"id":"202716","messageId":"1352487385-5929-3-git-send-email-hordp@cisco.com","threadId":"31922","inReplyTo":"1352487385-5929-1-git-send-email-hordp@cisco.com","subject":"[PATCHv3 2/4] wt-status: Teach sequencer advice to use get_state","fromName":"Phil Hord","fromEmail":"hordp@cisco.com","sentAt":"2012-11-09T18:56:23Z","receivedAt":"2012-11-09T18:56:23Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"wt_status_print_state retrieves some sequencer state information via\nwt_status_get_state, but other state information it deduces on its\nown.  Replace these \"local knowledge\" deductions with wt_status\nvariables so we can share more common code in the future.\n---\n wt-status.c | 16 +++++++++-------\n wt-status.h |  3 +++\n 2 files changed, 12 insertions(+), 7 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex 760f52b..a888120 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -781,7 +781,7 @@ static void show_merge_in_progress(struct wt_status *s,\n \t\t\t\tstruct wt_status_state *state,\n \t\t\t\tconst char *color)\n {\n-\tif (has_unmerged(s)) {\n+\tif (state->has_unmerged) {\n \t\tstatus_printf_ln(s, color, _(\"You have unmerged paths.\"));\n \t\tif (advice_status_hints)\n \t\t\tstatus_printf_ln(s, color,\n@@ -867,9 +867,7 @@ static void show_rebase_in_progress(struct wt_status *s,\n \t\t\t\tstruct wt_status_state *state,\n \t\t\t\tconst char *color)\n {\n-\tstruct stat st;\n-\n-\tif (has_unmerged(s)) {\n+\tif (state->has_unmerged) {\n \t\tstatus_printf_ln(s, color, _(\"You are currently rebasing.\"));\n \t\tif (advice_status_hints) {\n \t\t\tstatus_printf_ln(s, color,\n@@ -879,12 +877,12 @@ static void show_rebase_in_progress(struct wt_status *s,\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (use \\\"git rebase --abort\\\" to check out the original branch)\"));\n \t\t}\n-\t} else if (state->rebase_in_progress || !stat(git_path(\"MERGE_MSG\"), &st)) {\n+\t} else if (state->rebase_in_progress || state->commit_is_pending) {\n \t\tstatus_printf_ln(s, color, _(\"You are currently rebasing.\"));\n \t\tif (advice_status_hints)\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (all conflicts fixed: run \\\"git rebase --continue\\\")\"));\n-\t} else if (split_commit_in_progress(s)) {\n+\t} else if (state->split_in_progress) {\n \t\tstatus_printf_ln(s, color, _(\"You are currently splitting a commit during a rebase.\"));\n \t\tif (advice_status_hints)\n \t\t\tstatus_printf_ln(s, color,\n@@ -907,7 +905,7 @@ static void show_cherry_pick_in_progress(struct wt_status *s,\n {\n \tstatus_printf_ln(s, color, _(\"You are currently cherry-picking.\"));\n \tif (advice_status_hints) {\n-\t\tif (has_unmerged(s))\n+\t\tif (state->has_unmerged)\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (fix conflicts and run \\\"git commit\\\")\"));\n \t\telse\n@@ -955,6 +953,10 @@ static void wt_status_get_state(struct wt_status *s , struct wt_status_state *st\n \t}\n \tif (!stat(git_path(\"BISECT_LOG\"), &st))\n \t\tstate->bisect_in_progress = 1;\n+\n+\tstate->has_unmerged = has_unmerged(s);\n+\tstate->split_in_progress = split_commit_in_progress(s);\n+\tstate->commit_is_pending = !stat(git_path(\"MERGE_MSG\"), &st);\n }\n \n static void wt_status_print_state(struct wt_status *s)\ndiff --git a/wt-status.h b/wt-status.h\nindex 236b41f..0b866a2 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -79,6 +79,9 @@ struct wt_status_state {\n \tint rebase_interactive_in_progress;\n \tint cherry_pick_in_progress;\n \tint bisect_in_progress;\n+\tint split_in_progress;\n+\tint has_unmerged;\n+\tint commit_is_pending;\n };\n \n void wt_status_prepare(struct wt_status *s);\n-- \n1.8.0.3.gde9c7d5.dirty\n"},{"id":"202717","messageId":"1352487385-5929-4-git-send-email-hordp@cisco.com","threadId":"31922","inReplyTo":"1352487385-5929-1-git-send-email-hordp@cisco.com","subject":"[PATCHv3 3/4] git-status: show short sequencer state","fromName":"Phil Hord","fromEmail":"hordp@cisco.com","sentAt":"2012-11-09T18:56:24Z","receivedAt":"2012-11-09T18:56:24Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"Teach git-status to report the sequencer state in short form\nusing a new --sequencer (-S) switch.  Output zero or more\nsimple state token strings indicating the deduced state of the\ngit sequencer.\n\nSequencer state info tokens are displayed in \"short\"\nform.  'git status --short -S' will show the normal short\nstatus including the sequencer tokens.  'git status -S'\nwithout --short will show only the new sequencer information\ntokens in whatever the requested format is.\n\nState token strings which may be emitted and their meanings:\n    merge              a merge is in progress\n    am                 an am is in progress\n    am-is-empty        the am patch is empty\n    rebase             a rebase is in progress\n    rebase-interactive an interactive rebase is in progress\n    cherry-pick        a cherry-pick is in progress\n    bisect             a bisect is in progress\n    conflicted         there are unresolved conflicts\n    commit-pending     a commit operation is waiting to be completed\n    splitting          interactive rebase, commit is being split\n\nI also considered adding these tokens, but I decided it was not\nappropriate since these changes are not sequencer-related.  But\nit is possible I am being too short-sighted or have chosen the\nswitch name poorly.\n    changed-index  Changes exist in the index\n    changed-files  Changes exist in the working directory\n    untracked      New files exist in the working directory\n\nSigned-off-by: Phil Hord <hordp@cisco.com>\n---\n Documentation/git-status.txt | 20 ++++++++++++++++++++\n builtin/commit.c             | 14 ++++++++++++++\n wt-status.c                  | 34 ++++++++++++++++++++++++++++++++++\n wt-status.h                  |  7 +++++++\n 4 files changed, 75 insertions(+)\n\ndiff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\nindex 67e5f53..bdacf08 100644\n--- a/Documentation/git-status.txt\n+++ b/Documentation/git-status.txt\n@@ -38,6 +38,26 @@ OPTIONS\n \tacross git versions and regardless of user configuration. See\n \tbelow for details.\n \n+-S::\n+--sequence::\n+\tShow the git sequencer status. This shows zero or more words\n+\tdescribing the state of the git sequencer. If --short is also\n+\tgiven, the words are shown at the beginning of the short-format\n+\tdisplay after the one-line branch information, if present.  If\n+\t--short is not given, then only the sequencer words are shown\n+\twith no other status information.\n++\n+\tmerge              a merge is in progress\n+\tam                 an am is in progress\n+\tam-is-empty        the am patch is empty\n+\trebase             a rebase is in progress\n+\trebase-interactive an interactive rebase is in progress\n+\tcherry-pick        a cherry-pick is in progress\n+\tbisect             a bisect is in progress\n+\tconflicted         there are unresolved conflicts\n+\tcommit-pending     a commit operation is waiting to be completed\n+\tsplitting          interactive rebase, commit is being split\n+\n -u[<mode>]::\n --untracked-files[=<mode>]::\n \tShow untracked files.\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex a17a5df..bf16cc6 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1060,6 +1060,11 @@ static int parse_and_validate_options(int argc, const char *argv[],\n \n \tif (s->null_termination && status_format == STATUS_FORMAT_LONG)\n \t\tstatus_format = STATUS_FORMAT_PORCELAIN;\n+\tif (s->show_sequencer && status_format != STATUS_FORMAT_SHORT) {\n+\t\ts->show_sequencer = SHOW_SEQUENCER_ONLY;\n+\t\tif (status_format == STATUS_FORMAT_LONG)\n+\t\t\tstatus_format = STATUS_FORMAT_SHORT;\n+\t}\n \tif (status_format != STATUS_FORMAT_LONG)\n \t\tdry_run = 1;\n \n@@ -1156,6 +1161,8 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \t\t\t    N_(\"show status concisely\"), STATUS_FORMAT_SHORT),\n \t\tOPT_BOOLEAN('b', \"branch\", &s.show_branch,\n \t\t\t    N_(\"show branch information\")),\n+\t\tOPT_SET_INT('S', \"sequencer\", &s.show_sequencer,\n+\t\t\t\tN_(\"show sequencer state information\"), SHOW_SEQUENCER_YES),\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@@ -1188,6 +1195,11 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \n \tif (s.null_termination && status_format == STATUS_FORMAT_LONG)\n \t\tstatus_format = STATUS_FORMAT_PORCELAIN;\n+\tif (s.show_sequencer && status_format != STATUS_FORMAT_SHORT) {\n+\t\ts.show_sequencer = SHOW_SEQUENCER_ONLY;\n+\t\tif (status_format == STATUS_FORMAT_LONG)\n+\t\t\tstatus_format = STATUS_FORMAT_SHORT;\n+\t}\n \n \thandle_untracked_files_arg(&s);\n \tif (show_ignored_in_status)\n@@ -1384,6 +1396,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\tOPT_SET_INT(0, \"short\", &status_format, N_(\"show status concisely\"),\n \t\t\t    STATUS_FORMAT_SHORT),\n \t\tOPT_BOOLEAN(0, \"branch\", &s.show_branch, N_(\"show branch information\")),\n+\t\tOPT_SET_INT(0, \"sequencer\", &s.show_sequencer,\n+\t\t\t    N_(\"show sequencer state information\"), SHOW_SEQUENCER_YES),\n \t\tOPT_SET_INT(0, \"porcelain\", &status_format,\n \t\t\t    N_(\"machine-readable output\"), STATUS_FORMAT_PORCELAIN),\n \t\tOPT_BOOLEAN('z', \"null\", &s.null_termination,\ndiff --git a/wt-status.c b/wt-status.c\nindex a888120..71da1fb 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1201,6 +1201,33 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)\n \tfputc(s->null_termination ? '\\0' : '\\n', s->fp);\n }\n \n+static void wt_print_token(struct wt_status *s, const char *token, int active)\n+{\n+\tif (active) {\n+\t\tcolor_fprintf(s->fp, color(WT_STATUS_HEADER, s), \"## %s\", prefix, token);\n+\t\tfputc(s->null_termination ? '\\0' : '\\n', s->fp);\n+\t}\n+}\n+\n+static void wt_sequencer_print(struct wt_status *s)\n+{\n+\tstruct wt_status_state state;\n+\n+\twt_status_get_state(s, &state);\n+\n+\twt_print_token(s, \"merge\", state.merge_in_progress);\n+\twt_print_token(s, \"am\", state.am_in_progress);\n+\twt_print_token(s, \"rebase\", state.rebase_in_progress);\n+\twt_print_token(s, \"rebase-interactive\", state.rebase_interactive_in_progress);\n+\twt_print_token(s, \"cherry-pick\", state.cherry_pick_in_progress);\n+\twt_print_token(s, \"bisect\", state.bisect_in_progress);\n+\twt_print_token(s, \"am-empty\", state.am_empty_patch);\n+\n+\twt_print_token(s, \"conflicted\", state.has_unmerged);\n+\twt_print_token(s, \"commit-pending\", state.commit_is_pending);\n+\twt_print_token(s, \"splitting\", state.split_in_progress);\n+}\n+\n void wt_shortstatus_print(struct wt_status *s)\n {\n \tint i;\n@@ -1208,6 +1235,13 @@ void wt_shortstatus_print(struct wt_status *s)\n \tif (s->show_branch)\n \t\twt_shortstatus_print_tracking(s);\n \n+\tif (s->show_sequencer)\n+\t{\n+\t\twt_sequencer_print(s);\n+\t\tif (s->show_sequencer == SHOW_SEQUENCER_ONLY)\n+\t\t\treturn;\n+\t}\n+\n \tfor (i = 0; i < s->change.nr; i++) {\n \t\tstruct wt_status_change_data *d;\n \t\tstruct string_list_item *it;\ndiff --git a/wt-status.h b/wt-status.h\nindex 0b866a2..df4b36d 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -24,6 +24,12 @@ enum untracked_status_type {\n \tSHOW_ALL_UNTRACKED_FILES\n };\n \n+enum sequencer_status_type {\n+\tSHOW_SEQUENCER_NO=0,\n+\tSHOW_SEQUENCER_YES,\n+\tSHOW_SEQUENCER_ONLY\n+};\n+\n /* from where does this commit originate */\n enum commit_whence {\n \tFROM_COMMIT,     /* normal */\n@@ -59,6 +65,7 @@ struct wt_status {\n \tunsigned colopts;\n \tint null_termination;\n \tint show_branch;\n+\tenum sequencer_status_type show_sequencer;\n \n \t/* These are computed during processing of the individual sections */\n \tint commitable;\n-- \n1.8.0.3.gde9c7d5.dirty\n"},{"id":"202718","messageId":"1352487385-5929-5-git-send-email-hordp@cisco.com","threadId":"31922","inReplyTo":"1352487385-5929-1-git-send-email-hordp@cisco.com","subject":"[PATCHv3 4/4] Add tests for git-status --sequencer","fromName":"Phil Hord","fromEmail":"hordp@cisco.com","sentAt":"2012-11-09T18:56:25Z","receivedAt":"2012-11-09T18:56:25Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"Add t7061-status-sequence.sh with tests for the various\n'git status --sequence' states.\n\nI did not include tests for these states because I am not\nsure how to induce these conditions organically yet:\n\n   conflicted am status\n   empty am status\n   rebase-interactive editing status\n   rebase-interactive splitting status\n\nSigned-off-by: Phil Hord <hordp@cisco.com>\n---\n t/t7061-status-sequence.sh | 96 ++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 96 insertions(+)\n create mode 100755 t/t7061-status-sequence.sh\n\ndiff --git a/t/t7061-status-sequence.sh b/t/t7061-status-sequence.sh\nnew file mode 100755\nindex 0000000..db99822\n--- /dev/null\n+++ b/t/t7061-status-sequence.sh\n@@ -0,0 +1,96 @@\n+#!/bin/sh\n+\n+test_description='sequencer state tokens'\n+\n+. ./test-lib.sh\n+\n+expect_tokens() {\n+\tfor TOKEN in \"$@\" ; do\n+\t\techo \"## $TOKEN\"\n+\tdone | sort\n+}\n+\n+status_has_only() {\n+\texpect_tokens \"$@\" >expect &&\n+\tgit status -S | sort >actual &&\n+\ttest_cmp expect actual\n+}\n+\t\n+test_expect_success setup '\n+\ttest_commit A &&\n+\ttest_commit B oneside added &&\n+\tgit checkout A^0 &&\n+\ttest_commit C oneside created\n+'\n+\n+test_expect_success 'status -S reports conflicted merge' '\n+\tgit checkout B^0 &&\n+\ttest_must_fail git merge C &&\n+\tstatus_has_only commit-pending conflicted merge\n+'\n+\n+test_expect_success 'git reset --hard cleans up merge status' '\n+\tgit reset --hard HEAD &&\n+\tstatus_has_only\n+'\n+\n+test_expect_success 'status -S reports conflicted rebase' '\n+\tgit reset --hard HEAD &&\n+\tgit checkout B^0 &&\n+\ttest_must_fail git rebase C &&\n+\tstatus_has_only conflicted rebase\n+'\n+\n+test_expect_success 'git rebase --abort cleans up rebase status' '\n+\tgit rebase --abort &&\n+\tstatus_has_only\n+'\n+\n+test_expect_success 'status -S reports incomplete cherry-pick' '\n+\tgit reset --hard HEAD &&\n+\tgit checkout A &&\n+\tgit cherry-pick --no-commit C &&\n+\tstatus_has_only commit-pending\n+'\n+\n+test_expect_success 'completing commit cleans up pending commit status' '\n+\tgit commit -mcompleted &&\n+\tstatus_has_only\n+'\n+\n+test_expect_success 'status -S reports failed cherry-pick' '\n+\tgit reset --hard HEAD &&\n+\tgit checkout B &&\n+\ttest_must_fail git cherry-pick C &&\n+\tstatus_has_only cherry-pick commit-pending conflicted\n+'\n+\n+test_expect_success 'resolved conflicts clear conflicted status' '\n+\tgit add oneside &&\n+\tstatus_has_only cherry-pick commit-pending\n+'\n+\n+test_expect_success 'aborted cherry-pick clears cherry-pick status' '\n+\tgit cherry-pick --abort &&\n+\tstatus_has_only\n+'\n+\n+test_expect_success 'conflicted rebase-interactive status' '\n+\tgit reset --hard HEAD &&\n+\tgit checkout B &&\n+\ttest_must_fail git rebase -i C &&\n+\tstatus_has_only rebase-interactive conflicted commit-pending\n+'\n+\n+test_expect_success 'bisect status' '\n+\tgit reset --hard HEAD &&\n+\tgit bisect start &&\n+\tstatus_has_only bisect\n+'\n+\n+test_expect_success 'bisect-reset clears bisect status' '\n+\tgit bisect reset &&\n+\tstatus_has_only\n+'\n+\n+test_done\n-- \n1.8.0.3.gde9c7d5.dirty\n"},{"id":"202977","messageId":"7vip9aiuk8.fsf@alter.siamese.dyndns.org","threadId":"31922","inReplyTo":"1352487385-5929-4-git-send-email-hordp@cisco.com","subject":"Re: [PATCHv3 3/4] git-status: show short sequencer state","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-11-12T17:45:43Z","receivedAt":"2012-11-12T17:45:43Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phil Hord <hordp@cisco.com> writes:\n\n> State token strings which may be emitted and their meanings:\n>     merge              a merge is in progress\n>     am                 an am is in progress\n>     am-is-empty        the am patch is empty\n>     rebase             a rebase is in progress\n>     rebase-interactive an interactive rebase is in progress\n>     cherry-pick        a cherry-pick is in progress\n>     bisect             a bisect is in progress\n>     conflicted         there are unresolved conflicts\n>     commit-pending     a commit operation is waiting to be completed\n>     splitting          interactive rebase, commit is being split\n>\n> I also considered adding these tokens, but I decided it was not\n> appropriate since these changes are not sequencer-related.  But\n> it is possible I am being too short-sighted or have chosen the\n> switch name poorly.\n>     changed-index  Changes exist in the index\n>     changed-files  Changes exist in the working directory\n>     untracked      New files exist in the working directory\n\nI tend to agree; unlike all the normal output from \"status -s\" that\nare per-file, the above are the overall states of the working tree.\n\nIt is just that most of the \"overall states\" look as if they are\ndominated by \"sequencer states\", but that is only because you chose\nto call states related to things like \"am\" and \"bisect\" that are not\nsequencer states as such.\n\nIt probably should be called the tree state, working tree state, or\nsomesuch.\n"},{"id":"202980","messageId":"50A13C9A.8070108@cisco.com","threadId":"31922","inReplyTo":"7vip9aiuk8.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv3 3/4] git-status: show short sequencer state","fromName":"Phil Hord","fromEmail":"hordp@cisco.com","sentAt":"2012-11-12T18:14:50Z","receivedAt":"2012-11-12T18:14:50Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"Junio C Hamano wrote:\n> Phil Hord <hordp@cisco.com> writes:\n>\n>> State token strings which may be emitted and their meanings:\n>>     merge              a merge is in progress\n>>     am                 an am is in progress\n>>     am-is-empty        the am patch is empty\n>>     rebase             a rebase is in progress\n>>     rebase-interactive an interactive rebase is in progress\n>>     cherry-pick        a cherry-pick is in progress\n>>     bisect             a bisect is in progress\n>>     conflicted         there are unresolved conflicts\n>>     commit-pending     a commit operation is waiting to be completed\n>>     splitting          interactive rebase, commit is being split\n>>\n>> I also considered adding these tokens, but I decided it was not\n>> appropriate since these changes are not sequencer-related.  But\n>> it is possible I am being too short-sighted or have chosen the\n>> switch name poorly.\n>>     changed-index  Changes exist in the index\n>>     changed-files  Changes exist in the working directory\n>>     untracked      New files exist in the working directory\n> I tend to agree; unlike all the normal output from \"status -s\" that\n> are per-file, the above are the overall states of the working tree.\n>\n> It is just that most of the \"overall states\" look as if they are\n> dominated by \"sequencer states\", but that is only because you chose\n> to call states related to things like \"am\" and \"bisect\" that are not\n> sequencer states as such.\n>\n> It probably should be called the tree state, working tree state, or\n> somesuch.\n\nI think you are agreeing that I chose the switch name poorly, right?\n\nDo you think '--tree-state' is an acceptable switch or do you have other\nsuggestions?\n\nPhil\n"},{"id":"202982","messageId":"CALkWK0=7JrE90TH=DLzBvybuaJQuOoXOfZO71OTsUGzDQ8bLMw@mail.gmail.com","threadId":"31922","inReplyTo":"1352487385-5929-2-git-send-email-hordp@cisco.com","subject":"Re: [PATCHv3 1/4] Refactor print_state into get_state","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2012-11-12T18:29:52Z","receivedAt":"2012-11-12T18:29:52Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Phil Hord wrote:\n> Recently git-status learned to display the state of the git\n> sequencer in long form to help the user remember an interrupted\n> command.  This information is useful to other callers who do\n> not want it printed in the same way.\n\nNit: Please mention that \"Recently\" refers to 83c750ac to save future\nreaders the trouble of running blame.\n\nThanks.\n\nRam\n"},{"id":"203161","messageId":"50A2DCD7.4050909@cisco.com","threadId":"31922","inReplyTo":"50A13C9A.8070108@cisco.com","subject":"Re: [PATCHv3 3/4] git-status: show short sequencer state","fromName":"Phil Hord","fromEmail":"hordp@cisco.com","sentAt":"2012-11-13T23:50:47Z","receivedAt":"2012-11-13T23:50:47Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"Phil Hord wrote:\n> Junio C Hamano wrote:\n>> Phil Hord <hordp@cisco.com> writes:\n>>\n>>> State token strings which may be emitted and their meanings:\n>>>     merge              a merge is in progress\n>>>     am                 an am is in progress\n>>>     am-is-empty        the am patch is empty\n>>>     rebase             a rebase is in progress\n>>>     rebase-interactive an interactive rebase is in progress\n>>>     cherry-pick        a cherry-pick is in progress\n>>>     bisect             a bisect is in progress\n>>>     conflicted         there are unresolved conflicts\n>>>     commit-pending     a commit operation is waiting to be completed\n>>>     splitting          interactive rebase, commit is being split\n>>>\n>>> I also considered adding these tokens, but I decided it was not\n>>> appropriate since these changes are not sequencer-related.  But\n>>> it is possible I am being too short-sighted or have chosen the\n>>> switch name poorly.\n>>>     changed-index  Changes exist in the index\n>>>     changed-files  Changes exist in the working directory\n>>>     untracked      New files exist in the working directory\n>> I tend to agree; unlike all the normal output from \"status -s\" that\n>> are per-file, the above are the overall states of the working tree.\n>>\n>> It is just that most of the \"overall states\" look as if they are\n>> dominated by \"sequencer states\", but that is only because you chose\n>> to call states related to things like \"am\" and \"bisect\" that are not\n>> sequencer states as such.\n>>\n>> It probably should be called the tree state, working tree state, or\n>> somesuch.\n> I think you are agreeing that I chose the switch name poorly, right?\n>\n> Do you think '--tree-state' is an acceptable switch or do you have other\n> suggestions?\n>\n\nI've been calling these 'tokens' myself.  A token is a word-or-phrase I\ncan parse easily with the default $IFS, for simpler script handling.\n\nI'm happy to make that official and use --tokens and -T, but I suspect a\nmore appropriate name is available.\n\nPhil\n"},{"id":"203188","messageId":"7vy5i4b9d8.fsf@alter.siamese.dyndns.org","threadId":"31922","inReplyTo":"50A2DCD7.4050909@cisco.com","subject":"Re: [PATCHv3 3/4] git-status: show short sequencer state","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-11-14T13:29:55Z","receivedAt":"2012-11-14T13:29:55Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phil Hord <hordp@cisco.com> writes:\n\n>> Do you think '--tree-state' is an acceptable switch or do you have other\n>> suggestions?\n>\n> I've been calling these 'tokens' myself.  A token is a word-or-phrase I\n> can parse easily with the default $IFS, for simpler script handling.\n\nThat name may be good for variables, but it is good only because you\nas the implementor know what purpose the tokens are used for.\nInstead of having to call them with a longer name, e.g. \"state\ntokens\", only because you know that these tokens represent tree-wide\n(as opposed to per-file) state, you can call them \"tokens\" in your\nimplementation (and in your head) without confusing yourself.\n\nTo the end users who should not care about the implementation\ndetail, it is not a good name at all.  The UI should surface the\npurpose, i.e. what these tokens are used for, (e.g. to represent\ntree-wide state) more than the fact that you happened to represent\nthem with a single short word (i.e. \"token\").\n\nSo --show-tree-state, --include-tree-state-in-the-output or\nsomething along that line that tells the user what the option is\nabout is more preferable than --token.  After all, you may want to\nuse tokens to represent different kind of information in a later\ntopic that is not about a tree-wide state, and you will regret that\nyou used --token for this particular feature at that time.\n"},{"id":"203189","messageId":"50A3A040.7040304@cisco.com","threadId":"31922","inReplyTo":"7vy5i4b9d8.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv3 3/4] git-status: show short sequencer state","fromName":"Phil Hord","fromEmail":"hordp@cisco.com","sentAt":"2012-11-14T13:44:32Z","receivedAt":"2012-11-14T13:44:32Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"Junio C Hamano wrote:\n> Phil Hord <hordp@cisco.com> writes:\n>\n>>> Do you think '--tree-state' is an acceptable switch or do you have other\n>>> suggestions?\n>> I've been calling these 'tokens' myself.  A token is a word-or-phrase I\n>> can parse easily with the default $IFS, for simpler script handling.\n> That name may be good for variables, but it is good only because you\n> as the implementor know what purpose the tokens are used for.\n> Instead of having to call them with a longer name, e.g. \"state\n> tokens\", only because you know that these tokens represent tree-wide\n> (as opposed to per-file) state, you can call them \"tokens\" in your\n> implementation (and in your head) without confusing yourself.\n>\n> To the end users who should not care about the implementation\n> detail, it is not a good name at all.  The UI should surface the\n> purpose, i.e. what these tokens are used for, (e.g. to represent\n> tree-wide state) more than the fact that you happened to represent\n> them with a single short word (i.e. \"token\").\n>\n> So --show-tree-state, --include-tree-state-in-the-output or\n> something along that line that tells the user what the option is\n> about is more preferable than --token.  After all, you may want to\n> use tokens to represent different kind of information in a later\n> topic that is not about a tree-wide state, and you will regret that\n> you used --token for this particular feature at that time.\n\nI don't think I would regret it at all.  I do not expect to conflate the\nword \"tokens\" with the meaning \"show-tree-state\".  It only has this\nmeaning because it is part 'git status'.  If I want to show a different\nkind of tokens in the future, I think \"--tokens\" would still work fine\nthere.  It would even have precedent.\n\nConsider the usage:\n\n  git status   # show work-tree status\n  git status --short  # show short work-tree status\n  git status --tokens  # show work-tree status in token form\n\nIn the future if someone adds a similar operation to another command,I\ndo not think it would be confusing if it had a similar result. \n\n  git log --tokens\n  git show-ref --tokens HEAD\n\nBut maybe \"--tokens\" has some better meaning that someone will want to\nuse in the future.  I'm not married to it.  But \"git status\" already\nmeans \"Show the working tree status\".  So \"git status --show-tree-state\"\nsounds redundant or meaningless.\n\n'git status' already recognizes switches --ignored and --branch, for\nexample, to add extra state information to the output.  I want to add\n\"tree-state tokens\" to the list.  But I don't know a better name for them.\n\nPerhaps \"--show-tree-state\" is sufficient.  Still sounds redundant to me.\n\nPhil\n"},{"id":"203203","messageId":"7vfw4caxkh.fsf@alter.siamese.dyndns.org","threadId":"31922","inReplyTo":"50A3A040.7040304@cisco.com","subject":"Re: [PATCHv3 3/4] git-status: show short sequencer state","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-11-14T17:44:46Z","receivedAt":"2012-11-14T17:44:46Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phil Hord <hordp@cisco.com> writes:\n\n> Consider the usage:\n>\n>   git status   # show work-tree status\n>   git status --short  # show short work-tree status\n>   git status --tokens  # show work-tree status in token form\n\nOK, your --tokens is more about *how* things are output, but it is\nunclear how it would interact with --short.  I had an impression\nthat you are basing your output on the short output, whose existing\nrecord include \"##\" (that shows the branch names and states), and\n\"MM\", \"A \" and friends (that show the per-file states), by adding\nnew record types that shows tree-wide states.\n\n> But maybe \"--tokens\" has some better meaning that someone will want to\n> use in the future.  I'm not married to it.  But \"git status\" already\n> means \"Show the working tree status\".  So \"git status --show-tree-state\"\n> sounds redundant or meaningless.\n\nI didn't mean to say that you have to spell out all these words;\n\"show\" and \"state\" are redundant.\n\nThe important part is that unlike the existing \"per-file\" state the\n\"status\" command is showing, the option is to add \"tree-wide\" state\nto the output, and my suggestion was to pick a word that makes it\nclear, rather than using \"output is done using tokens\" without\nsaying \"what is being output in tokenized form\".\n"},{"id":"203211","messageId":"50A3ED8A.9080604@cisco.com","threadId":"31922","inReplyTo":"7vfw4caxkh.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv3 3/4] git-status: show short sequencer state","fromName":"Phil Hord","fromEmail":"hordp@cisco.com","sentAt":"2012-11-14T19:14:18Z","receivedAt":"2012-11-14T19:14:18Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"\nJunio C Hamano wrote:\n> Phil Hord <hordp@cisco.com> writes:\n>\n>> Consider the usage:\n>>\n>>   git status   # show work-tree status\n>>   git status --short  # show short work-tree status\n>>   git status --tokens  # show work-tree status in token form\n> OK, your --tokens is more about *how* things are output, but it is\n> unclear how it would interact with --short.  I had an impression\n> that you are basing your output on the short output, whose existing\n> record include \"##\" (that shows the branch names and states), and\n> \"MM\", \"A \" and friends (that show the per-file states), by adding\n> new record types that shows tree-wide states.\n\nI am, but I don't much care for the \"##\" prefix, especially when\ncombined with --null, for example.  I'm inclined to remove it when\n--short is not provided, specifically to give scripts an easier time of\nparsing.  But scripts are likely to need \"--porcelain\" as well, and\ncurrently that implies \"--short\".  But I suppose another combination\ncould be meaningful.\n\n  # tokens only\n  $ git status --tree\n  changed-files\n\n  # tokens and short-status\n  $ git status --tree --short  \n  ## changed-files\n   M foo.txt\n\n  # short-status only\n  $ git status --porcelain\n   M foo.txt\n\n  # tokens only?\n  $ git status --tree --porcelain\n  changed-files\n\nI think this spaghettify's the ui too much.  Maybe this instead:\n\n  # undecorated tokens only\n  $ git status --tree=porcelain\n  changed-files\n\n\n>\n>> But maybe \"--tokens\" has some better meaning that someone will want to\n>> use in the future.  I'm not married to it.  But \"git status\" already\n>> means \"Show the working tree status\".  So \"git status --show-tree-state\"\n>> sounds redundant or meaningless.\n> I didn't mean to say that you have to spell out all these words;\n> \"show\" and \"state\" are redundant.\n>\n> The important part is that unlike the existing \"per-file\" state the\n> \"status\" command is showing, the option is to add \"tree-wide\" state\n> to the output, and my suggestion was to pick a word that makes it\n> clear, rather than using \"output is done using tokens\" without\n> saying \"what is being output in tokenized form\".\n\nThanks for clarifying. \n\nPhil\n"},{"id":"203214","messageId":"7v7gpoasf4.fsf@alter.siamese.dyndns.org","threadId":"31922","inReplyTo":"50A3ED8A.9080604@cisco.com","subject":"Re: [PATCHv3 3/4] git-status: show short sequencer state","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-11-14T19:35:59Z","receivedAt":"2012-11-14T19:35:59Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phil Hord <hordp@cisco.com> writes:\n\n>   # tokens and short-status\n>   $ git status --tree --short  \n>   ## changed-files\n>    M foo.txt\n\nHrm, how will the existing readers of the output avoid getting\nconfused by this overloading of \"##\", which has meant the current\nbranch information?\n\n>   # tokens only?\n>   $ git status --tree --porcelain\n>   changed-files\n\nIt probably is simpler for parsers of the --porcelain format if you\n(1) always used first two bytes as the record type, and (2) avoided\nusing \"##\" that is already used for the tree-wide status.\n\nJust a thought.\n"},{"id":"203217","messageId":"7v390carf4.fsf@alter.siamese.dyndns.org","threadId":"31922","inReplyTo":"7v7gpoasf4.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv3 3/4] git-status: show short sequencer state","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-11-14T19:57:35Z","receivedAt":"2012-11-14T19:57:35Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Phil Hord <hordp@cisco.com> writes:\n>\n>>   # tokens and short-status\n>>   $ git status --tree --short  \n>>   ## changed-files\n>>    M foo.txt\n>\n> Hrm, how will the existing readers of the output avoid getting\n> confused by this overloading of \"##\", which has meant the current\n> branch information?\n\nThat was a stupid question.\n\nExisting readers do not know to give --tree to the command, so they\nare perfectly OK.\n\nIt is however not OK for new readers that wants to read these\ntree-wide state and also branch information.\n"}]}