Skip to content

Commit 26b59b4

Browse files
cvbgegitster
authored andcommitted
git stash: show status relative to current directory
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ea2c69e commit 26b59b4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-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
@@ -394,7 +395,7 @@ apply_stash () {
394395
then
395396
squelch='>/dev/null 2>&1'
396397
fi
397-
eval "git status $squelch" || :
398+
(cd "$START_DIR" && eval "git status $squelch") || :
398399
else
399400
# Merge conflict; keep the exit status from merge-recursive
400401
status=$?

0 commit comments

Comments
 (0)