From: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jeff King <peff@peff.net>, git@vger.kernel.org
Subject: Re: git stash: status from current dir not top dir?
Date: Mon, 14 Mar 2011 20:45:41 +0100 [thread overview]
Message-ID: <4D7E7065.20908@gmail.com> (raw)
In-Reply-To: <7v1v2agnww.fsf@alter.siamese.dyndns.org>
W dniu 14.03.2011 08:29, Junio C Hamano pisze:
> Piotr Krukowiecki <piotr.krukowiecki@gmail.com> writes:
>
>> Subject: [PATCH] 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 <piotr.krukowiecki@gmail.com>
>> ---
>
> Sensible. Thanks.
>
> Don't we want to protect this output with some tests?
Right. Wrote a test but it fails mysteriously. Looks like a debug output
is added when test is run as "sh t3903-stash.sh" (the "Merging Version" etc).
No such output when "git apply" is run by hand.
Not sure what to do with it?
With --verbose I see:
[...]
[master b27a2bc] subdir
Author: A U Thor <author@example.com>
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 subdir/subfile1
Saved working directory and index state WIP on master: b27a2bc subdir
HEAD is now at b27a2bc subdir
--- ../output 2011-03-14 19:39:42.473685001 +0000
+++ ../expect 2011-03-14 19:39:42.489685001 +0000
@@ -1,9 +1,3 @@
-Merging Version stash was based on with Stashed changes
-Merging:
-virtual Version stash was based on
-virtual Stashed changes
-found 1 common ancestor(s):
-virtual 13419d0b4f5b097f61dde4c911de99a154f8286f
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
not ok - 41 stash apply shows status same as git status (relative to current directory)
---8<---
From: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>
Date: Mon, 14 Mar 2011 20:19:36 +0100
Subject: [PATCH] Add test: git stash shows status relative to current dir
Signed-off-by: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>
---
t/t3903-stash.sh | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 6fd560c..3682f1c 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -556,4 +556,19 @@ test_expect_success 'stash branch should not drop the stash if the branch exists
git rev-parse stash@{0} --
'
+test_expect_success 'stash apply shows status same as git status (relative to current directory)' '
+ git stash clear &&
+ echo 1 > subdir/subfile1 &&
+ echo 2 > subdir/subfile2 &&
+ git add subdir/subfile1 &&
+ git commit -m subdir &&
+ cd subdir &&
+ echo x > subfile1 &&
+ echo x > ../file &&
+ git stash &&
+ git stash apply > ../output &&
+ git status > ../expect &&
+ test_cmp ../output ../expect
+'
+
test_done
--
1.7.4.1.228.g9e388
--
Piotr Krukowiecki
next prev parent reply other threads:[~2011-03-14 19:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-11 20:49 git stash: status from current dir not top dir? Piotr Krukowiecki
2011-03-11 22:32 ` Jeff King
2011-03-12 8:57 ` Piotr Krukowiecki
2011-03-14 7:29 ` Junio C Hamano
2011-03-14 19:45 ` Piotr Krukowiecki [this message]
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=4D7E7065.20908@gmail.com \
--to=piotr.krukowiecki@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/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).