summaryrefslogtreecommitdiff
path: root/git-stash.sh
AgeCommit message (Collapse)Author
2009-09-07Merge branch 'tr/reset-checkout-patch'Junio C Hamano
* tr/reset-checkout-patch: stash: simplify defaulting to "save" and reject unknown options Make test case number unique tests: disable interactive hunk selection tests if perl is not available DWIM 'git stash save -p' for 'git stash -p' Implement 'git stash save --patch' Implement 'git checkout --patch' Implement 'git reset --patch' builtin-add: refactor the meat of interactive_add() Add a small patch-mode testing library git-apply--interactive: Refactor patch mode code Make 'git stash -k' a short form for 'git stash save --keep-index'
2009-09-02stash: simplify defaulting to "save" and reject unknown optionsMatthieu Moy
With the earlier DWIM patches, certain combination of options defaulted to the "save" command correctly while certain equally valid combination did not. For example, "git stash -k" were Ok but "git stash -q -k" did not work. This makes the logic of defaulting to "save" much simpler. If there are no non-flag arguments, it is clear that there is no command word, and we default to "save" subcommand. This rule prevents "git stash -q apply" from quietly creating a stash with "apply" as the message. This also teaches "git stash save" to reject an unknown option. This is to keep a mistyped "git stash save --quite" from creating a stash with a message "--quite", and this safety is more important with the new logic to default to "save" with any option-looking argument without an explicit comand word. [jc: this is based on Matthieu's 3-patch series, and a follow-up discussion, and he and Peff take all the credit; if I have introduced bugs while reworking, they are mine.] Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-15DWIM 'git stash save -p' for 'git stash -p'Thomas Rast
Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-15Merge branch 'js/stash-dwim' into tr/reset-checkout-patchJunio C Hamano
* commit 'tr/reset-checkout-patch^^2': Make 'git stash -k' a short form for 'git stash save --keep-index'
2009-08-15Implement 'git stash save --patch'Thomas Rast
This adds a hunk-based mode to git-stash. You can select hunks from the difference between HEAD and worktree, and git-stash will build a stash that reflects these changes. The index state of the stash is the same as your current index, and we also let --patch imply --keep-index. Note that because the selected hunks are rolled back from the worktree but not the index, the resulting state may appear somewhat confusing if you had also staged these changes. This is not entirely satisfactory, but due to the way stashes are applied, other solutions would require a change to the stash format. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-15git stash: Give friendlier errors when there is nothing to applyOri Avtalion
The change makes sure a stash (given or default) exists before checking if the working tree is dirty. If the default stash is requested, the old message was scary and included a 'fatal' error from rev-parse: fatal: Needed a single revision : no valid stashed state found It is replaced with a friendlier 'Nothing to apply' error, similar to 'git stash branch'. If a specific stash is specified, the 'Needed a single revision' errors from rev-parse are suppressed. Signed-off-by: Ori Avtalion <ori@avtalion.name> Acked-by: Thomas Rast <trast@student.ethz.ch> Acked-by: Nanako Shiraishi <nanako3@lavabit.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-07-31Make 'git stash -k' a short form for 'git stash save --keep-index'Johannes Schindelin
To save me from the carpal tunnel syndrome, make 'git stash' accept the short option '-k' instead of '--keep-index', and for even more convenience, let's DWIM when this developer forgot to type the 'save' command. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-07-23git stash: modernize use of "dashed" git-XXX callsMartin Koegler
Replace remaining git-XXX calls with git XXX. Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at> Acked-by: Nanako Shiraishi <nanako3@lavabit.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-18stash: teach quiet optionStephen Boyd
Teach stash pop, apply, save, and drop to be quiet when told. By using the quiet option (-q), these actions will be silent unless errors are encountered. Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-09Documentation: mention 'git stash pop --index' option explicitlySZEDER Gábor
'git stash pop' supports the '--index' option since its initial implementation (bd56ff54, git-stash: add new 'pop' subcommand, 2008-02-22), but its documentation does not mention it explicitly. Moreover, both the usage shown by 'git stash -h' and the synopsis section in the man page imply that 'git stash pop' does not have an '--index' option. First, this patch corrects the usage and the synopsis section. Second, the patch moves the description of the '--index' option to the 'git stash pop' section in the documentation, and refers to it from the 'git stash apply' section. This way it follows the intentions of commit d1836637 (Documentation: teach stash/pop workflow instead of stash/apply, 2009-05-28), as all 'git stash pop'-related documentation will be in one place without references to 'git stash apply'. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-12-08Revert "git-stash: use git rev-parse -q"Junio C Hamano
This reverts commit 757c7f60a78004fc3d0ea62f44320d54ef430c10 as an unnecessary error message to pop up when the last stash entry is dropped. It simply is not worth the aggravation.
2008-12-03git-stash: use git rev-parse -qMiklos Vajna
Don't redirect stderr to /dev/null, use -q to suppress the output on stderr. Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-10-09git-stash.sh: fix flawed fix of invalid ref handling (commit da65e7c1)Brandon Casey
The referenced commit tried to fix a flaw in stash's handling of a user supplied invalid ref. i.e. 'git stash apply fake_ref@{0}' should fail instead of applying stash@{0}. But, it did so in a naive way by avoiding the use of the --default option of rev-parse, and instead manually supplied the default revision if the user supplied an empty command line. This prevented a common usage scenario of supplying flags on the stash command line (i.e. non-empty command line) which would be parsed by lower level git commands, without supplying a specific revision. This should fall back to the default revision, but now it causes an error. e.g. 'git stash show -p' The correct fix is to use the --verify option of rev-parse, which fails properly if an invalid ref is supplied, and still allows falling back to a default ref when one is not supplied. Convert stash-drop to use --verify while we're at it, since specifying multiple revisions for any of these commands is also an error and --verify makes it so. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-29Clarify how the user can satisfy stash's 'dirty state' check.Stephen Haberman
Signed-off-by: Stephen Haberman <stephen@exigencecorp.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-24git-stash.sh: don't default to refs/stash if invalid ref suppliedBrandon Casey
apply_stash() and show_stash() each call rev-parse with '--default refs/stash' as an argument. This option causes rev-parse to operate on refs/stash if it is not able to successfully operate on any element of the command line. This includes failure to supply a "valid" revision. This has the effect of causing 'stash apply' and 'stash show' to operate as if stash@{0} had been supplied when an invalid revision is supplied. e.g. 'git stash apply stash@{1}' would fall back to 'git stash apply stash@{0}' This patch modifies these two functions so that they avoid using the --default option of rev-parse. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-06stash: refresh the index before deciding if the work tree is dirtyJunio C Hamano
Unlike the case where the user does have a real change in the work tree, refusing to work because of unclean stat information is not very helpful. Signed-off-by: Junio C Hamano <gitster@pobox.com> Acked-by: Nanako Shiraishi <nanako3@lavabit.com>
2008-08-16git-stash: improve synopsis in help and manual pageStephan Beyer
"git stash -h" showed some incomplete and ugly usage information. For example, the useful "--keep-index" option for "save" or the "--index" option for "apply" were not shown. Also in the documentation synopsis they were not shown, so that there is no incentive to scroll down and even see that such options exist. This patch improves the git-stash synopsis in the documentation by mentioning that further options to the stash commands and then copies this synopsis to the usage information string of git-stash.sh. For the latter, the dashless git command string has to be inserted on the second and the following usage lines. The code of this is taken from git-sh-setup so that all lines will show the command string. Note that the "create" command is not advertised at all now, because it was not mentioned in git-stash.txt. Signed-off-by: Stephan Beyer <s-beyer@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-06bash completion: More completions for 'git stash'Lee Marlow
Add branch subcommand to completions and USAGE for git-stash.sh. Complete stash names for show, apply, drop, pop, and branch. Add "--index" long option for apply. Signed-off-by: Lee Marlow <lee.marlow@gmail.com> Acked-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-23stash save: fix parameter handlingJunio C Hamano
A command line "git stash save --keep-index I was doing this" was misparsed and keep-index codepath did not trigger. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-13Merge branch 'am/stash-branch'Junio C Hamano
* am/stash-branch: Add a test for "git stash branch" Implement "git stash branch <newbranch> <stash>"
2008-07-05stash: introduce 'stash save --keep-index' optionSZEDER Gábor
'git stash save' saves local modifications to a new stash, and runs 'git reset --hard' to revert them to a clean index and work tree. When the '--keep-index' option is specified, after that 'git reset --hard' the previous contents of the index is restored and the work tree is updated to match the index. This option is useful if the user wants to commit only parts of his local modifications, but wants to test those parts before committing. Also add support for the completion of the new option, and add an example use case to the documentation. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-05Implement "git stash branch <newbranch> <stash>"Abhijit Menon-Sen
Restores the stashed state on a new branch rooted at the commit on which the stash was originally created, so that conflicts caused by subsequent changes on the original branch can be dealt with. (Thanks to Junio for this nice idea.) Signed-off-by: Abhijit Menon-Sen <ams@toroid.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-15Ignore dirty submodule states during rebase and stashJohannes Schindelin
When rebasing or stashing, chances are that you do not care about dirty submodules, since they are not updated by those actions anyway. So ignore the submodules' states. Note: the submodule states -- as committed in the superproject -- will still be stashed and rebased, it is _just_ the state of the submodule in the working tree which is ignored. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-23git-stash: add new 'pop' subcommandBrandon Casey
This combines the existing stash subcommands 'apply' and 'drop' to allow a single stash entry to be applied and then dropped, in other words 'popped', from the stash list. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-23git-stash: add new 'drop' subcommandBrandon Casey
This allows a single stash entry to be deleted. It takes an optional argument which is a stash reflog entry. If no arguments are supplied, it drops the most recent stash entry. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-07git-stash clear: refuse to work with extra parameter for nowJunio C Hamano
Because it is so tempting to expect "git stash clear stash@{4}" to remove the fourth element in the stash while leaving other elements intact, we should not blindly throw away everything upon seeing such a command. This may change when we start using "git reflog delete" to selectively nuke a single (or multiple, for that matter) stash entries with such a command line. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-05git-stash: use stdout instead of stderr for non error messagesMarco Costalba
Some scripts and libraries check stderr to detect a failing command, instead of checking the exit code. Because the output from git-status is not primarily for machine consumption, it would not hurt to send these messages to stdout instead and it will make it easier to drive the command for such callers. Signed-off-by: Marco Costalba <mcostalba@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-22Emit helpful status for accidental "git stash" saveWincent Colaiuta
If the user types "git stash" mistakenly thinking that this will list their stashes he/she may be surprised to see that it actually saved a new stash and reset their working tree and index. In the worst case they might not know how to recover the state. So help them by telling them exactly what was saved and also how to restore it immediately. Signed-off-by: Wincent Colaiuta <win@wincent.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-03git-stash: Display help message if git-stash is run with wrong sub-commandsKevin Leung
The current git-stash behaviour is very error prone to typos. For example, if you typed "git-stash llist", git-stash would think that you wanted to save to a stash named "llist", but in fact, you meant "git-stash list". Signed-off-by: Kevin Leung <kevinlsk@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-29Merge branch 'maint'Junio C Hamano
* maint: scripts: do not get confused with HEAD in work tree Improve description of git-branch -d and -D in man page.
2007-11-29scripts: do not get confused with HEAD in work treeJunio C Hamano
When you have a file called HEAD in your work tree, many commands that our scripts feed "HEAD" to would complain about the rev vs path ambiguity. A solution is to form command line more carefully by appending -- to them, which makes it clear that we mean HEAD rev not HEAD file. This patch would apply to maint. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-28git-stash: do not get fooled with "color.diff = true"Pascal Obry
When colors are set to "true" on the repository, the git log output will contain control characters to set/reset the colors, even when the output is to a pipe. This makes list_stash() fail as the downstream sed does not see what it is expecting. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-18Merge branch 'ph/parseopt-sh'Junio C Hamano
* ph/parseopt-sh: git-quiltimport.sh fix --patches handling git-am: -i does not take a string parameter. sh-setup: don't let eval output to be shell-expanded. git-sh-setup: fix parseopt `eval` string underquoting Give git-am back the ability to add Signed-off-by lines. git-rev-parse --parseopt scripts: Add placeholders for OPTIONS_SPEC Migrate git-repack.sh to use git-rev-parse --parseopt Migrate git-quiltimport.sh to use git-rev-parse --parseopt Migrate git-checkout.sh to use git-rev-parse --parseopt --keep-dashdash Migrate git-instaweb.sh to use git-rev-parse --parseopt Migrate git-merge.sh to use git-rev-parse --parseopt Migrate git-am.sh to use git-rev-parse --parseopt Migrate git-clone to use git-rev-parse --parseopt Migrate git-clean.sh to use git-rev-parse --parseopt. Update git-sh-setup(1) to allow transparent use of git-rev-parse --parseopt Add a parseopt mode to git-rev-parse to bring parse-options to shell scripts.
2007-11-14Merge branch 'jc/stash-create'Junio C Hamano
* jc/stash-create: git-stash: Fix listing stashes git-merge: no reason to use cpio anymore Revert "rebase: allow starting from a dirty tree." rebase: allow starting from a dirty tree. stash: implement "stash create"
2007-11-07git-stash: Fix listing stashesEmil Medve
Commit bc9e7399af3790918140c30a5b2c85bf9a8f1ad3 "reverted" commit f12e925ac23ad6169e046cfe05b8438a1611ad58 Signed-off-by: Emil Medve <Emilian.Medve@Freescale.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-06scripts: Add placeholders for OPTIONS_SPECJunio C Hamano
--text follows this line-- These commands currently lack OPTIONS_SPEC; allow people to easily list with "git grep 'OPTIONS_SPEC=$'" what they can help improving. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-10-19Paper bag fix diff invocation in 'git stash show'Shawn O. Pearce
In 89d750bf6fa025edeb31ad258cdd09a27a5c02fa I got a little too aggressive with changing "git diff" to "git diff-tree". This is shown to the user, who expects to see a full diff on their console, and will want to see the output of their custom diff drivers (if any) as the whole point of this call site is to show the diff to the end-user. Noticed by Johannes Sixt <j.sixt@viscovery.net>. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-19Avoid invoking diff drivers during git-stashShawn O. Pearce
git-stash needs to restrict itself to plumbing when running automated diffs as part of its operation as the user may have configured a custom diff driver that opens an interactive UI for certain/all files. Doing that during scripted actions is very unfriendly to the end-user and may cause git-stash to fail to work. Reported by Johannes Sixt Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-15stash: implement "stash create"Junio C Hamano
This subcommand creates a stash from the current state and writes out the resulting commit object ID to the standard output, without updating the stash ref nor resetting the tree. It is intended to be used by scripts to temporarily rewind the working tree to a clean state. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-09-12stash: end index commit log with a newlineJean-Luc Herren
There was no newline at the end of the index commit message, putting the shell prompt at its end after a 'git cat-file commit $id'. This is similar to what was fixed in 843103d69388a5c74ed99753e1c162a66835b04d. Signed-off-by: Jean-Luc Herren <jlh@gmx.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-07-28git-stash apply --index: optimize postprocessingJunio C Hamano
Originally, "apply --index" codepath was bolted on to the "update working tree files and index, but then revert the changes we make to the index except for added files so that we do not forget about them" codepath, almost as an afterthought. Because "apply --index" first prepares the final index state upfront, "revert except the added paths" postprocessing does not have to be done. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-07-28Fix git-stash apply --indexJunio C Hamano
Two bugs that made the command practically unusable were fixed with this. - A stash created with a clean index does not have any difference between the base tree and the index tree. Trying to apply the diff between them to the index would error out with "No changes". Even when the user asked to unstash with --index, do not bother with --index action if the base tree and the index tree match. - After successfully performing the working tree merge, the index was reloaded from an earlier state of unstashed index with "read-tree"; this left all the paths cache dirty. By moving the call to git-status after this read-tree, match the cached stat information in the index. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-07-28git-stash: Make sure reflog is created for refs/stashしらいしななこ
Earlier commit 7ab3cc70 fixed "stash clear" but broke save_stash, because it forgot to make sure the reflog file exists before saving. Signed-off-by: Nanako Shiraishi <nanako3@bluebottle.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-07-27git-stash: do not remove a ref by hand.Junio C Hamano
Somebody on #git noticed that "git stash clear" left a packed ref behind for ref/stash. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-07-25Make sure git-stash works from subdirectory.Junio C Hamano
We say "SUBDIRECTORY_OK" but we did not chdir to toplevel; this is fine as long as everything we use can be started from a subdirectory, but unfortunately "merge-recursive" is not one of the programs you can safely use from a subdirectory. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-07-09git-stash: try reusing cached stat info as much as possibleJunio C Hamano
Earlier when we read a tree into a temporary index, we read it from scratch. Start from the current index and use read-tree -m to preserve cached stat information as much as possible, in order to speed up "git add -u". This makes "git stash" usable in a source tree of nontrivial size. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-07-07Merge branch 'js/stash'Junio C Hamano
* js/stash: Teach git-stash to "apply --index"
2007-07-07stash: allow running from a subdirectoryJames Bowes
Signed-off-by: James Bowes <jbowes@dangerouslyinc.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-07-06Teach git-stash to "apply --index"Johannes Schindelin
When given this subcommand, git-stash will try to merge the stashed index into the current one. Only trivial merges are possible, since we have no index for the index ;-) If a trivial merge is not possible, git-stash will bail out with a hint to skip the --index option. For good measure, finally include a test case. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-07-06git-stash: allow more descriptive reminder message when savingJunio C Hamano
This allows you to say: $ git stash starting to implement X while creating a stash, and the resulting "stash list entry would read as: $ git stash list stash@{0}: On master: starting to implement X instead of the default message which talks about the commit the stash happens to be based on (hence does not have much to do with what the stashed change is trying to do). Signed-off-by: Junio C Hamano <gitster@pobox.com>