summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-06-22 21:15:24 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-06-22 21:15:25 (GMT)
commit49a8bf2edaa7c5922677e1ae04cf44df0c0c8abf (patch)
tree775364213b59807747ee3998634c97d735efe70d
parentb21d6304f1f61c72e420e49520537f88a039ae8d (diff)
parent22fc703ec949602e9fd4e2ab0bb63dd47c2945b5 (diff)
downloadgit-49a8bf2edaa7c5922677e1ae04cf44df0c0c8abf.zip
git-49a8bf2edaa7c5922677e1ae04cf44df0c0c8abf.tar.gz
git-49a8bf2edaa7c5922677e1ae04cf44df0c0c8abf.tar.bz2
Merge branch 'ps/stash-push-pathspec-fix'
"git stash push <pathspec>" did not work from a subdirectory at all. Bugfix for a topic in v2.13 * ps/stash-push-pathspec-fix: git-stash: fix pushing stash with pathspec from subdir
-rwxr-xr-xgit-stash.sh3
-rwxr-xr-xt/t3903-stash.sh16
2 files changed, 19 insertions, 0 deletions
diff --git a/git-stash.sh b/git-stash.sh
index 2fb651b..e7b8593 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")"
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 3b4bed5..4046817 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -812,6 +812,22 @@ test_expect_success 'stash -- <pathspec> stashes and restores the file' '
test_path_is_file bar
'
+test_expect_success 'stash -- <pathspec> stashes in subdirectory' '
+ mkdir sub &&
+ >foo &&
+ >bar &&
+ git add foo bar &&
+ (
+ cd sub &&
+ git stash push -- ../foo
+ ) &&
+ test_path_is_file bar &&
+ test_path_is_missing foo &&
+ git stash pop &&
+ test_path_is_file foo &&
+ test_path_is_file bar
+'
+
test_expect_success 'stash with multiple pathspec arguments' '
>foo &&
>bar &&