summaryrefslogtreecommitdiff
path: root/git-stash.sh
Commit message (Collapse)AuthorAgeFilesLines
* Revert "stash: require a clean index to apply"jk/stash-require-clean-indexJeff King2015-06-151-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit ed178ef13a26136d86ff4e33bb7b1afb5033f908. That commit was an attempt to improve the safety of applying a stash, because the application process may create conflicted index entries, after which it is hard to restore the original index state. Unfortunately, this hurts some common workflows around "git stash -k", like: git add -p ;# (1) stage set of proposed changes git stash -k ;# (2) get rid of everything else make test ;# (3) make sure proposal is reasonable git stash apply ;# (4) restore original working tree If you "git commit" between steps (3) and (4), then this just works. However, if these steps are part of a pre-commit hook, you don't have that opportunity (you have to restore the original state regardless of whether the tests passed or failed). It's possible that we could provide better tools for this sort of workflow. In particular, even before ed178ef, it could fail with a conflict if there were conflicting hunks in the working tree and index (since the "stash -k" puts the index version into the working tree, and we then attempt to apply the differences between HEAD and the old working tree on top of that). But the fact remains that people have been using it happily for a while, and the safety provided by ed178ef is simply not that great. Let's revert it for now. In the long run, people can work on improving stash for this sort of workflow, but the safety tradeoff is not worth it in the meantime. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* stash: require a clean index to applyJeff King2015-04-221-0/+2
| | | | | | | | | | | | | | | | | | | | | | If you have staged contents in your index and run "stash apply", we may hit a conflict and put new entries into the index. Recovering to your original state is difficult at that point, because tools like "git reset --keep" will blow away anything staged. We can make this safer by refusing to apply when there are staged changes. It's possible we could provide better tooling here, as "git stash apply" should be writing only conflicts to the index (so we know that any stage-0 entries are potentially precious). But it is the odd duck; most "mergy" commands will update the index for cleanly merged entries, and it is not worth updating our tooling to support this use case which is unlikely to be of interest (besides which, we would still need to block a dirty index for "stash apply --index", since that case _would_ be ambiguous). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'da/rev-parse-verify-quiet'Junio C Hamano2014-09-291-6/+7
|\ | | | | | | | | | | | | | | | | | | | | | | "rev-parse --verify --quiet $name" is meant to quietly exit with a non-zero status when $name is not a valid object name, but still gave error messages in some cases. * da/rev-parse-verify-quiet: stash: prefer --quiet over shell redirection of the standard error stream refs: make rev-parse --quiet actually quiet t1503: use test_must_be_empty Documentation: a note about stdout for git rev-parse --verify --quiet
| * stash: prefer --quiet over shell redirection of the standard error streamda/rev-parse-verify-quietDavid Aguilar2014-09-191-6/+7
| | | | | | | | | | | | | | | | Use `git rev-parse --verify --quiet` instead of redirecting stderr to /dev/null. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'ah/grammofix'Junio C Hamano2014-09-191-1/+1
|\ \ | |/ |/| | | | | * ah/grammofix: grammofix in user-facing messages
| * grammofix in user-facing messagesah/grammofixAlex Henrie2014-09-021-1/+1
| | | | | | | | | | | | Signed-off-by: Alex Henrie <alexhenrie24@gmail.com> Acked-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'jk/stash-list-p'Junio C Hamano2014-09-091-1/+1
|\ \ | |/ |/| | | | | | | | | | | | | Teach "git stash list -p" to show the difference between the base commit version and the working tree version, which is in line with what "git show" gives. * jk/stash-list-p: stash: default listing to working-tree diff
| * stash: default listing to working-tree diffjk/stash-list-pJeff King2014-08-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When you list stashes, you can provide arbitrary git-log options to change the display. However, adding just "-p" does nothing, because each stash is actually a merge commit. This implementation detail is easy to forget, leading to confused users who think "-p" is not working. We can make this easier by defaulting to "--first-parent -m", which will show the diff against the working tree. This omits the index portion of the stash entirely, but it's simple and it matches what "git stash show" provides. People who are more clueful about stash's true form can use "--cc" to override the "-m", and the "--first-parent" will then do nothing. For diffs, it only affects non-combined diffs, so "--cc" overrides it. And for the traversal, we are walking the linear reflog anyway, so we do not even care about the parents. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * Merge branch 'jc/stash-pop-not-popped' into maintJunio C Hamano2014-04-031-2/+8
| |\ | | | | | | | | | | | | * jc/stash-pop-not-popped: stash pop: mention we did not drop the stash upon failing to apply
* | \ Merge branch 'ep/shell-assign-and-export-vars'Junio C Hamano2014-06-061-1/+2
|\ \ \ | | | | | | | | | | | | | | | | | | | | * ep/shell-assign-and-export-vars: scripts: more "export VAR=VALUE" fixes scripts: "export VAR=VALUE" construct is not portable
| * | | scripts: "export VAR=VALUE" construct is not portableElia Pinto2014-05-231-1/+2
| |/ / | | | | | | | | | | | | | | | | | | | | | Found by check-non-portable-shell.pl Signed-off-by: Elia Pinto <gitter.spiros@gmail.com> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | git-stash.sh: use the $( ... ) construct for command substitutionElia Pinto2014-04-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Git CodingGuidelines prefer the $(...) construct for command substitution instead of using the backquotes `...`. The backquoted form is the traditional method for command substitution, and is supported by POSIX. However, all but the simplest uses become complicated quickly. In particular, embedded command substitutions and/or the use of double quotes require careful escaping with the backslash character. The patch was generated by: for _f in $(find . -name "*.sh") do sed -i 's@`\(.*\)`@$(\1)@g' ${_f} done and then carefully proof-read. Signed-off-by: Elia Pinto <gitter.spiros@gmail.com> Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Merge branch 'jc/stash-pop-not-popped'Junio C Hamano2014-03-211-2/+8
|\ \ \ | |/ / |/| / | |/ | | | | | | | | | | | | | | "stash pop", upon failing to apply the stash, refrains from discarding the stash to avoid information loss. Be more explicit in the error message. The wording may want to get a bit more bikeshedding. * jc/stash-pop-not-popped: stash pop: mention we did not drop the stash upon failing to apply
| * stash pop: mention we did not drop the stash upon failing to applyjc/stash-pop-not-poppedJunio C Hamano2014-02-261-2/+8
| | | | | | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | stash: handle specifying stashes with $IFSow/stash-with-ifsØystein Walle2014-01-071-7/+7
|/ | | | | | | | | | | | | | | | | | When trying to pop/apply a stash specified with an argument containing IFS whitespace, git-stash will throw an error: $ git stash pop 'stash@{two hours ago}' Too many revisions specified: stash@{two hours ago} This happens because word splitting is used to count non-option arguments. Make use of rev-parse's --sq option to quote the arguments for us to ensure a correct count. Add quotes where necessary. Also add a test that verifies correct behaviour. Helped-by: Thomas Rast <tr@thomasrast.ch> Signed-off-by: Øystein Walle <oystwa@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Revert "git stash: avoid data loss when "git stash save" kills a directory"Junio C Hamano2013-08-141-12/+0
| | | | | | | | | | This reverts commit a73653130edd6a8977106d45a8092c09040f9132, as it has been reported that "ls-files --killed" is too time-consuming in a deep directory with too many untracked crufts (e.g. $HOME/.git tracking only a few files). We'd need to revisit it later but "ls-files --killed" needs to be optimized before it happens.
* git stash: avoid data loss when "git stash save" kills a directoryPetr Baudis2013-07-011-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | "stash save" is about saving the local change to the working tree, but also about restoring the state of the last commit to the working tree. When a local change is to turn a non-directory to a directory, in order to restore the non-directory, everything in the directory needs to be removed. Which is fine when running "git stash save --include-untracked", but without that option, untracked, newly created files in the directory will have to be discarded, if the state you are restoring to has a non-directory at the same path as the directory. Introduce a safety valve to fail the operation in such case, using the "ls-files --killed" which was designed for this exact purpose. The "stash save" is stopped when untracked files need to be discarded because their leading path ceased to be a directory, and the user is required to pass --force to really have the data removed. Signed-off-by: Petr Baudis <pasky@ucw.cz> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* stash: introduce 'git stash store'Ramkumar Ramachandra2013-06-171-6/+41
| | | | | | | | | | | | | | | | | save_stash() contains the logic for doing two potentially independent operations; the first is preparing the stash merge commit, and the second is updating the stash ref/ reflog accordingly. While the first operation is abstracted out into a create_stash() for callers to access via 'git stash create', the second one is not. Fix this by factoring out the logic for storing the stash into a store_stash() that callers can access via 'git stash store'. Like create, store is not intended for end user interactive use, but for callers in other scripts. We can simplify the logic in the rebase.autostash feature using this new subcommand. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* stash: simplify option parser for createRamkumar Ramachandra2013-06-171-4/+1
| | | | | | | | The option parser for create unnecessarily checks "$1" inside a case statement that matches "$1" in the first place. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'ph/stash-rerere'Junio C Hamano2012-09-031-0/+1
|\ | | | | | | | | | | | | | | | | "git stash" internally used "git merge-recursive" backend, which did not trigger "rerere" upon conflicts unlike other mergy operations. * ph/stash-rerere: stash: invoke rerere in case of conflict test: git-stash conflict sets up rerere
| * stash: invoke rerere in case of conflictPhil Hord2012-08-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | "stash apply" directly calls a backend merge function which does not automatically invoke rerere. This confuses mergetool when leftover rerere state is left behind from previous merges. Invoke rerere explicitly when we encounter a conflict during stash apply. This turns the test introduced by the previous commit to succeed. Signed-off-by: Phil Hord <hordp@cisco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | stash: use eval_gettextln correctlyRoss Lagerwall2012-04-141-2/+2
|/ | | | | | | | | | | Otherwise, passing an invalid option, git stash -v, gave: git-stash: line 204: $'error: unknown option for \'stash save\': $option\n To provide a message, use git stash save -- \'$option\'': command not found Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* stash: Don't fail if work dir contains file named 'HEAD'jm/stash-diff-disambiguateJonathon Mah2012-01-011-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | When performing a plain "git stash" (without --patch), git-diff would fail with "fatal: ambiguous argument 'HEAD': both revision and filename". The output was piped into git-update-index, masking the failed exit status. The output is now sent to a temporary file (which is cleaned up by existing code), and the exit status is checked. The "HEAD" arg to the git-diff invocation has been disambiguated too, of course. In patch mode, "git stash -p" would fail harmlessly, leaving the working dir untouched. Interactive adding is fine, but the resulting tree was diffed with an ambiguous 'HEAD' argument. Use >foo (no space) when redirecting output. In t3904, checks and operations on each file are in the order they'll appear when interactively staging. In t3905, fix a bug in "stash save --include-untracked -q is quiet": The redirected stdout file was considered untracked, and so was removed from the working directory. Use test path helper functions where appropriate. Signed-off-by: Jonathon Mah <me@JonathonMah.com> Acked-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'bc/unstash-clean-crufts'Junio C Hamano2011-10-051-2/+2
|\ | | | | | | | | | | | | | | * bc/unstash-clean-crufts: git-stash: remove untracked/ignored directories when stashed t/t3905: add missing '&&' linkage git-stash.sh: fix typo in error message t/t3905: use the name 'actual' for test output, swap arguments to test_cmp
| * git-stash: remove untracked/ignored directories when stashedbc/unstash-clean-cruftsBrandon Casey2011-08-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The two new stash options --include-untracked and --all do not remove the untracked and/or ignored files that are stashed if those files reside in a subdirectory. e.g. the following sequence fails: mkdir untracked && echo hello >untracked/file.txt && git stash --include-untracked && test ! -f untracked/file.txt Within the git-stash script, git-clean is used to remove the untracked/ignored files, but since the -d option was not supplied, it does not remove directories. So, add -d to the git-clean arguments, and update the tests to test this functionality. Reported-by: Hilco Wijbenga <hilco.wijbenga@gmail.com> Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * git-stash.sh: fix typo in error messageBrandon Casey2011-08-271-1/+1
| | | | | | | | | | Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | stash: take advantage of eval_gettextlnJon Seymour2011-08-081-6/+3
| | | | | | | | | | Signed-off-by: Jon Seymour <jon.seymour@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'dc/stash-con-untracked'Junio C Hamano2011-07-221-5/+65
|\ \ | |/ | | | | | | | | | | | | * dc/stash-con-untracked: stash: Add --include-untracked option to stash and remove all untracked files Conflicts: git-stash.sh
| * stash: Add --include-untracked option to stash and remove all untracked filesDavid Caldwell2011-06-261-4/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The --include-untracked option acts like the normal "git stash save" but also adds all untracked files in the working directory to the stash and then calls "git clean --force --quiet" to restore the working directory to a pristine state. This is useful for projects that need to run release scripts. With this option, the release scripts can be from the main working directory so one does not have to maintain a "clean" directory in parallel just for releasing. Basically the work-flow becomes: $ git tag release-1.0 $ git stash --include-untracked $ make release $ git clean -f $ git stash pop "git stash" alone is not enough in this case--it leaves untracked files lying around that might mess up a release process that expects everything to be very clean or might let a release succeed that should actually fail (due to a new source file being created that hasn't been committed yet). Signed-off-by: David Caldwell <david@porkrind.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * Merge branch 'jk/maint-stash-oob' into maintJunio C Hamano2011-05-041-11/+1
| |\ | | | | | | | | | | | | | | | | | | | | | | | | * jk/maint-stash-oob: stash: fix false positive in the invalid ref test. stash: fix accidental apply of non-existent stashes Conflicts: t/t3903-stash.sh
| * \ Merge branch 'dm/stash-k-i-p' into maintJunio C Hamano2011-05-041-4/+5
| |\ \ | | | | | | | | | | | | | | | | | | | | * dm/stash-k-i-p: stash: ensure --no-keep-index and --patch can be used in any order stash: add two more tests for --no-keep-index
* | | | i18n: git-stash drop_stash say/die messagesÆvar Arnfjörð Bjarmason2011-05-211-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Gettextize the say/die eval_gettext messages in the drop_stash function. Since making these translatable would result in a long line I've wrapped this into two lines. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | i18n: git-stash "unknown option" messageÆvar Arnfjörð Bjarmason2011-05-211-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Gettextize the "unknown option for 'stash save'" message that's shown on: $ git stash save --blah-blah error: unknown option for 'stash save': --blah-blah To provide a message, use git stash save -- '--blah-blah' Usage: git stash list [<options>] In a translation the second line should be aligned with the first one. I've added a TRANSLATORS comment to indicate this. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | i18n: git-stash die + eval_gettext $1 messagesÆvar Arnfjörð Bjarmason2011-05-211-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Gettextize a messages that used the $1 variable. Since it's subroutine local we have to provide an alias for it for eval_gettext. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | i18n: git-stash die + eval_gettext $* messagesÆvar Arnfjörð Bjarmason2011-05-211-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Gettextize messages that used the $* variable. Since it's subroutine local we have to provide an alias for it for eval_gettext. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | i18n: git-stash die + eval_gettext messagesÆvar Arnfjörð Bjarmason2011-05-211-1/+1
| | | | | | | | | | | | | | | | | | | | Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | i18n: git-stash die + gettext messagesÆvar Arnfjörð Bjarmason2011-05-211-18/+18
| | | | | | | | | | | | | | | | | | | | Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | i18n: git-stash say + gettext messagesÆvar Arnfjörð Bjarmason2011-05-211-2/+2
| | | | | | | | | | | | | | | | | | | | Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | i18n: git-stash echo + gettext messageÆvar Arnfjörð Bjarmason2011-05-211-1/+4
| | | | | | | | | | | | | | | | | | | | Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | i18n: git-stash add git-sh-i18nÆvar Arnfjörð Bjarmason2011-05-211-0/+1
| | | | | | | | | | | | | | | | | | | | Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | Merge branch 'dm/stash-k-i-p'Junio C Hamano2011-04-271-4/+5
|\ \ \ \ | | |/ / | |/| | | | | | | | | | | | | | * dm/stash-k-i-p: stash: ensure --no-keep-index and --patch can be used in any order stash: add two more tests for --no-keep-index
| * | | stash: ensure --no-keep-index and --patch can be used in any orderDan McGee2011-04-071-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't assume one comes after the other on the command line. Use a three-state variable to track and check its value accordingly. Signed-off-by: Dan McGee <dpmcgee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | Merge branch 'jk/maint-stash-oob'Junio C Hamano2011-04-271-11/+1
|\ \ \ \ | |_|/ / |/| | / | | |/ | |/| | | | | | | | | | | | | * jk/maint-stash-oob: stash: fix false positive in the invalid ref test. stash: fix accidental apply of non-existent stashes Conflicts: t/t3903-stash.sh
| * | stash: fix accidental apply of non-existent stashesJeff King2011-04-051-11/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Once upon a time, "git rev-parse ref@{9999999}" did not generate an error. Therefore when we got an invalid stash reference in "stash apply", we could end up not noticing until quite late. Commit b0f0ecd (detached-stash: work around git rev-parse failure to detect bad log refs, 2010-08-21) handled this by checking for the "Log for stash has only %d entries" warning on stderr when we validated the ref. A few days later, e6eedc3 (rev-parse: exit with non-zero status if ref@{n} is not valid., 2010-08-24) fixed the original issue. That made the extra stderr test superfluous, but also introduced a new bug. Now the early call to: git rev-parse --symbolic "$@" fails, but we don't notice the exit code. Worse, its empty output means we think the user didn't provide us a ref, and we try to apply stash@{0}. This patch checks the rev-parse exit code and fails early in the revision parsing process. We can also get rid of the stderr test; as a bonus, this means that "stash apply" can now run under GIT_TRACE=1 properly. Signed-off-by: Jeff King <peff@peff.net> Acked-by: Jon Seymour <jon.seymour@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | stash: drop dirty worktree check on applyJeff King2011-04-061-3/+1
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before we apply a stash, we make sure there are no changes in the worktree that are not in the index. This check dates back to the original git-stash.sh, and is presumably intended to prevent changes in the working tree from being accidentally lost during the merge. However, this check has two problems: 1. It is overly restrictive. If my stash changes only file "foo", but "bar" is dirty in the working tree, it will prevent us from applying the stash. 2. It is redundant. We don't touch the working tree at all until we actually call merge-recursive. But it has its own (much more accurate) checks to avoid losing working tree data, and will abort the merge with a nicer message telling us which paths were problems. So we can simply drop the check entirely. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'pk/stash-apply-status-relative'Junio C Hamano2011-03-231-1/+2
|\ \ | | | | | | | | | | | | | | | * pk/stash-apply-status-relative: Add test: git stash shows status relative to current dir git stash: show status relative to current directory
| * | git stash: show status relative to current directoryPiotr Krukowiecki2011-03-141-1/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git status shows modified paths relative to current directory, so it's possible to copy&paste them directly, even if you're in a subdirectory. But "git stash apply" always shows status from root of git repository. This is misleading because you can't use the paths without modifications. This is caused by changing directory to root of repository at the beginning of git stash. This patch makes git stash show status relative to current directory. Instead of removing the "cd to toplevel", which would affect whole script and might have other side-effects, the fix is to change directory temporarily back to original dir just before displaying status. Signed-off-by: Piotr Krukowiecki <piotr.krukowiecki@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | stash: copy the index using --index-output instead of cp -pJohannes Sixt2011-03-171-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 'git stash create' must operate with a temporary index. For this purpose, it used 'cp -p' to create a copy. -p is needed to preserve the timestamp of the index file. Now Jakob Pfender reported a certain combination of a Linux NFS client, OpenBSD NFS server, and cp implementation where this operation failed. Luckily, the first operation in git-stash after copying the index is to call 'git read-tree'. Therefore, use --index-output instead of 'cp -p' to write the copy of the index. --index-output requires that the specified file is on the same volume as the source index, so that the lock file can be rename()d. For this reason, the name of the temporary index is constructed in a way different from the other temporary files. The code path of 'stash -p' also needs a temporary index, but we do not use the new name because it does not depend on the same precondition as --index-output. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | stash: fix incorrect quoting in cleanup of temporary filesJohannes Sixt2011-03-171-1/+1
|/ | | | | | | | | | | The * was inside the quotes, so that the pattern was never expanded and the temporary files were never removed. As a consequence, 'stash -p' left a .git-stash-*-patch file in $GIT_DIR. Other code paths did not leave files behind because they removed the temporary file themselves, at least in non-error paths. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* shell portability: no "export VAR=VAL"Junio C Hamano2010-10-131-1/+1
| | | | | | | | It is more portable to say "VAR=VAL && export VAR" instead. Noticed by Ævar. Signed-off-by: Junio C Hamano <gitster@pobox.com>