summaryrefslogtreecommitdiff
path: root/git-stash.sh
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-06-13 13:38:34 +0200
committerJunio C Hamano <gitster@pobox.com>2017-06-13 08:27:13 -0700
commit22fc703ec949602e9fd4e2ab0bb63dd47c2945b5 (patch)
treedc67ea0e9a1b66cb1a92d284392a8904f248cdf8 /git-stash.sh
parent3851e4483f0d62e677703297218c9bb47325806f (diff)
downloadgit-22fc703ec949602e9fd4e2ab0bb63dd47c2945b5.tar.gz
git-stash: fix pushing stash with pathspec from subdirps/stash-push-pathspec-fix
The `git stash push` command recently gained the ability to get a pathspec as its argument to only stash matching files. Calling this command from a subdirectory does not work, though, as one of the first things we do is changing to the top level directory without keeping track of the prefix from which the command is being run. Fix the shortcoming by storing the prefix previous to the call to `cd_to_toplevel` and then subsequently using `git rev-parse --prefix` to correctly resolve the pathspec. Add a test to catch future breakage of this usecase. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-stash.sh')
-rwxr-xr-xgit-stash.sh3
1 files changed, 3 insertions, 0 deletions
diff --git a/git-stash.sh b/git-stash.sh
index 2fb651b2b8..e7b85932d6 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -19,6 +19,7 @@ OPTIONS_SPEC=
START_DIR=$(pwd)
. git-sh-setup
require_work_tree
+prefix=$(git rev-parse --show-prefix) || exit 1
cd_to_toplevel
TMP="$GIT_DIR/.git-stash.$$"
@@ -273,6 +274,8 @@ push_stash () {
shift
done
+ eval "set $(git rev-parse --sq --prefix "$prefix" -- "$@")"
+
if test -n "$patch_mode" && test -n "$untracked"
then
die "$(gettext "Can't use --patch and --include-untracked or --all at the same time")"