summaryrefslogtreecommitdiff
path: root/t/t3903-stash.sh
diff options
context:
space:
mode:
authorLibravatar Patrick Steinhardt <ps@pks.im>2017-06-13 13:38:34 +0200
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-06-13 08:27:13 -0700
commit22fc703ec949602e9fd4e2ab0bb63dd47c2945b5 (patch)
treedc67ea0e9a1b66cb1a92d284392a8904f248cdf8 /t/t3903-stash.sh
parentcompletion: add git stash push (diff)
downloadtgif-22fc703ec949602e9fd4e2ab0bb63dd47c2945b5.tar.xz
git-stash: fix pushing stash with pathspec from subdir
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 't/t3903-stash.sh')
-rwxr-xr-xt/t3903-stash.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index b71d1e659e..d10ddb5b35 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 &&