From: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>
To: git@vger.kernel.org
Subject: git stash: status from current dir not top dir?
Date: Fri, 11 Mar 2011 21:49:13 +0100 [thread overview]
Message-ID: <4D7A8AC9.1030506@gmail.com> (raw)
Hi,
git status shows 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" shows status from root of git repository.
This is misleading because you can't copy and paste the paths.
I wonder if it's possible/better to change it so "git stash apply" shows
status relative to directory from which it was executed?
OTOH "git commit" also shows paths relative to root. So maybe git status
should be changed (hopefully no, because the relative paths are quite
useful IMO).
This patch tries to fix git-stash.sh to show status relative to
current directory. I can resend the patch with better commit message.
Example:
$ mkdir d && cd d && echo a > ../topfile && echo b > subfile && git add ..
$ git commit -m 1
[master (root-commit) 6935958] 1
2 files changed, 2 insertions(+), 0 deletions(-)
create mode 100644 d/subfile
create mode 100644 topfile
$ echo x > ../topfile ; echo y > subfile
$ git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: subfile
# modified: ../topfile
#
no changes added to commit (use "git add" and/or "git commit -a")
$ git stash
Saved working directory and index state WIP on master: 6935958 1
HEAD is now at 6935958 1
$ git stash pop
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: d/subfile
# modified: topfile
#
no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (3c7c82dba01feed37c725a795116354f6e229d76)
$ git checkout -- topfile
error: pathspec 'd/topfile' did not match any file(s) known to git.
With the patch:
$ git stash pop
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: subfile
# modified: ../topfile
#
no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (4a0f7bb0a3e2902ba9046686d457b1b8f1ade04c)
---8<---
From: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>
Date: Fri, 11 Mar 2011 20:50:49 +0100
Subject: [PATCH] git stash: show status relative to currect directory
Signed-off-by: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>
---
git-stash.sh | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/git-stash.sh b/git-stash.sh
index 7561b37..586c12f 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -12,6 +12,7 @@ USAGE="list [<options>]
SUBDIRECTORY_OK=Yes
OPTIONS_SPEC=
+START_DIR=`pwd`
. git-sh-setup
require_work_tree
cd_to_toplevel
@@ -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=$?
--
1.7.1
next reply other threads:[~2011-03-11 20:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-11 20:49 Piotr Krukowiecki [this message]
2011-03-11 22:32 ` git stash: status from current dir not top dir? Jeff King
2011-03-12 8:57 ` Piotr Krukowiecki
2011-03-14 7:29 ` Junio C Hamano
2011-03-14 19:45 ` Piotr Krukowiecki
2011-03-17 18:13 ` Piotr Krukowiecki
2011-03-17 19:30 ` Junio C Hamano
2011-03-19 9:24 ` Piotr Krukowiecki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D7A8AC9.1030506@gmail.com \
--to=piotr.krukowiecki@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).