{"thread":{"id":"46199","subject":"[PATCH 0/3] add stash count information to git-status command","startedAt":"2017-06-16T04:31:04Z","lastAt":"2017-06-19T05:18:34Z","messageCount":16,"participants":["Liam Beguin","Jeff King","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"322433","messageId":"20170616043050.29192-1-liambeguin@gmail.com","threadId":"46199","inReplyTo":null,"subject":"[PATCH 0/3] add stash count information to git-status command","fromName":"Liam Beguin","fromEmail":"liambeguin@gmail.com","sentAt":"2017-06-16T04:30:47Z","receivedAt":"2017-06-16T04:31:04Z","isPatch":true,"sender":{"key":"liambeguin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3811160?v=4"},"body":"As discussed here [*1*], this allows `git status` to show the number of\nentries currently stashed away.\n\nI also tried to update the related parts of the documentation to use\n'stash entry' instead of 'stash' as we agreed that it was a bit better.\nI don't mind dropping the documentation update and using something like\n\"You have %d stash/stashes\" in the status message if it makes the change\n\"too big\".\n\n*1* https://public-inbox.org/git/CA+B9myHRahTd+FDgzK5AhXW+hq_Y_czMX9X6MXYBcr9WSPeiDw@mail.gmail.com/\n\nLiam Beguin (3):\n  stash: update documentation to use 'stash entries'\n  wt-status: add optional stash status information\n  glossary: define stash entries\n\n Documentation/config.txt           | 11 ++++++---\n Documentation/git-pull.txt         |  2 +-\n Documentation/git-rebase.txt       |  2 +-\n Documentation/git-stash.txt        | 49 +++++++++++++++++++-------------------\n Documentation/gitcli.txt           |  2 +-\n Documentation/glossary-content.txt |  4 ++++\n git-stash.sh                       |  6 ++---\n wt-status.c                        | 24 +++++++++++++++++++\n 8 files changed, 67 insertions(+), 33 deletions(-)\n\n-- \n2.9.4\n\n"},{"id":"322434","messageId":"20170616043050.29192-2-liambeguin@gmail.com","threadId":"46199","inReplyTo":"20170616043050.29192-1-liambeguin@gmail.com","subject":"[PATCH 1/3] stash: update documentation to use 'stash entries'","fromName":"Liam Beguin","fromEmail":"liambeguin@gmail.com","sentAt":"2017-06-16T04:30:48Z","receivedAt":"2017-06-16T04:31:10Z","isPatch":true,"sender":{"key":"liambeguin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3811160?v=4"},"body":"Most of the time, a 'stash entry' is called a 'stash'\nor a 'stash state'. Lets use 'stash entry' instead.\n\nSigned-off-by: Liam Beguin <liambeguin@gmail.com>\n---\n Documentation/config.txt     |  6 +++---\n Documentation/git-pull.txt   |  2 +-\n Documentation/git-rebase.txt |  2 +-\n Documentation/git-stash.txt  | 49 ++++++++++++++++++++++----------------------\n Documentation/gitcli.txt     |  2 +-\n git-stash.sh                 |  6 +++---\n 6 files changed, 34 insertions(+), 33 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex f6278a5ae6a1..23b807065d92 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -2620,7 +2620,7 @@ rebase.autoSquash::\n \tIf set to true enable `--autosquash` option by default.\n \n rebase.autoStash::\n-\tWhen set to true, automatically create a temporary stash\n+\tWhen set to true, automatically create a temporary stash entry\n \tbefore the operation begins, and apply it after the operation\n \tends.  This means that you can run rebase on a dirty worktree.\n \tHowever, use with care: the final stash application after a\n@@ -3029,12 +3029,12 @@ status.submoduleSummary::\n \n stash.showPatch::\n \tIf this is set to true, the `git stash show` command without an\n-\toption will show the stash in patch form.  Defaults to false.\n+\toption will show the stash entry in patch form.  Defaults to false.\n \tSee description of 'show' command in linkgit:git-stash[1].\n \n stash.showStat::\n \tIf this is set to true, the `git stash show` command without an\n-\toption will show diffstat of the stash.  Defaults to true.\n+\toption will show diffstat of the stash entry.  Defaults to true.\n \tSee description of 'show' command in linkgit:git-stash[1].\n \n submodule.<name>.url::\ndiff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt\nindex e414185f5a6a..9db5e08f4a63 100644\n--- a/Documentation/git-pull.txt\n+++ b/Documentation/git-pull.txt\n@@ -131,7 +131,7 @@ unless you have read linkgit:git-rebase[1] carefully.\n --autostash::\n --no-autostash::\n \tBefore starting rebase, stash local modifications away (see\n-\tlinkgit:git-stash[1]) if needed, and apply the stash when\n+\tlinkgit:git-stash[1]) if needed, and apply the stash entry when\n \tdone. `--no-autostash` is useful to override the `rebase.autoStash`\n \tconfiguration variable (see linkgit:git-config[1]).\n +\ndiff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt\nindex 53f4e144444a..a5afd602d8eb 100644\n--- a/Documentation/git-rebase.txt\n+++ b/Documentation/git-rebase.txt\n@@ -446,7 +446,7 @@ used to override and disable this setting.\n \n --autostash::\n --no-autostash::\n-\tAutomatically create a temporary stash before the operation\n+\tAutomatically create a temporary stash entry before the operation\n \tbegins, and apply it after the operation ends.  This means\n \tthat you can run rebase on a dirty worktree.  However, use\n \twith care: the final stash application after a successful\ndiff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt\nindex 70191d06b69e..59979ad31dfe 100644\n--- a/Documentation/git-stash.txt\n+++ b/Documentation/git-stash.txt\n@@ -51,18 +51,18 @@ OPTIONS\n save [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [<message>]::\n push [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [-m|--message <message>] [--] [<pathspec>...]::\n \n-\tSave your local modifications to a new 'stash' and roll them\n+\tSave your local modifications to a new 'stash entry' and roll them\n \tback to HEAD (in the working tree and in the index).\n \tThe <message> part is optional and gives\n \tthe description along with the stashed state.\n +\n For quickly making a snapshot, you can omit \"push\".  In this mode,\n non-option arguments are not allowed to prevent a misspelled\n-subcommand from making an unwanted stash.  The two exceptions to this\n+subcommand from making an unwanted entry.  The two exceptions to this\n are `stash -p` which acts as alias for `stash push -p` and pathspecs,\n which are allowed after a double hyphen `--` for disambiguation.\n +\n-When pathspec is given to 'git stash push', the new stash records the\n+When pathspec is given to 'git stash push', the new stash entry records the\n modified states only for the files that match the pathspec.  The index\n entries and working tree files are then rolled back to the state in\n HEAD only for these files, too, leaving files that do not match the\n@@ -89,10 +89,10 @@ The `--patch` option implies `--keep-index`.  You can use\n \n list [<options>]::\n \n-\tList the stashes that you currently have.  Each 'stash' is listed\n-\twith its name (e.g. `stash@{0}` is the latest stash, `stash@{1}` is\n+\tList the stash entries that you currently have.  Each 'stash entry' is\n+\tlisted with its name (e.g. `stash@{0}` is the latest entry, `stash@{1}` is\n \tthe one before, etc.), the name of the branch that was current when the\n-\tstash was made, and a short description of the commit the stash was\n+\tentry was made, and a short description of the commit the entry was\n \tbased on.\n +\n ----------------------------------------------------------------\n@@ -105,11 +105,11 @@ command to control what is shown and how. See linkgit:git-log[1].\n \n show [<stash>]::\n \n-\tShow the changes recorded in the stash as a diff between the\n-\tstashed state and its original parent. When no `<stash>` is given,\n+\tShow the changes recorded in the stash entry as a diff between the\n+\tstashed entry and its original parent. When no `<stash>` is given, it\n \tshows the latest one. By default, the command shows the diffstat, but\n \tit will accept any format known to 'git diff' (e.g., `git stash show\n-\t-p stash@{1}` to view the second most recent stash in patch form).\n+\t-p stash@{1}` to view the second most recent entry in patch form).\n \tYou can use stash.showStat and/or stash.showPatch config variables\n \tto change the default behavior.\n \n@@ -149,26 +149,27 @@ branch <branchname> [<stash>]::\n +\n This is useful if the branch on which you ran `git stash save` has\n changed enough that `git stash apply` fails due to conflicts. Since\n-the stash is applied on top of the commit that was HEAD at the time\n-`git stash` was run, it restores the originally stashed state with\n-no conflicts.\n+the stash entry is applied on top of the commit that was HEAD at the\n+time `git stash` was run, it restores the originally stashed entry\n+with no conflicts.\n \n clear::\n-\tRemove all the stashed states. Note that those states will then\n+\tRemove all the stashed entries. Note that those entries will then\n \tbe subject to pruning, and may be impossible to recover (see\n \t'Examples' below for a possible strategy).\n \n drop [-q|--quiet] [<stash>]::\n \n-\tRemove a single stashed state from the stash list. When no `<stash>`\n+\tRemove a single stashed entry from the stash list. When no `<stash>`\n \tis given, it removes the latest one. i.e. `stash@{0}`, otherwise\n \t`<stash>` must be a valid stash log reference of the form\n \t`stash@{<revision>}`.\n \n create::\n \n-\tCreate a stash (which is a regular commit object) and return its\n-\tobject name, without storing it anywhere in the ref namespace.\n+\tCreate a stash entry (which is a regular commit object) and\n+\treturn its object name, without storing it anywhere in the ref\n+\tnamespace.\n \tThis is intended to be useful for scripts.  It is probably not\n \tthe command you want to use; see \"save\" above.\n \n@@ -182,10 +183,10 @@ store::\n DISCUSSION\n ----------\n \n-A stash is represented as a commit whose tree records the state of the\n-working directory, and its first parent is the commit at `HEAD` when\n-the stash was created.  The tree of the second parent records the\n-state of the index when the stash is made, and it is made a child of\n+A stash entry is represented as a commit whose tree records the state\n+of the working directory, and its first parent is the commit at `HEAD`\n+when the entry was created.  The tree of the second parent records the\n+state of the index when the entry is made, and it is made a child of\n the `HEAD` commit.  The ancestry graph looks like this:\n \n             .----W\n@@ -269,12 +270,12 @@ $ edit/build/test remaining parts\n $ git commit foo -m 'Remaining parts'\n ----------------------------------------------------------------\n \n-Recovering stashes that were cleared/dropped erroneously::\n+Recovering stash entries that were cleared/dropped erroneously::\n \n-If you mistakenly drop or clear stashes, they cannot be recovered\n+If you mistakenly drop or clear stash entries, they cannot be recovered\n through the normal safety mechanisms.  However, you can try the\n-following incantation to get a list of stashes that are still in your\n-repository, but not reachable any more:\n+following incantation to get a list of stash entries that are still in\n+your repository, but not reachable any more:\n +\n ----------------------------------------------------------------\n git fsck --unreachable |\ndiff --git a/Documentation/gitcli.txt b/Documentation/gitcli.txt\nindex dfe7d8372723..9f13266a6851 100644\n--- a/Documentation/gitcli.txt\n+++ b/Documentation/gitcli.txt\n@@ -194,7 +194,7 @@ different things.\n  * The `--index` option is used to ask a command that\n    usually works on files in the working tree to *also*\n    affect the index.  For example, `git stash apply` usually\n-   merges changes recorded in a stash to the working tree,\n+   merges changes recorded in a stash entry to the working tree,\n    but with the `--index` option, it also merges changes to\n    the index as well.\n \ndiff --git a/git-stash.sh b/git-stash.sh\nindex 2fb651b2b8d9..0dfa4785f361 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -481,7 +481,7 @@ parse_flags_and_rev()\n \n \tcase $# in\n \t\t0)\n-\t\t\thave_stash || die \"$(gettext \"No stash found.\")\"\n+\t\t\thave_stash || die \"$(gettext \"No stash entry found.\")\"\n \t\t\tset -- ${ref_stash}@{0}\n \t\t;;\n \t\t1)\n@@ -573,7 +573,7 @@ apply_stash () {\n \t\tGIT_INDEX_FILE=\"$TMPindex\" git-read-tree \"$u_tree\" &&\n \t\tGIT_INDEX_FILE=\"$TMPindex\" git checkout-index --all &&\n \t\trm -f \"$TMPindex\" ||\n-\t\tdie \"$(gettext \"Could not restore untracked files from stash\")\"\n+\t\tdie \"$(gettext \"Could not restore untracked files from stash entry\")\"\n \tfi\n \n \teval \"\n@@ -627,7 +627,7 @@ pop_stash() {\n \t\tdrop_stash \"$@\"\n \telse\n \t\tstatus=$?\n-\t\tsay \"$(gettext \"The stash is kept in case you need it again.\")\"\n+\t\tsay \"$(gettext \"The stash entry is kept in case you need it again.\")\"\n \t\texit $status\n \tfi\n }\n-- \n2.9.4\n\n"},{"id":"322435","messageId":"20170616043050.29192-3-liambeguin@gmail.com","threadId":"46199","inReplyTo":"20170616043050.29192-1-liambeguin@gmail.com","subject":"[PATCH 2/3] wt-status: add optional stash status information","fromName":"Liam Beguin","fromEmail":"liambeguin@gmail.com","sentAt":"2017-06-16T04:30:49Z","receivedAt":"2017-06-16T04:31:17Z","isPatch":true,"sender":{"key":"liambeguin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3811160?v=4"},"body":"Add the `status.showStash` configuration option to allow git-status to\nshow information about currently stashed entries.\n\nSigned-off-by: Liam Beguin <liambeguin@gmail.com>\n---\n Documentation/config.txt |  5 +++++\n wt-status.c              | 24 ++++++++++++++++++++++++\n 2 files changed, 29 insertions(+)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 23b807065d92..e83b0f641574 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -2992,6 +2992,11 @@ status.displayCommentPrefix::\n \tbehavior of linkgit:git-status[1] in Git 1.8.4 and previous.\n \tDefaults to false.\n \n+status.showStash::\n+\tIf set to true, linkgit:git-status[1] will display the number of\n+\tentries currently stashed away.\n+\tDefaults to false.\n+\n status.showUntrackedFiles::\n \tBy default, linkgit:git-status[1] and linkgit:git-commit[1] show\n \tfiles which are not currently tracked by Git. Directories which\ndiff --git a/wt-status.c b/wt-status.c\nindex bf651f16fae8..7114eec123c8 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -801,6 +801,27 @@ static void wt_longstatus_print_changed(struct wt_status *s)\n \twt_longstatus_print_trailer(s);\n }\n \n+static int stash_count_refs(struct object_id *ooid, struct object_id *noid,\n+\t\t\t    const char *email, timestamp_t timestamp, int tz,\n+\t\t\t    const char *message, void *cb_data)\n+{\n+\tint *c = cb_data;\n+\t(*c)++;\n+\treturn 0;\n+}\n+\n+static void wt_longstatus_print_stash_summary(struct wt_status *s)\n+{\n+\tint stash_count = 0;\n+\n+\tfor_each_reflog_ent(\"refs/stash\", stash_count_refs, &stash_count);\n+\tif (stash_count > 0)\n+\t\tstatus_printf_ln(s, GIT_COLOR_NORMAL,\n+\t\t\t\t Q_(\"Your stash currently has %d entry\",\n+\t\t\t\t    \"Your stash currently has %d entries\", stash_count),\n+\t\t\t\t stash_count);\n+}\n+\n static void wt_longstatus_print_submodule_summary(struct wt_status *s, int uncommitted)\n {\n \tstruct child_process sm_summary = CHILD_PROCESS_INIT;\n@@ -1537,6 +1558,7 @@ static void wt_longstatus_print(struct wt_status *s)\n \tconst char *branch_color = color(WT_STATUS_ONBRANCH, s);\n \tconst char *branch_status_color = color(WT_STATUS_HEADER, s);\n \tstruct wt_status_state state;\n+\tint show_stash = 0;\n \n \tmemset(&state, 0, sizeof(state));\n \twt_status_get_state(&state,\n@@ -1642,6 +1664,8 @@ static void wt_longstatus_print(struct wt_status *s)\n \t\t} else\n \t\t\tprintf(_(\"nothing to commit, working tree clean\\n\"));\n \t}\n+\tif (!git_config_get_bool(\"status.showStash\", &show_stash) && show_stash)\n+\t\twt_longstatus_print_stash_summary(s);\n }\n \n static void wt_shortstatus_unmerged(struct string_list_item *it,\n-- \n2.9.4\n\n"},{"id":"322436","messageId":"20170616043050.29192-4-liambeguin@gmail.com","threadId":"46199","inReplyTo":"20170616043050.29192-1-liambeguin@gmail.com","subject":"[PATCH 3/3] glossary: define stash entries","fromName":"Liam Beguin","fromEmail":"liambeguin@gmail.com","sentAt":"2017-06-16T04:30:50Z","receivedAt":"2017-06-16T04:31:24Z","isPatch":true,"sender":{"key":"liambeguin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3811160?v=4"},"body":"Add glossary entry for \"stash entries\".\n\nSigned-off-by: Liam Beguin <liambeguin@gmail.com>\n---\n Documentation/glossary-content.txt | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/Documentation/glossary-content.txt b/Documentation/glossary-content.txt\nindex 6e991c246915..026f66e7240a 100644\n--- a/Documentation/glossary-content.txt\n+++ b/Documentation/glossary-content.txt\n@@ -570,6 +570,10 @@ The most notable example is `HEAD`.\n \tis created by giving the `--depth` option to linkgit:git-clone[1], and\n \tits history can be later deepened with linkgit:git-fetch[1].\n \n+[[def_stash]]stash entry::\n+\tAn <<def_object,object>> used to temporarily store the content of a\n+\t<<def_dirty,dirty>> working directory for futur reuse.\n+\n [[def_submodule]]submodule::\n \tA <<def_repository,repository>> that holds the history of a\n \tseparate project inside another repository (the latter of\n-- \n2.9.4\n\n"},{"id":"322451","messageId":"20170616120607.dj474det3dbx6ang@sigill.intra.peff.net","threadId":"46199","inReplyTo":"20170616043050.29192-2-liambeguin@gmail.com","subject":"Re: [PATCH 1/3] stash: update documentation to use 'stash entries'","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-06-16T12:06:08Z","receivedAt":"2017-06-16T12:06:15Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Jun 16, 2017 at 12:30:48AM -0400, Liam Beguin wrote:\n\n> Most of the time, a 'stash entry' is called a 'stash'\n> or a 'stash state'. Lets use 'stash entry' instead.\n\nI agree that this reads better. There is one exception:\n\n> diff --git a/git-stash.sh b/git-stash.sh\n> index 2fb651b2b8d9..0dfa4785f361 100755\n> --- a/git-stash.sh\n> +++ b/git-stash.sh\n> @@ -481,7 +481,7 @@ parse_flags_and_rev()\n>  \n>  \tcase $# in\n>  \t\t0)\n> -\t\t\thave_stash || die \"$(gettext \"No stash found.\")\"\n> +\t\t\thave_stash || die \"$(gettext \"No stash entry found.\")\"\n>  \t\t\tset -- ${ref_stash}@{0}\n\nI don't think your change is wrong (and it's probably more grammatical\nthan the original), but should this perhaps be \"No stashes found\" or \"No\nstash entries found\"?\n\n-Peff\n"},{"id":"322452","messageId":"20170616121423.smdtmcmbktuit2qb@sigill.intra.peff.net","threadId":"46199","inReplyTo":"20170616043050.29192-3-liambeguin@gmail.com","subject":"Re: [PATCH 2/3] wt-status: add optional stash status information","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-06-16T12:14:23Z","receivedAt":"2017-06-16T12:14:30Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Jun 16, 2017 at 12:30:49AM -0400, Liam Beguin wrote:\n\n> @@ -1642,6 +1664,8 @@ static void wt_longstatus_print(struct wt_status *s)\n>  \t\t} else\n>  \t\t\tprintf(_(\"nothing to commit, working tree clean\\n\"));\n>  \t}\n> +\tif (!git_config_get_bool(\"status.showStash\", &show_stash) && show_stash)\n> +\t\twt_longstatus_print_stash_summary(s);\n>  }\n\nThis feels like a funny place to look up the config. How would you\noverride it if were to have a \"--no-stash\" command line option?\n\nThe usual flow is for the caller to examine the config and set up fields\nin the wt_status object, which are then respected here in the low-level\ncode.\n\nSo I think you probably want to handle this in git_status_config() along\nwith other similar variables (like \"status.branch\").\n\nI don't personally insist on actually adding \"--no-stash\" or similar to\noverride it from the command line (there is always \"git -c\nstatus.showStash=false\" in a pinch). But I have seen other reviewers\n(including the maintainer) ask for that in the past, so you may want to\nanticipate it.\n\n-Peff\n"},{"id":"322453","messageId":"20170616121602.r3vjqmfcmqyvudsv@sigill.intra.peff.net","threadId":"46199","inReplyTo":"20170616043050.29192-4-liambeguin@gmail.com","subject":"Re: [PATCH 3/3] glossary: define stash entries","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-06-16T12:16:02Z","receivedAt":"2017-06-16T12:16:08Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Jun 16, 2017 at 12:30:50AM -0400, Liam Beguin wrote:\n\n> diff --git a/Documentation/glossary-content.txt b/Documentation/glossary-content.txt\n> index 6e991c246915..026f66e7240a 100644\n> --- a/Documentation/glossary-content.txt\n> +++ b/Documentation/glossary-content.txt\n> @@ -570,6 +570,10 @@ The most notable example is `HEAD`.\n>  \tis created by giving the `--depth` option to linkgit:git-clone[1], and\n>  \tits history can be later deepened with linkgit:git-fetch[1].\n>  \n> +[[def_stash]]stash entry::\n> +\tAn <<def_object,object>> used to temporarily store the content of a\n> +\t<<def_dirty,dirty>> working directory for futur reuse.\n\ns/futur/&e/\n\nI think we'd usually say \"contents\" (plural) of a working directory.\n\nIt also stores the contents of the index. git-stash(1) says \"current\nstate of the working directory and the index\".\n\n-Peff\n"},{"id":"322454","messageId":"20170616121642.jqsua5sw2u2iccdf@sigill.intra.peff.net","threadId":"46199","inReplyTo":"20170616043050.29192-1-liambeguin@gmail.com","subject":"Re: [PATCH 0/3] add stash count information to git-status command","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-06-16T12:16:43Z","receivedAt":"2017-06-16T12:16:49Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Jun 16, 2017 at 12:30:47AM -0400, Liam Beguin wrote:\n\n> As discussed here [*1*], this allows `git status` to show the number of\n> entries currently stashed away.\n> \n> I also tried to update the related parts of the documentation to use\n> 'stash entry' instead of 'stash' as we agreed that it was a bit better.\n> I don't mind dropping the documentation update and using something like\n> \"You have %d stash/stashes\" in the status message if it makes the change\n> \"too big\".\n\nI like the overall direction (including the documentation update). I\nnoted a few minor problems in the various patches, though.\n\n-Peff\n"},{"id":"322457","messageId":"55aed88d-f0ba-0d5a-9dcd-cda137a426b9@gmail.com","threadId":"46199","inReplyTo":"20170616121642.jqsua5sw2u2iccdf@sigill.intra.peff.net","subject":"Re: [PATCH 0/3] add stash count information to git-status command","fromName":"Liam Beguin","fromEmail":"liambeguin@gmail.com","sentAt":"2017-06-16T12:47:51Z","receivedAt":"2017-06-16T12:48:01Z","isPatch":true,"sender":{"key":"liambeguin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3811160?v=4"},"body":"Hi, \n\nOn 16/06/17 08:16 AM, Jeff King wrote:\n> On Fri, Jun 16, 2017 at 12:30:47AM -0400, Liam Beguin wrote:\n> \n>> As discussed here [*1*], this allows `git status` to show the number of\n>> entries currently stashed away.\n>>\n>> I also tried to update the related parts of the documentation to use\n>> 'stash entry' instead of 'stash' as we agreed that it was a bit better.\n>> I don't mind dropping the documentation update and using something like\n>> \"You have %d stash/stashes\" in the status message if it makes the change\n>> \"too big\".\n> \n> I like the overall direction (including the documentation update). I\n> noted a few minor problems in the various patches, though.\n\nThanks for reviewing! I'll try to send an update later today.\n\n> \n> -Peff\n> \n\n - Liam\n"},{"id":"322490","messageId":"xmqqmv97wrqc.fsf@gitster.mtv.corp.google.com","threadId":"46199","inReplyTo":"20170616043050.29192-2-liambeguin@gmail.com","subject":"Re: [PATCH 1/3] stash: update documentation to use 'stash entries'","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-16T21:24:43Z","receivedAt":"2017-06-16T21:24:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Liam Beguin <liambeguin@gmail.com> writes:\n\n> Most of the time, a 'stash entry' is called a 'stash'\n> or a 'stash state'. Lets use 'stash entry' instead.\n>\n> Signed-off-by: Liam Beguin <liambeguin@gmail.com>\n> ---\n> diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt\n> index 70191d06b69e..59979ad31dfe 100644\n> --- a/Documentation/git-stash.txt\n> +++ b/Documentation/git-stash.txt\n> @@ -51,18 +51,18 @@ OPTIONS\n>  save [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [<message>]::\n>  push [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [-m|--message <message>] [--] [<pathspec>...]::\n>  \n> -\tSave your local modifications to a new 'stash' and roll them\n> +\tSave your local modifications to a new 'stash entry' and roll them\n>  \tback to HEAD (in the working tree and in the index).\n>  \tThe <message> part is optional and gives\n>  \tthe description along with the stashed state.\n>  +\n>  For quickly making a snapshot, you can omit \"push\".  In this mode,\n>  non-option arguments are not allowed to prevent a misspelled\n> -subcommand from making an unwanted stash.  The two exceptions to this\n> +subcommand from making an unwanted entry.  The two exceptions to this\n\nIt is more clear to spell it out as 'unwanted stash entry' in the\ncontext of this sentence.\n\n>  list [<options>]::\n>  \n> -\tList the stashes that you currently have.  Each 'stash' is listed\n> -\twith its name (e.g. `stash@{0}` is the latest stash, `stash@{1}` is\n> +\tList the stash entries that you currently have.  Each 'stash entry' is\n> +\tlisted with its name (e.g. `stash@{0}` is the latest entry, `stash@{1}` is\n>  \tthe one before, etc.), the name of the branch that was current when the\n\nUnlike the previous one, 'the latest entry' here is clear enough\nthat it is talking about 'the latest stash entry' from the context,\nand I think this paragraph is good.\n\n> -\tstash was made, and a short description of the commit the stash was\n> +\tentry was made, and a short description of the commit the entry was\n\nSo is this one.\n\n> @@ -105,11 +105,11 @@ command to control what is shown and how. See linkgit:git-log[1].\n>  \n>  show [<stash>]::\n>  \n> -\tShow the changes recorded in the stash as a diff between the\n> -\tstashed state and its original parent. When no `<stash>` is given,\n> +\tShow the changes recorded in the stash entry as a diff between the\n\nThis is good, but...\n\n> +\tstashed entry and its original parent. When no `<stash>` is given, it\n\n... the original phrasing \"stashed state\" is better than this\nrewrite, because a \"stash entry\" is a vessel that holds a set of\n\"stashed states\" (the working tree state, the state of the index,\nand the contents of untracked files).\n\nI think what is shown is \"between the stashed contents of the\nworking tree and the commit back when the stash entry was created\".\n\n> @@ -149,26 +149,27 @@ branch <branchname> [<stash>]::\n>  +\n>  This is useful if the branch on which you ran `git stash save` has\n>  changed enough that `git stash apply` fails due to conflicts. Since\n> -the stash is applied on top of the commit that was HEAD at the time\n> -`git stash` was run, it restores the originally stashed state with\n> -no conflicts.\n> +the stash entry is applied on top of the commit that was HEAD at the\n> +time `git stash` was run, it restores the originally stashed entry\n> +with no conflicts.\n\nAgain, I do not think the last one should be made into \"stashed\nentry\".  We are restoring the stashed state, recorded in the named\n'stash entry'.\n\n>  clear::\n> -\tRemove all the stashed states. Note that those states will then\n> +\tRemove all the stashed entries. Note that those entries will then\n\nThis is removing 'all the stash entries'.\n\n>  drop [-q|--quiet] [<stash>]::\n>  \n> -\tRemove a single stashed state from the stash list. When no `<stash>`\n> +\tRemove a single stashed entry from the stash list. When no `<stash>`\n\nA single 'stash entry' is being removed from the list of stash entries.\n"},{"id":"322491","messageId":"xmqqinjvwrik.fsf@gitster.mtv.corp.google.com","threadId":"46199","inReplyTo":"20170616121423.smdtmcmbktuit2qb@sigill.intra.peff.net","subject":"Re: [PATCH 2/3] wt-status: add optional stash status information","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-16T21:29:23Z","receivedAt":"2017-06-16T21:29:39Z","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 Fri, Jun 16, 2017 at 12:30:49AM -0400, Liam Beguin wrote:\n>\n>> @@ -1642,6 +1664,8 @@ static void wt_longstatus_print(struct wt_status *s)\n>>  \t\t} else\n>>  \t\t\tprintf(_(\"nothing to commit, working tree clean\\n\"));\n>>  \t}\n>> +\tif (!git_config_get_bool(\"status.showStash\", &show_stash) && show_stash)\n>> +\t\twt_longstatus_print_stash_summary(s);\n>>  }\n>\n> This feels like a funny place to look up the config. How would you\n> override it if were to have a \"--no-stash\" command line option?\n\nGood suggestion.\n\nThis is a common mistake we saw in submissions by many new\ncontributors, and a good practice to avoid it is to start from a\ncommand line option without a configuration variable.  I.e. make\nsure that\n\n    $ git status --show-stash\n    $ git status --show-stash --no-show-stash\n\nwork well.  After that, add support for status.showStash and make\nthese also work well:\n\n    $ git -c status.showStash=false status --show-stash\n    $ git -c status.showStash=true status --no-show-stash\n\nThese two new ones need to result in command line options overriding\nthe configured default.\n\nAnd have these four getting tested in test scripts.\n"},{"id":"322509","messageId":"20170617223052.6580-4-liambeguin@gmail.com","threadId":"46199","inReplyTo":"20170617223052.6580-1-liambeguin@gmail.com","subject":"[PATCH v2 3/3] glossary: define 'stash entry'","fromName":"Liam Beguin","fromEmail":"liambeguin@gmail.com","sentAt":"2017-06-17T22:30:52Z","receivedAt":"2017-06-17T22:32:14Z","isPatch":true,"sender":{"key":"liambeguin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3811160?v=4"},"body":"Signed-off-by: Liam Beguin <liambeguin@gmail.com>\n---\n Documentation/glossary-content.txt | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/Documentation/glossary-content.txt b/Documentation/glossary-content.txt\nindex 6e991c246915..b71b943b12ed 100644\n--- a/Documentation/glossary-content.txt\n+++ b/Documentation/glossary-content.txt\n@@ -570,6 +570,10 @@ The most notable example is `HEAD`.\n \tis created by giving the `--depth` option to linkgit:git-clone[1], and\n \tits history can be later deepened with linkgit:git-fetch[1].\n \n+[[def_stash]]stash entry::\n+\tAn <<def_object,object>> used to temporarily store the contents of a\n+\t<<def_dirty,dirty>> working directory and the index for future reuse.\n+\n [[def_submodule]]submodule::\n \tA <<def_repository,repository>> that holds the history of a\n \tseparate project inside another repository (the latter of\n-- \n2.9.4\n\n"},{"id":"322510","messageId":"20170617223052.6580-2-liambeguin@gmail.com","threadId":"46199","inReplyTo":"20170617223052.6580-1-liambeguin@gmail.com","subject":"[PATCH v2 1/3] stash: update documentation to use 'stash entry'","fromName":"Liam Beguin","fromEmail":"liambeguin@gmail.com","sentAt":"2017-06-17T22:30:50Z","receivedAt":"2017-06-17T22:32:16Z","isPatch":true,"sender":{"key":"liambeguin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3811160?v=4"},"body":"Most of the time, a 'stash entry' is called a 'stash'. Lets try to make\nthis more consistent and use 'stash entry' instead.\n\nSigned-off-by: Liam Beguin <liambeguin@gmail.com>\n---\n Documentation/config.txt     |  6 ++---\n Documentation/git-pull.txt   |  2 +-\n Documentation/git-rebase.txt |  2 +-\n Documentation/git-stash.txt  | 60 +++++++++++++++++++++++---------------------\n Documentation/gitcli.txt     |  2 +-\n git-stash.sh                 |  6 ++---\n 6 files changed, 40 insertions(+), 38 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex f6278a5ae6a1..23b807065d92 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -2620,7 +2620,7 @@ rebase.autoSquash::\n \tIf set to true enable `--autosquash` option by default.\n \n rebase.autoStash::\n-\tWhen set to true, automatically create a temporary stash\n+\tWhen set to true, automatically create a temporary stash entry\n \tbefore the operation begins, and apply it after the operation\n \tends.  This means that you can run rebase on a dirty worktree.\n \tHowever, use with care: the final stash application after a\n@@ -3029,12 +3029,12 @@ status.submoduleSummary::\n \n stash.showPatch::\n \tIf this is set to true, the `git stash show` command without an\n-\toption will show the stash in patch form.  Defaults to false.\n+\toption will show the stash entry in patch form.  Defaults to false.\n \tSee description of 'show' command in linkgit:git-stash[1].\n \n stash.showStat::\n \tIf this is set to true, the `git stash show` command without an\n-\toption will show diffstat of the stash.  Defaults to true.\n+\toption will show diffstat of the stash entry.  Defaults to true.\n \tSee description of 'show' command in linkgit:git-stash[1].\n \n submodule.<name>.url::\ndiff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt\nindex e414185f5a6a..9db5e08f4a63 100644\n--- a/Documentation/git-pull.txt\n+++ b/Documentation/git-pull.txt\n@@ -131,7 +131,7 @@ unless you have read linkgit:git-rebase[1] carefully.\n --autostash::\n --no-autostash::\n \tBefore starting rebase, stash local modifications away (see\n-\tlinkgit:git-stash[1]) if needed, and apply the stash when\n+\tlinkgit:git-stash[1]) if needed, and apply the stash entry when\n \tdone. `--no-autostash` is useful to override the `rebase.autoStash`\n \tconfiguration variable (see linkgit:git-config[1]).\n +\ndiff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt\nindex 53f4e144444a..a5afd602d8eb 100644\n--- a/Documentation/git-rebase.txt\n+++ b/Documentation/git-rebase.txt\n@@ -446,7 +446,7 @@ used to override and disable this setting.\n \n --autostash::\n --no-autostash::\n-\tAutomatically create a temporary stash before the operation\n+\tAutomatically create a temporary stash entry before the operation\n \tbegins, and apply it after the operation ends.  This means\n \tthat you can run rebase on a dirty worktree.  However, use\n \twith care: the final stash application after a successful\ndiff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt\nindex 70191d06b69e..00f95fee1faf 100644\n--- a/Documentation/git-stash.txt\n+++ b/Documentation/git-stash.txt\n@@ -51,18 +51,18 @@ OPTIONS\n save [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [<message>]::\n push [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [-m|--message <message>] [--] [<pathspec>...]::\n \n-\tSave your local modifications to a new 'stash' and roll them\n+\tSave your local modifications to a new 'stash entry' and roll them\n \tback to HEAD (in the working tree and in the index).\n \tThe <message> part is optional and gives\n \tthe description along with the stashed state.\n +\n For quickly making a snapshot, you can omit \"push\".  In this mode,\n non-option arguments are not allowed to prevent a misspelled\n-subcommand from making an unwanted stash.  The two exceptions to this\n+subcommand from making an unwanted stash entry.  The two exceptions to this\n are `stash -p` which acts as alias for `stash push -p` and pathspecs,\n which are allowed after a double hyphen `--` for disambiguation.\n +\n-When pathspec is given to 'git stash push', the new stash records the\n+When pathspec is given to 'git stash push', the new stash entry records the\n modified states only for the files that match the pathspec.  The index\n entries and working tree files are then rolled back to the state in\n HEAD only for these files, too, leaving files that do not match the\n@@ -89,10 +89,10 @@ The `--patch` option implies `--keep-index`.  You can use\n \n list [<options>]::\n \n-\tList the stashes that you currently have.  Each 'stash' is listed\n-\twith its name (e.g. `stash@{0}` is the latest stash, `stash@{1}` is\n+\tList the stash entries that you currently have.  Each 'stash entry' is\n+\tlisted with its name (e.g. `stash@{0}` is the latest entry, `stash@{1}` is\n \tthe one before, etc.), the name of the branch that was current when the\n-\tstash was made, and a short description of the commit the stash was\n+\tentry was made, and a short description of the commit the entry was\n \tbased on.\n +\n ----------------------------------------------------------------\n@@ -105,11 +105,12 @@ command to control what is shown and how. See linkgit:git-log[1].\n \n show [<stash>]::\n \n-\tShow the changes recorded in the stash as a diff between the\n-\tstashed state and its original parent. When no `<stash>` is given,\n-\tshows the latest one. By default, the command shows the diffstat, but\n-\tit will accept any format known to 'git diff' (e.g., `git stash show\n-\t-p stash@{1}` to view the second most recent stash in patch form).\n+\tShow the changes recorded in the stash entry as a diff between the\n+\tstashed contents and the commit back when the stash entry was first\n+\tcreated. When no `<stash>` is given, it shows the latest one.\n+\tBy default, the command shows the diffstat, but it will accept any\n+\tformat known to 'git diff' (e.g., `git stash show -p stash@{1}`\n+\tto view the second most recent entry in patch form).\n \tYou can use stash.showStat and/or stash.showPatch config variables\n \tto change the default behavior.\n \n@@ -149,26 +150,27 @@ branch <branchname> [<stash>]::\n +\n This is useful if the branch on which you ran `git stash save` has\n changed enough that `git stash apply` fails due to conflicts. Since\n-the stash is applied on top of the commit that was HEAD at the time\n-`git stash` was run, it restores the originally stashed state with\n-no conflicts.\n+the stash entry is applied on top of the commit that was HEAD at the\n+time `git stash` was run, it restores the originally stashed state\n+with no conflicts.\n \n clear::\n-\tRemove all the stashed states. Note that those states will then\n+\tRemove all the stash entries. Note that those entries will then\n \tbe subject to pruning, and may be impossible to recover (see\n \t'Examples' below for a possible strategy).\n \n drop [-q|--quiet] [<stash>]::\n \n-\tRemove a single stashed state from the stash list. When no `<stash>`\n-\tis given, it removes the latest one. i.e. `stash@{0}`, otherwise\n-\t`<stash>` must be a valid stash log reference of the form\n-\t`stash@{<revision>}`.\n+\tRemove a single stash entry from the list of stash entries.\n+\tWhen no `<stash>` is given, it removes the latest one.\n+\ti.e. `stash@{0}`, otherwise `<stash>` must be a valid stash\n+\tlog reference of the form `stash@{<revision>}`.\n \n create::\n \n-\tCreate a stash (which is a regular commit object) and return its\n-\tobject name, without storing it anywhere in the ref namespace.\n+\tCreate a stash entry (which is a regular commit object) and\n+\treturn its object name, without storing it anywhere in the ref\n+\tnamespace.\n \tThis is intended to be useful for scripts.  It is probably not\n \tthe command you want to use; see \"save\" above.\n \n@@ -182,10 +184,10 @@ store::\n DISCUSSION\n ----------\n \n-A stash is represented as a commit whose tree records the state of the\n-working directory, and its first parent is the commit at `HEAD` when\n-the stash was created.  The tree of the second parent records the\n-state of the index when the stash is made, and it is made a child of\n+A stash entry is represented as a commit whose tree records the state\n+of the working directory, and its first parent is the commit at `HEAD`\n+when the entry was created.  The tree of the second parent records the\n+state of the index when the entry is made, and it is made a child of\n the `HEAD` commit.  The ancestry graph looks like this:\n \n             .----W\n@@ -269,12 +271,12 @@ $ edit/build/test remaining parts\n $ git commit foo -m 'Remaining parts'\n ----------------------------------------------------------------\n \n-Recovering stashes that were cleared/dropped erroneously::\n+Recovering stash entries that were cleared/dropped erroneously::\n \n-If you mistakenly drop or clear stashes, they cannot be recovered\n+If you mistakenly drop or clear stash entries, they cannot be recovered\n through the normal safety mechanisms.  However, you can try the\n-following incantation to get a list of stashes that are still in your\n-repository, but not reachable any more:\n+following incantation to get a list of stash entries that are still in\n+your repository, but not reachable any more:\n +\n ----------------------------------------------------------------\n git fsck --unreachable |\ndiff --git a/Documentation/gitcli.txt b/Documentation/gitcli.txt\nindex dfe7d8372723..9f13266a6851 100644\n--- a/Documentation/gitcli.txt\n+++ b/Documentation/gitcli.txt\n@@ -194,7 +194,7 @@ different things.\n  * The `--index` option is used to ask a command that\n    usually works on files in the working tree to *also*\n    affect the index.  For example, `git stash apply` usually\n-   merges changes recorded in a stash to the working tree,\n+   merges changes recorded in a stash entry to the working tree,\n    but with the `--index` option, it also merges changes to\n    the index as well.\n \ndiff --git a/git-stash.sh b/git-stash.sh\nindex 2fb651b2b8d9..68be4146bd2a 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -481,7 +481,7 @@ parse_flags_and_rev()\n \n \tcase $# in\n \t\t0)\n-\t\t\thave_stash || die \"$(gettext \"No stash found.\")\"\n+\t\t\thave_stash || die \"$(gettext \"No stash entries found.\")\"\n \t\t\tset -- ${ref_stash}@{0}\n \t\t;;\n \t\t1)\n@@ -573,7 +573,7 @@ apply_stash () {\n \t\tGIT_INDEX_FILE=\"$TMPindex\" git-read-tree \"$u_tree\" &&\n \t\tGIT_INDEX_FILE=\"$TMPindex\" git checkout-index --all &&\n \t\trm -f \"$TMPindex\" ||\n-\t\tdie \"$(gettext \"Could not restore untracked files from stash\")\"\n+\t\tdie \"$(gettext \"Could not restore untracked files from stash entry\")\"\n \tfi\n \n \teval \"\n@@ -627,7 +627,7 @@ pop_stash() {\n \t\tdrop_stash \"$@\"\n \telse\n \t\tstatus=$?\n-\t\tsay \"$(gettext \"The stash is kept in case you need it again.\")\"\n+\t\tsay \"$(gettext \"The stash entry is kept in case you need it again.\")\"\n \t\texit $status\n \tfi\n }\n-- \n2.9.4\n\n"},{"id":"322511","messageId":"20170617223052.6580-3-liambeguin@gmail.com","threadId":"46199","inReplyTo":"20170617223052.6580-1-liambeguin@gmail.com","subject":"[PATCH v2 2/3] status: add optional stash count information","fromName":"Liam Beguin","fromEmail":"liambeguin@gmail.com","sentAt":"2017-06-17T22:30:51Z","receivedAt":"2017-06-17T22:32:18Z","isPatch":true,"sender":{"key":"liambeguin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3811160?v=4"},"body":"Introduce '--show-stash' and its configuration option 'status.showStash'\nto allow git-status to show information about currently stashed entries.\n\nSigned-off-by: Liam Beguin <liambeguin@gmail.com>\n---\n Documentation/config.txt     |  5 +++++\n Documentation/git-status.txt |  3 +++\n builtin/commit.c             |  6 ++++++\n t/t7508-status.sh            | 32 ++++++++++++++++++++++++++++++++\n wt-status.c                  | 24 ++++++++++++++++++++++++\n wt-status.h                  |  1 +\n 6 files changed, 71 insertions(+)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 23b807065d92..e83b0f641574 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -2992,6 +2992,11 @@ status.displayCommentPrefix::\n \tbehavior of linkgit:git-status[1] in Git 1.8.4 and previous.\n \tDefaults to false.\n \n+status.showStash::\n+\tIf set to true, linkgit:git-status[1] will display the number of\n+\tentries currently stashed away.\n+\tDefaults to false.\n+\n status.showUntrackedFiles::\n \tBy default, linkgit:git-status[1] and linkgit:git-commit[1] show\n \tfiles which are not currently tracked by Git. Directories which\ndiff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\nindex d70abc6afe3a..d47f198f15cd 100644\n--- a/Documentation/git-status.txt\n+++ b/Documentation/git-status.txt\n@@ -32,6 +32,9 @@ OPTIONS\n --branch::\n \tShow the branch and tracking info even in short-format.\n \n+--show-stash::\n+\tShow the number of entries currently stashed away.\n+\n --porcelain[=<version>]::\n \tGive the output in an easy-to-parse format for scripts.\n \tThis is similar to the short output, but will remain stable\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex ef52457effc1..c089fb87e363 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1295,6 +1295,10 @@ static int git_status_config(const char *k, const char *v, void *cb)\n \t\tstatus_deferred_config.show_branch = git_config_bool(k, v);\n \t\treturn 0;\n \t}\n+\tif (!strcmp(k, \"status.showstash\")) {\n+\t\ts->show_stash = git_config_bool(k, v);\n+\t\treturn 0;\n+\t}\n \tif (!strcmp(k, \"status.color\") || !strcmp(k, \"color.status\")) {\n \t\ts->use_color = git_config_colorbool(k, v);\n \t\treturn 0;\n@@ -1343,6 +1347,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_BOOL('b', \"branch\", &s.show_branch,\n \t\t\t N_(\"show branch information\")),\n+\t\tOPT_BOOL(0, \"show-stash\", &s.show_stash,\n+\t\t\t N_(\"show stash information\")),\n \t\t{ OPTION_CALLBACK, 0, \"porcelain\", &status_format,\n \t\t  N_(\"version\"), N_(\"machine-readable output\"),\n \t\t  PARSE_OPT_OPTARG, opt_parse_porcelain },\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex 79427840a4fa..7121a550c7ce 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -1608,4 +1608,36 @@ test_expect_success 'git commit -m will commit a staged but ignored submodule' '\n \tgit config -f .gitmodules  --remove-section submodule.subname\n '\n \n+test_expect_success 'show stash info with \"--show-stash\"' '\n+\tgit reset --hard &&\n+\tgit stash clear &&\n+\techo 1 >file &&\n+\tgit add file &&\n+\tgit stash &&\n+\tgit status >expected_default &&\n+\tgit status --show-stash >expected_with_stash &&\n+\ttest_i18ngrep \"^Your stash currently has 1 entry$\" expected_with_stash\n+'\n+\n+test_expect_success 'no stash info with \"--show-stash --no-show-stash\"' '\n+\tgit status --show-stash --no-show-stash >expected_without_stash &&\n+\ttest_cmp expected_default expected_without_stash\n+'\n+\n+test_expect_success '\"status.showStash=false\" weaker than \"--show-stash\"' '\n+\tgit -c status.showStash=false status --show-stash >actual &&\n+\ttest_cmp expected_with_stash actual\n+'\n+\n+test_expect_success '\"status.showStash=true\" weaker than \"--no-show-stash\"' '\n+\tgit -c status.showStash=true status --no-show-stash >actual &&\n+\ttest_cmp expected_without_stash actual\n+'\n+\n+test_expect_success 'no additionnal info if no stash entries' '\n+\tgit stash clear &&\n+\tgit -c status.showStash=true status >actual &&\n+\ttest_cmp expected_without_stash actual\n+'\n+\n test_done\ndiff --git a/wt-status.c b/wt-status.c\nindex bf651f16fae8..7992a73902ae 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -137,6 +137,7 @@ void wt_status_prepare(struct wt_status *s)\n \ts->untracked.strdup_strings = 1;\n \ts->ignored.strdup_strings = 1;\n \ts->show_branch = -1;  /* unspecified */\n+\ts->show_stash = 0;\n \ts->display_comment_prefix = 0;\n }\n \n@@ -801,6 +802,27 @@ static void wt_longstatus_print_changed(struct wt_status *s)\n \twt_longstatus_print_trailer(s);\n }\n \n+static int stash_count_refs(struct object_id *ooid, struct object_id *noid,\n+\t\t\t    const char *email, timestamp_t timestamp, int tz,\n+\t\t\t    const char *message, void *cb_data)\n+{\n+\tint *c = cb_data;\n+\t(*c)++;\n+\treturn 0;\n+}\n+\n+static void wt_longstatus_print_stash_summary(struct wt_status *s)\n+{\n+\tint stash_count = 0;\n+\n+\tfor_each_reflog_ent(\"refs/stash\", stash_count_refs, &stash_count);\n+\tif (stash_count > 0)\n+\t\tstatus_printf_ln(s, GIT_COLOR_NORMAL,\n+\t\t\t\t Q_(\"Your stash currently has %d entry\",\n+\t\t\t\t    \"Your stash currently has %d entries\", stash_count),\n+\t\t\t\t stash_count);\n+}\n+\n static void wt_longstatus_print_submodule_summary(struct wt_status *s, int uncommitted)\n {\n \tstruct child_process sm_summary = CHILD_PROCESS_INIT;\n@@ -1642,6 +1664,8 @@ static void wt_longstatus_print(struct wt_status *s)\n \t\t} else\n \t\t\tprintf(_(\"nothing to commit, working tree clean\\n\"));\n \t}\n+\tif(s->show_stash)\n+\t\twt_longstatus_print_stash_summary(s);\n }\n \n static void wt_shortstatus_unmerged(struct string_list_item *it,\ndiff --git a/wt-status.h b/wt-status.h\nindex 8a3864783b03..d8ae2e590daf 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -77,6 +77,7 @@ struct wt_status {\n \tunsigned colopts;\n \tint null_termination;\n \tint show_branch;\n+\tint show_stash;\n \tint hints;\n \n \tenum wt_status_format status_format;\n-- \n2.9.4\n\n"},{"id":"322512","messageId":"20170617223052.6580-1-liambeguin@gmail.com","threadId":"46199","inReplyTo":"20170616043050.29192-1-liambeguin@gmail.com","subject":"[PATCH v2 0/3] add stash count information to git-status command","fromName":"Liam Beguin","fromEmail":"liambeguin@gmail.com","sentAt":"2017-06-17T22:30:49Z","receivedAt":"2017-06-17T22:32:24Z","isPatch":true,"sender":{"key":"liambeguin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3811160?v=4"},"body":"As discussed here [*1*], this allows `git status` to show the number of\nentries currently stashed away.\n\nI also tried to update the related parts of the documentation to use\n'stash entry' instead of 'stash' as we agreed that it was a bit better.\n\n*1* https://public-inbox.org/git/CA+B9myHRahTd+FDgzK5AhXW+hq_Y_czMX9X6MXYBcr9WSPeiDw@mail.gmail.com/\n\nLiam Beguin (3):\n  stash: update documentation to use 'stash entry'\n  status: add optional stash count information\n  glossary: define 'stash entry'\n\n Documentation/config.txt           | 11 +++++--\n Documentation/git-pull.txt         |  2 +-\n Documentation/git-rebase.txt       |  2 +-\n Documentation/git-stash.txt        | 60 ++++++++++++++++++++------------------\n Documentation/git-status.txt       |  3 ++\n Documentation/gitcli.txt           |  2 +-\n Documentation/glossary-content.txt |  4 +++\n builtin/commit.c                   |  6 ++++\n git-stash.sh                       |  6 ++--\n t/t7508-status.sh                  | 32 ++++++++++++++++++++\n wt-status.c                        | 24 +++++++++++++++\n wt-status.h                        |  1 +\n 12 files changed, 115 insertions(+), 38 deletions(-)\n\n\nBase-commit: 97e2ff464302565877a00b8a9aa6a2d85bd1445e\n\nChanges since v1:\n - update commit messages to be more consistent\n - improve Documentation based on feedback\n - move config lookup to `git_status_config()`\n - add '--show-stash' command line option to `git-status`\n - add tests for now option\n\nInterdiff:\ndiff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt\nindex 59979ad31dfe..00f95fee1faf 100644\n--- a/Documentation/git-stash.txt\n+++ b/Documentation/git-stash.txt\n@@ -58,7 +58,7 @@ push [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q\n +\n For quickly making a snapshot, you can omit \"push\".  In this mode,\n non-option arguments are not allowed to prevent a misspelled\n-subcommand from making an unwanted entry.  The two exceptions to this\n+subcommand from making an unwanted stash entry.  The two exceptions to this\n are `stash -p` which acts as alias for `stash push -p` and pathspecs,\n which are allowed after a double hyphen `--` for disambiguation.\n +\n@@ -106,10 +106,11 @@ command to control what is shown and how. See linkgit:git-log[1].\n show [<stash>]::\n \n \tShow the changes recorded in the stash entry as a diff between the\n-\tstashed entry and its original parent. When no `<stash>` is given, it\n-\tshows the latest one. By default, the command shows the diffstat, but\n-\tit will accept any format known to 'git diff' (e.g., `git stash show\n-\t-p stash@{1}` to view the second most recent entry in patch form).\n+\tstashed contents and the commit back when the stash entry was first\n+\tcreated. When no `<stash>` is given, it shows the latest one.\n+\tBy default, the command shows the diffstat, but it will accept any\n+\tformat known to 'git diff' (e.g., `git stash show -p stash@{1}`\n+\tto view the second most recent entry in patch form).\n \tYou can use stash.showStat and/or stash.showPatch config variables\n \tto change the default behavior.\n \n@@ -150,20 +151,20 @@ branch <branchname> [<stash>]::\n This is useful if the branch on which you ran `git stash save` has\n changed enough that `git stash apply` fails due to conflicts. Since\n the stash entry is applied on top of the commit that was HEAD at the\n-time `git stash` was run, it restores the originally stashed entry\n+time `git stash` was run, it restores the originally stashed state\n with no conflicts.\n \n clear::\n-\tRemove all the stashed entries. Note that those entries will then\n+\tRemove all the stash entries. Note that those entries will then\n \tbe subject to pruning, and may be impossible to recover (see\n \t'Examples' below for a possible strategy).\n \n drop [-q|--quiet] [<stash>]::\n \n-\tRemove a single stashed entry from the stash list. When no `<stash>`\n-\tis given, it removes the latest one. i.e. `stash@{0}`, otherwise\n-\t`<stash>` must be a valid stash log reference of the form\n-\t`stash@{<revision>}`.\n+\tRemove a single stash entry from the list of stash entries.\n+\tWhen no `<stash>` is given, it removes the latest one.\n+\ti.e. `stash@{0}`, otherwise `<stash>` must be a valid stash\n+\tlog reference of the form `stash@{<revision>}`.\n \n create::\n \ndiff --git a/Documentation/git-status.txt b/Documentation/git-status.txt\nindex d70abc6afe3a..d47f198f15cd 100644\n--- a/Documentation/git-status.txt\n+++ b/Documentation/git-status.txt\n@@ -32,6 +32,9 @@ OPTIONS\n --branch::\n \tShow the branch and tracking info even in short-format.\n \n+--show-stash::\n+\tShow the number of entries currently stashed away.\n+\n --porcelain[=<version>]::\n \tGive the output in an easy-to-parse format for scripts.\n \tThis is similar to the short output, but will remain stable\ndiff --git a/Documentation/glossary-content.txt b/Documentation/glossary-content.txt\nindex 026f66e7240a..b71b943b12ed 100644\n--- a/Documentation/glossary-content.txt\n+++ b/Documentation/glossary-content.txt\n@@ -571,8 +571,8 @@ The most notable example is `HEAD`.\n \tits history can be later deepened with linkgit:git-fetch[1].\n \n [[def_stash]]stash entry::\n-\tAn <<def_object,object>> used to temporarily store the content of a\n-\t<<def_dirty,dirty>> working directory for futur reuse.\n+\tAn <<def_object,object>> used to temporarily store the contents of a\n+\t<<def_dirty,dirty>> working directory and the index for future reuse.\n \n [[def_submodule]]submodule::\n \tA <<def_repository,repository>> that holds the history of a\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex ef52457effc1..c089fb87e363 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1295,6 +1295,10 @@ static int git_status_config(const char *k, const char *v, void *cb)\n \t\tstatus_deferred_config.show_branch = git_config_bool(k, v);\n \t\treturn 0;\n \t}\n+\tif (!strcmp(k, \"status.showstash\")) {\n+\t\ts->show_stash = git_config_bool(k, v);\n+\t\treturn 0;\n+\t}\n \tif (!strcmp(k, \"status.color\") || !strcmp(k, \"color.status\")) {\n \t\ts->use_color = git_config_colorbool(k, v);\n \t\treturn 0;\n@@ -1343,6 +1347,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_BOOL('b', \"branch\", &s.show_branch,\n \t\t\t N_(\"show branch information\")),\n+\t\tOPT_BOOL(0, \"show-stash\", &s.show_stash,\n+\t\t\t N_(\"show stash information\")),\n \t\t{ OPTION_CALLBACK, 0, \"porcelain\", &status_format,\n \t\t  N_(\"version\"), N_(\"machine-readable output\"),\n \t\t  PARSE_OPT_OPTARG, opt_parse_porcelain },\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 0dfa4785f361..68be4146bd2a 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -481,7 +481,7 @@ parse_flags_and_rev()\n \n \tcase $# in\n \t\t0)\n-\t\t\thave_stash || die \"$(gettext \"No stash entry found.\")\"\n+\t\t\thave_stash || die \"$(gettext \"No stash entries found.\")\"\n \t\t\tset -- ${ref_stash}@{0}\n \t\t;;\n \t\t1)\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex 79427840a4fa..7121a550c7ce 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -1608,4 +1608,36 @@ test_expect_success 'git commit -m will commit a staged but ignored submodule' '\n \tgit config -f .gitmodules  --remove-section submodule.subname\n '\n \n+test_expect_success 'show stash info with \"--show-stash\"' '\n+\tgit reset --hard &&\n+\tgit stash clear &&\n+\techo 1 >file &&\n+\tgit add file &&\n+\tgit stash &&\n+\tgit status >expected_default &&\n+\tgit status --show-stash >expected_with_stash &&\n+\ttest_i18ngrep \"^Your stash currently has 1 entry$\" expected_with_stash\n+'\n+\n+test_expect_success 'no stash info with \"--show-stash --no-show-stash\"' '\n+\tgit status --show-stash --no-show-stash >expected_without_stash &&\n+\ttest_cmp expected_default expected_without_stash\n+'\n+\n+test_expect_success '\"status.showStash=false\" weaker than \"--show-stash\"' '\n+\tgit -c status.showStash=false status --show-stash >actual &&\n+\ttest_cmp expected_with_stash actual\n+'\n+\n+test_expect_success '\"status.showStash=true\" weaker than \"--no-show-stash\"' '\n+\tgit -c status.showStash=true status --no-show-stash >actual &&\n+\ttest_cmp expected_without_stash actual\n+'\n+\n+test_expect_success 'no additionnal info if no stash entries' '\n+\tgit stash clear &&\n+\tgit -c status.showStash=true status >actual &&\n+\ttest_cmp expected_without_stash actual\n+'\n+\n test_done\ndiff --git a/wt-status.c b/wt-status.c\nindex 7114eec123c8..7992a73902ae 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -137,6 +137,7 @@ void wt_status_prepare(struct wt_status *s)\n \ts->untracked.strdup_strings = 1;\n \ts->ignored.strdup_strings = 1;\n \ts->show_branch = -1;  /* unspecified */\n+\ts->show_stash = 0;\n \ts->display_comment_prefix = 0;\n }\n \n@@ -1558,7 +1559,6 @@ static void wt_longstatus_print(struct wt_status *s)\n \tconst char *branch_color = color(WT_STATUS_ONBRANCH, s);\n \tconst char *branch_status_color = color(WT_STATUS_HEADER, s);\n \tstruct wt_status_state state;\n-\tint show_stash = 0;\n \n \tmemset(&state, 0, sizeof(state));\n \twt_status_get_state(&state,\n@@ -1664,7 +1664,7 @@ static void wt_longstatus_print(struct wt_status *s)\n \t\t} else\n \t\t\tprintf(_(\"nothing to commit, working tree clean\\n\"));\n \t}\n-\tif (!git_config_get_bool(\"status.showStash\", &show_stash) && show_stash)\n+\tif(s->show_stash)\n \t\twt_longstatus_print_stash_summary(s);\n }\n \ndiff --git a/wt-status.h b/wt-status.h\nindex 8a3864783b03..d8ae2e590daf 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -77,6 +77,7 @@ struct wt_status {\n \tunsigned colopts;\n \tint null_termination;\n \tint show_branch;\n+\tint show_stash;\n \tint hints;\n \n \tenum wt_status_format status_format;\n-- \n2.9.4\n\n"},{"id":"322547","messageId":"xmqq60fsv9lo.fsf@gitster.mtv.corp.google.com","threadId":"46199","inReplyTo":"20170617223052.6580-1-liambeguin@gmail.com","subject":"Re: [PATCH v2 0/3] add stash count information to git-status command","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-19T05:18:27Z","receivedAt":"2017-06-19T05:18:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks; queued.\n"}]}