Skip to content

Commit 2aa5b6b

Browse files
committed
Merge branch 'pk/stash-apply-status-relative' into maint
* pk/stash-apply-status-relative: Add test: git stash shows status relative to current dir git stash: show status relative to current directory
2 parents bcf3d1f + 6eaf92f commit 2aa5b6b

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

git-stash.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ USAGE="list [<options>]
1212

1313
SUBDIRECTORY_OK=Yes
1414
OPTIONS_SPEC=
15+
START_DIR=`pwd`
1516
. git-sh-setup
1617
require_work_tree
1718
cd_to_toplevel
@@ -393,7 +394,7 @@ apply_stash () {
393394
then
394395
squelch='>/dev/null 2>&1'
395396
fi
396-
eval "git status $squelch" || :
397+
(cd "$START_DIR" && eval "git status $squelch") || :
397398
else
398399
# Merge conflict; keep the exit status from merge-recursive
399400
status=$?

t/t3903-stash.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,4 +556,23 @@ test_expect_success 'stash branch should not drop the stash if the branch exists
556556
git rev-parse stash@{0} --
557557
'
558558

559+
test_expect_success 'stash apply shows status same as git status (relative to current directory)' '
560+
git stash clear &&
561+
echo 1 >subdir/subfile1 &&
562+
echo 2 >subdir/subfile2 &&
563+
git add subdir/subfile1 &&
564+
git commit -m subdir &&
565+
(
566+
cd subdir &&
567+
echo x >subfile1 &&
568+
echo x >../file &&
569+
git status >../expect &&
570+
git stash &&
571+
sane_unset GIT_MERGE_VERBOSITY &&
572+
git stash apply
573+
) |
574+
sed -e 1,2d >actual && # drop "Saved..." and "HEAD is now..."
575+
test_cmp expect actual
576+
'
577+
559578
test_done

0 commit comments

Comments
 (0)