Skip to content

Commit

Permalink
git stash: show status relative to current directory
Browse files Browse the repository at this point in the history
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 <piotr.krukowiecki@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Piotr Krukowiecki authored and Junio C Hamano committed Mar 14, 2011
1 parent ea2c69e commit 26b59b4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion git-stash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ USAGE="list [<options>]

SUBDIRECTORY_OK=Yes
OPTIONS_SPEC=
START_DIR=`pwd`
. git-sh-setup
require_work_tree
cd_to_toplevel
Expand Down Expand Up @@ -394,7 +395,7 @@ apply_stash () {
then
squelch='>/dev/null 2>&1'
fi
eval "git status $squelch" || :
(cd "$START_DIR" && eval "git status $squelch") || :
else
# Merge conflict; keep the exit status from merge-recursive
status=$?
Expand Down

0 comments on commit 26b59b4

Please sign in to comment.