git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 4/8] doc: stash: split options from description (2)

From
AGAlexandr Miloslavskiy via GitGitGadget <gitgitgadget@gmail.com>
Date
Feb 10, 2020, 14:45 UTC
Message-ID
<db3a96720ce94cc93c8bcefe08d3340ae4e08cae.1581345948.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.530.v2.git.1581345948.gitgitgadget@gmail.com>
From: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>

Together with the previous patch, this brings docs for `git stash` to the common layout used for most other commands (see for example docs for `git add`, `git commit`, `git checkout`, `git reset`) where all options are documented in a separate list.

After some thinking and having a look at docs for `git svn` and
`git `submodule`, I have arrived at following conclusions:
  * Options should be described in a list rather then text to
    facilitate lookup for user.
  * Single list is better then multiple lists because it avoids
    copy&pasting descriptions between subcommands (or, without
    copy&pasting, user will have to look up missing options in other
    subcommands).
  * As a consequence, commands section should only give brief info and
    list possible options. Since options have good enough names, user
	will only need to look up the "interesting" options.
  * Every option should list which subcommands support it.

I have decided to use alphabetical sorting in the list of options to facilitate lookup for user.

There is some text editing done to make old descriptions better fit into the list-style format.

Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
---
 Documentation/git-stash.txt | 92 +++++++++++++++++++++++--------------
 1 file changed, 57 insertions(+), 35 deletions(-)
diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt
index 2dedc21997..c1c16623cb 100644
--- a/Documentation/git-stash.txt
+++ b/Documentation/git-stash.txt
@@ -43,8 +43,8 @@ created stash, `stash@{1}` is the one before it, `stash@{2.hours.ago}`
 is also possible). Stashes may also be referenced by specifying just the
 stash index (e.g. the integer `n` is equivalent to `stash@{n}`).
 
-OPTIONS
--------
+COMMANDS
+--------
 
 push [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [-m|--message <message>] [--] [<pathspec>...]::
 
@@ -86,7 +86,7 @@ show [<options>] [<stash>]::
 
 	Show the changes recorded in the stash entry as a diff between the
 	stashed contents and the commit back when the stash entry was first
-	created. When no `<stash>` is given, it shows the latest one.
+	created.
 	By default, the command shows the diffstat, but it will accept any
 	format known to 'git diff' (e.g., `git stash show -p stash@{1}`
 	to view the second most recent entry in patch form).
@@ -116,8 +116,7 @@ branch <branchname> [<stash>]::
 	the commit at which the `<stash>` was originally created, applies the
 	changes recorded in `<stash>` to the new working tree and index.
 	If that succeeds, and `<stash>` is a reference of the form
-	`stash@{<revision>}`, it then drops the `<stash>`. When no `<stash>`
-	is given, applies the latest one.
+	`stash@{<revision>}`, it then drops the `<stash>`.
 +
 This is useful if the branch on which you ran `git stash push` has
 changed enough that `git stash apply` fails due to conflicts. Since
@@ -133,9 +132,6 @@ clear::
 drop [-q|--quiet] [<stash>]::
 
 	Remove a single stash entry from the list of stash entries.
-	When no `<stash>` is given, it removes the latest one.
-	i.e. `stash@{0}`, otherwise `<stash>` must be a valid stash
-	log reference of the form `stash@{<revision>}`.
 
 create::
 
@@ -152,40 +148,66 @@ store::
 	reflog.  This is intended to be useful for scripts.  It is
 	probably not the command you want to use; see "push" above.
 
-If the `--all` option is used instead then the
-ignored files are stashed and cleaned in addition to the untracked files.
-
-If the `--include-untracked` option is used, all untracked files are also
-stashed and then cleaned up with `git clean`, leaving the working directory
-in a very clean state.
+OPTIONS
+-------
+-a::
+--all::
+	This option is only valid for `push` and `save` commands.
++
+All ignored and untracked files are also stashed and then cleaned
+up with `git clean`.
 
-If the `--index` option is used, then tries to reinstate not only the working
-tree's changes, but also the index's ones. However, this can fail, when you
-have conflicts (which are stored in the index, where you therefore can no
-longer apply the changes as they were originally).
+-u::
+--include-untracked::
+	This option is only valid for `push` and `save` commands.
++
+All untracked files are also stashed and then cleaned up with
+`git clean`.
 
-If the `--keep-index` option is used, all changes already added to the
-index are left intact.
+--index::
+	This option is only valid for `pop` and `apply` commands.
++
+Tries to reinstate not only the working tree's changes, but also
+the index's ones. However, this can fail, when you have conflicts
+(which are stored in the index, where you therefore can no longer
+apply the changes as they were originally).
+
+-k::
+--keep-index::
+--no-keep-index::
+	This option is only valid for `push` and `save` commands.
++
+All changes already added to the index are left intact.
 
-With `--patch`, you can interactively select hunks from the diff
-between HEAD and the working tree to be stashed.  The stash entry is
-constructed such that its index state is the same as the index state
-of your repository, and its worktree contains only the changes you
-selected interactively.  The selected changes are then rolled back
-from your worktree. See the ``Interactive Mode'' section of
-linkgit:git-add[1] to learn how to operate the `--patch` mode.
+-p::
+--patch::
+	This option is only valid for `push` and `save` commands.
++
+Interactively select hunks from the diff between HEAD and the
+working tree to be stashed.  The stash entry is constructed such
+that its index state is the same as the index state of your
+repository, and its worktree contains only the changes you selected
+interactively.  The selected changes are then rolled back from your
+worktree. See the ``Interactive Mode'' section of linkgit:git-add[1]
+to learn how to operate the `--patch` mode.
 +
 The `--patch` option implies `--keep-index`.  You can use 
 `--no-keep-index` to override this.
 
-When pathspec is given to 'git stash push', the new stash entry records the
-modified states only for the files that match the pathspec.  The index
-entries and working tree files are then rolled back to the state in
-HEAD only for these files, too, leaving files that do not match the
-pathspec intact.
-
-When no `<stash>` is given, `stash@{0}` is assumed, otherwise `<stash>` must
-be a reference of the form `stash@{<revision>}`.
+<pathspec>...::
+	This option is only valid for `push` command.
++
+The new stash entry records the modified states only for the files
+that match the pathspec.  The index entries and working tree files
+are then rolled back to the state in HEAD only for these files,
+too, leaving files that do not match the pathspec intact.
+
+<stash>::
+	This option is only valid for `apply`, `branch`, `drop`, `pop`,
+	`show` commands.
++
+A reference of the form `stash@{<revision>}`. When no `<stash>` is
+given, the latest stash is assumed (that is, `stash@{0}`).
 
 DISCUSSION
 ----------
-- 
gitgitgadget
Previous: Junio C HamanoNext: Alexandr Miloslavskiy via GitGitGadget
Message 28 of 41 in “Support --pathspec-from-file in rm, stash”
  1. 0/8 Support --pathspec-from-file in rm, stashAlexandr Miloslavskiy via GitGitGadget, Jan 16, 2020
  2. 1/8 doc: rm: synchronize <pathspec> descriptionAlexandr Miloslavskiy via GitGitGadget, Jan 16, 2020
  3. Junio C HamanoJan 21, 2020
  4. 2/8 rm: support the --pathspec-from-file optionAlexandr Miloslavskiy via GitGitGadget, Jan 16, 2020
  5. Junio C HamanoJan 21, 2020
  6. Alexandr MiloslavskiyFeb 10, 2020
  7. Junio C HamanoFeb 10, 2020
  8. Alexandr MiloslavskiyFeb 17, 2020
  9. 4/8 doc: stash: split options from description (2)Alexandr Miloslavskiy via GitGitGadget, Jan 16, 2020
  10. Junio C HamanoJan 21, 2020
  11. Alexandr MiloslavskiyFeb 10, 2020
  12. 5/8 doc: stash: document more optionsAlexandr Miloslavskiy via GitGitGadget, Jan 16, 2020
  13. Junio C HamanoJan 21, 2020
  14. 6/8 doc: stash: synchronize <pathspec> descriptionAlexandr Miloslavskiy via GitGitGadget, Jan 16, 2020
  15. Junio C HamanoJan 21, 2020
  16. 7/8 stash: eliminate crude option parsingAlexandr Miloslavskiy via GitGitGadget, Jan 16, 2020
  17. 8/8 stash push: support the --pathspec-from-file optionAlexandr Miloslavskiy via GitGitGadget, Jan 16, 2020
  18. 3/8 doc: stash: split options from description (1)Alexandr Miloslavskiy via GitGitGadget, Jan 16, 2020
  19. 0/8 Support --pathspec-from-file in rm, stashAlexandr Miloslavskiy via GitGitGadget, Feb 10, 2020
  20. 5/8 doc: stash: document more optionsAlexandr Miloslavskiy via GitGitGadget, Feb 10, 2020
  21. 3/8 doc: stash: split options from description (1)Alexandr Miloslavskiy via GitGitGadget, Feb 10, 2020
  22. 1/8 doc: rm: synchronize <pathspec> descriptionAlexandr Miloslavskiy via GitGitGadget, Feb 10, 2020
  23. 2/8 rm: support the --pathspec-from-file optionAlexandr Miloslavskiy via GitGitGadget, Feb 10, 2020
  24. Junio C HamanoFeb 10, 2020
  25. Alexandr MiloslavskiyFeb 17, 2020
  26. Junio C HamanoFeb 17, 2020
  27. Junio C HamanoFeb 17, 2020
  28. 4/8 doc: stash: split options from description (2)Alexandr Miloslavskiy via GitGitGadget, Feb 10, 2020
  29. 6/8 doc: stash: synchronize <pathspec> descriptionAlexandr Miloslavskiy via GitGitGadget, Feb 10, 2020
  30. 8/8 stash push: support the --pathspec-from-file optionAlexandr Miloslavskiy via GitGitGadget, Feb 10, 2020
  31. 7/8 stash: eliminate crude option parsingAlexandr Miloslavskiy via GitGitGadget, Feb 10, 2020
  32. 0/8 Support --pathspec-from-file in rm, stashAlexandr Miloslavskiy via GitGitGadget, Feb 17, 2020
  33. 1/8 doc: rm: synchronize <pathspec> descriptionAlexandr Miloslavskiy via GitGitGadget, Feb 17, 2020
  34. 2/8 rm: support the --pathspec-from-file optionAlexandr Miloslavskiy via GitGitGadget, Feb 17, 2020
  35. Alexandr MiloslavskiyFeb 17, 2020
  36. 3/8 doc: stash: split options from description (1)Alexandr Miloslavskiy via GitGitGadget, Feb 17, 2020
  37. 5/8 doc: stash: document more optionsAlexandr Miloslavskiy via GitGitGadget, Feb 17, 2020
  38. 8/8 stash push: support the --pathspec-from-file optionAlexandr Miloslavskiy via GitGitGadget, Feb 17, 2020
  39. 4/8 doc: stash: split options from description (2)Alexandr Miloslavskiy via GitGitGadget, Feb 17, 2020
  40. 7/8 stash: eliminate crude option parsingAlexandr Miloslavskiy via GitGitGadget, Feb 17, 2020
  41. 6/8 doc: stash: synchronize <pathspec> descriptionAlexandr Miloslavskiy via GitGitGadget, Feb 17, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.