From db37745eef62c57e1609cbd50c6dbf9a8066f191 Mon Sep 17 00:00:00 2001 From: Thomas Gummerer Date: Sun, 22 Oct 2017 18:04:07 +0100 Subject: [PATCH 1/3] stash: replace "git stash save" with "git stash push" in the documentation "git stash push" is the newer interface for creating a stash. While we are still keeping "git stash save" around for the time being, it's better to point new users of "git stash" to the more modern (and more feature rich) interface, instead of teaching them the older version that we might want to phase out in the future. Signed-off-by: Thomas Gummerer Signed-off-by: Junio C Hamano --- Documentation/git-stash.txt | 12 ++++++------ Documentation/gitworkflows.txt | 2 +- Documentation/user-manual.txt | 2 +- git-stash.sh | 10 +++++----- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt index 00f95fee1f..53b2e60aeb 100644 --- a/Documentation/git-stash.txt +++ b/Documentation/git-stash.txt @@ -33,7 +33,7 @@ and reverts the working directory to match the `HEAD` commit. The modifications stashed away by this command can be listed with `git stash list`, inspected with `git stash show`, and restored (potentially on top of a different commit) with `git stash apply`. -Calling `git stash` without any arguments is equivalent to `git stash save`. +Calling `git stash` without any arguments is equivalent to `git stash push`. A stash is by default listed as "WIP on 'branchname' ...", but you can give a more descriptive message on the command line when you create one. @@ -118,7 +118,7 @@ pop [--index] [-q|--quiet] []:: Remove a single stashed state from the stash list and apply it on top of the current working tree state, i.e., do the inverse - operation of `git stash save`. The working directory must + operation of `git stash push`. The working directory must match the index. + Applying the state can fail with conflicts; in this case, it is not @@ -137,7 +137,7 @@ apply [--index] [-q|--quiet] []:: Like `pop`, but do not remove the state from the stash list. Unlike `pop`, `` may be any commit that looks like a commit created by - `stash save` or `stash create`. + `stash push` or `stash create`. branch []:: @@ -148,7 +148,7 @@ branch []:: `stash@{}`, it then drops the ``. When no `` is given, applies the latest one. + -This is useful if the branch on which you ran `git stash save` has +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 the stash entry is applied on top of the commit that was HEAD at the time `git stash` was run, it restores the originally stashed state @@ -255,14 +255,14 @@ $ git stash pop Testing partial commits:: -You can use `git stash save --keep-index` when you want to make two or +You can use `git stash push --keep-index` when you want to make two or more commits out of the changes in the work tree, and you want to test each change before committing: + ---------------------------------------------------------------- # ... hack hack hack ... $ git add --patch foo # add just first part to the index -$ git stash save --keep-index # save all other changes to the stash +$ git stash push --keep-index # save all other changes to the stash $ edit/build/test first part $ git commit -m 'First part' # commit fully tested change $ git stash pop # prepare to work on all other changes diff --git a/Documentation/gitworkflows.txt b/Documentation/gitworkflows.txt index 177610e44e..02569d0614 100644 --- a/Documentation/gitworkflows.txt +++ b/Documentation/gitworkflows.txt @@ -40,7 +40,7 @@ beginning. It is always easier to squash a few commits together than to split one big commit into several. Don't be afraid of making too small or imperfect steps along the way. You can always go back later and edit the commits with `git rebase --interactive` before you -publish them. You can use `git stash save --keep-index` to run the +publish them. You can use `git stash push --keep-index` to run the test suite independent of other uncommitted changes; see the EXAMPLES section of linkgit:git-stash[1]. diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt index b4d88af133..3a03e63eb0 100644 --- a/Documentation/user-manual.txt +++ b/Documentation/user-manual.txt @@ -1556,7 +1556,7 @@ so on a different branch and then coming back), unstash the work-in-progress changes. ------------------------------------------------ -$ git stash save "work in progress for foo feature" +$ git stash push -m "work in progress for foo feature" ------------------------------------------------ This command will save your changes away to the `stash`, and diff --git a/git-stash.sh b/git-stash.sh index 8b2ce9afda..3a4e5d157c 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -267,11 +267,11 @@ push_stash () { # translation of "error: " takes in your language. E.g. in # English this is: # - # $ git stash save --blah-blah 2>&1 | head -n 2 - # error: unknown option for 'stash save': --blah-blah - # To provide a message, use git stash save -- '--blah-blah' - eval_gettextln "error: unknown option for 'stash save': \$option - To provide a message, use git stash save -- '\$option'" + # $ git stash push --blah-blah 2>&1 | head -n 2 + # error: unknown option for 'stash push': --blah-blah + # To provide a message, use git stash push -m '--blah-blah' + eval_gettextln "error: unknown option for 'stash push': \$option + To provide a message, use git stash push -m '\$option'" usage ;; *) From fd2ebf14db52cc41e1cd39b1532d03cb1a702d47 Mon Sep 17 00:00:00 2001 From: Thomas Gummerer Date: Sun, 22 Oct 2017 18:04:08 +0100 Subject: [PATCH 2/3] stash: mark "git stash save" deprecated in the man page 'git stash push' fixes a historical wart in the interface of 'git stash save'. As 'git stash push' has all functionality of 'git stash save', with a nicer, more consistent user interface deprecate 'git stash save'. To do this, remove it from the synopsis of the man page, and move it to a separate section, stating that it is deprecated. Helped-by: Robert P. J. Day Helped-by: Jeff King Signed-off-by: Thomas Gummerer Signed-off-by: Junio C Hamano --- Documentation/git-stash.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt index 53b2e60aeb..8be661007d 100644 --- a/Documentation/git-stash.txt +++ b/Documentation/git-stash.txt @@ -13,8 +13,6 @@ SYNOPSIS 'git stash' drop [-q|--quiet] [] 'git stash' ( pop | apply ) [--index] [-q|--quiet] [] 'git stash' branch [] -'git stash' save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet] - [-u|--include-untracked] [-a|--all] [] 'git stash' [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet] [-u|--include-untracked] [-a|--all] [-m|--message ]] [--] [...]] @@ -48,7 +46,6 @@ stash index (e.g. the integer `n` is equivalent to `stash@{n}`). OPTIONS ------- -save [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] []:: push [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [-m|--message ] [--] [...]:: Save your local modifications to a new 'stash entry' and roll them @@ -87,6 +84,12 @@ 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. +save [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] []:: + + This option is deprecated in favour of 'git stash push'. It + differs from "stash push" in that it cannot take pathspecs, + and any non-option arguments form the message. + list []:: List the stash entries that you currently have. Each 'stash entry' is From c0c0c825ce19963ded30919778a23c3c85662755 Mon Sep 17 00:00:00 2001 From: Thomas Gummerer Date: Sun, 22 Oct 2017 18:04:09 +0100 Subject: [PATCH 3/3] stash: remove now superfluos help for "stash push" With the 'git stash save' interface, it was easily possible for users to try to add a message which would start with "-", which 'git stash save' would interpret as a command line argument, and fail. For this case we added some extra help on how to create a stash with a message starting with "-". For 'stash push', messages are passed with the -m flag, avoiding this potential pitfall. Now only pathspecs starting with "-" would have to be distinguished from command line parameters by using "-- --". This is fairly common in the git command line interface, and we don't try to guess what the users wanted in the other cases. Because this way of passing pathspecs is quite common in other git commands, and we don't provide any extra help there, do the same in the error message for 'git stash push'. Signed-off-by: Thomas Gummerer Signed-off-by: Junio C Hamano --- git-stash.sh | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/git-stash.sh b/git-stash.sh index 3a4e5d157c..4b74951440 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -260,18 +260,7 @@ push_stash () { ;; -*) option="$1" - # TRANSLATORS: $option is an invalid option, like - # `--blah-blah'. The 7 spaces at the beginning of the - # second line correspond to "error: ". So you should line - # up the second line with however many characters the - # translation of "error: " takes in your language. E.g. in - # English this is: - # - # $ git stash push --blah-blah 2>&1 | head -n 2 - # error: unknown option for 'stash push': --blah-blah - # To provide a message, use git stash push -m '--blah-blah' - eval_gettextln "error: unknown option for 'stash push': \$option - To provide a message, use git stash push -m '\$option'" + eval_gettextln "error: unknown option for 'stash push': \$option" usage ;; *)