{"thread":{"id":"26718","subject":"git stash: status from current dir not top dir?","startedAt":"2011-03-11T20:49:13Z","lastAt":"2011-03-19T09:24:24Z","messageCount":8,"participants":["Piotr Krukowiecki","Jeff King","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"163245","messageId":"4D7A8AC9.1030506@gmail.com","threadId":"26718","inReplyTo":null,"subject":"git stash: status from current dir not top dir?","fromName":"Piotr Krukowiecki","fromEmail":"piotr.krukowiecki@gmail.com","sentAt":"2011-03-11T20:49:13Z","receivedAt":"2011-03-11T20:49:13Z","isPatch":false,"sender":{"key":"piotr.krukowiecki@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3259959?v=4"},"body":"Hi,\n\ngit status shows paths relative to current directory, so it's\npossible to copy&paste them directly, even if you're in a subdirectory. \n\nBut \"git stash apply\" shows status from root of git repository.\nThis is misleading because you can't copy and paste the paths.\n\nI wonder if it's possible/better to change it so \"git stash apply\" shows\nstatus relative to directory from which it was executed?\n\nOTOH \"git commit\" also shows paths relative to root. So maybe git status\nshould be changed (hopefully no, because the relative paths are quite\nuseful IMO).\n\nThis patch tries to fix git-stash.sh to show status relative to \ncurrent directory. I can resend the patch with better commit message.\n\nExample:\n\n$ mkdir d && cd d && echo a > ../topfile && echo b > subfile && git add ..\n$ git commit -m 1\n[master (root-commit) 6935958] 1\n 2 files changed, 2 insertions(+), 0 deletions(-)\n create mode 100644 d/subfile\n create mode 100644 topfile\n$ echo x > ../topfile ; echo y > subfile \n$ git status\n# On branch master\n# Changes not staged for commit:\n#   (use \"git add <file>...\" to update what will be committed)\n#   (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n#\tmodified:   subfile\n#\tmodified:   ../topfile\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n$ git stash\nSaved working directory and index state WIP on master: 6935958 1\nHEAD is now at 6935958 1\n$ git stash pop\n# On branch master\n# Changes not staged for commit:\n#   (use \"git add <file>...\" to update what will be committed)\n#   (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n#\tmodified:   d/subfile\n#\tmodified:   topfile\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\nDropped refs/stash@{0} (3c7c82dba01feed37c725a795116354f6e229d76)\n$ git checkout -- topfile\nerror: pathspec 'd/topfile' did not match any file(s) known to git.\n\n\nWith the patch:\n\n$ git stash pop\n# On branch master\n# Changes not staged for commit:\n#   (use \"git add <file>...\" to update what will be committed)\n#   (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n#\tmodified:   subfile\n#\tmodified:   ../topfile\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\nDropped refs/stash@{0} (4a0f7bb0a3e2902ba9046686d457b1b8f1ade04c)\n\n---8<---\nFrom: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>\nDate: Fri, 11 Mar 2011 20:50:49 +0100\nSubject: [PATCH] git stash: show status relative to currect directory\n\n\nSigned-off-by: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>\n---\n git-stash.sh |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 7561b37..586c12f 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -12,6 +12,7 @@ USAGE=\"list [<options>]\n \n SUBDIRECTORY_OK=Yes\n OPTIONS_SPEC=\n+START_DIR=`pwd`\n . git-sh-setup\n require_work_tree\n cd_to_toplevel\n@@ -394,7 +395,7 @@ apply_stash () {\n \t\tthen\n \t\t\tsquelch='>/dev/null 2>&1'\n \t\tfi\n-\t\teval \"git status $squelch\" || :\n+\t\t(cd \"$START_DIR\" && eval \"git status $squelch\") || :\n \telse\n \t\t# Merge conflict; keep the exit status from merge-recursive\n \t\tstatus=$?\n-- \n1.7.1\n"},{"id":"163249","messageId":"20110311223232.GA21410@sigill.intra.peff.net","threadId":"26718","inReplyTo":"4D7A8AC9.1030506@gmail.com","subject":"Re: git stash: status from current dir not top dir?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-03-11T22:32:32Z","receivedAt":"2011-03-11T22:32:32Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Mar 11, 2011 at 09:49:13PM +0100, Piotr Krukowiecki wrote:\n\n> But \"git stash apply\" shows status from root of git repository.\n> This is misleading because you can't copy and paste the paths.\n\nYeah, I am inclined to call it a bug. git-status will show the status of\nthe whole tree from wherever you are, and people who want full paths\nwill have status.relativePaths turned off, anyway. So I think your\nproposed semantics are more natural.\n\n> This patch tries to fix git-stash.sh to show status relative to \n> current directory. I can resend the patch with better commit message.\n\nYes, please. There is lots of nice discussion in your email but none of\nit in the commit message. :)\n\n> diff --git a/git-stash.sh b/git-stash.sh\n> index 7561b37..586c12f 100755\n> --- a/git-stash.sh\n> +++ b/git-stash.sh\n> @@ -12,6 +12,7 @@ USAGE=\"list [<options>]\n>  \n>  SUBDIRECTORY_OK=Yes\n>  OPTIONS_SPEC=\n> +START_DIR=`pwd`\n>  . git-sh-setup\n>  require_work_tree\n>  cd_to_toplevel\n> @@ -394,7 +395,7 @@ apply_stash () {\n>  \t\tthen\n>  \t\t\tsquelch='>/dev/null 2>&1'\n>  \t\tfi\n> -\t\teval \"git status $squelch\" || :\n> +\t\t(cd \"$START_DIR\" && eval \"git status $squelch\") || :\n>  \telse\n>  \t\t# Merge conflict; keep the exit status from merge-recursive\n>  \t\tstatus=$?\n\nThis fix looks reasonable to me. The other option would be to avoid\ncd_to_toplevel at the beginning (which I am not sure why we really need\nin the first place, but presumably some code paths rely on it), but it's\nprobably not worth the risk of introducing new confusing bugs.\n\n-Peff\n"},{"id":"163257","messageId":"4D7B358A.5010101@gmail.com","threadId":"26718","inReplyTo":"20110311223232.GA21410@sigill.intra.peff.net","subject":"Re: git stash: status from current dir not top dir?","fromName":"Piotr Krukowiecki","fromEmail":"piotr.krukowiecki@gmail.com","sentAt":"2011-03-12T08:57:46Z","receivedAt":"2011-03-12T08:57:46Z","isPatch":false,"sender":{"key":"piotr.krukowiecki@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3259959?v=4"},"body":"\nThanks for review,\nattaching patch with updated commit message.\n\nW dniu 11.03.2011 23:32, Jeff King pisze:\n> On Fri, Mar 11, 2011 at 09:49:13PM +0100, Piotr Krukowiecki wrote:\n> \n>> But \"git stash apply\" shows status from root of git repository.\n>> This is misleading because you can't copy and paste the paths.\n> \n> Yeah, I am inclined to call it a bug. git-status will show the status of\n> the whole tree from wherever you are, and people who want full paths\n> will have status.relativePaths turned off, anyway. So I think your\n> proposed semantics are more natural.\n\nI think it's better this way too, one thing that made me doubt if this is \nintended or not is fact that git-commit also shows paths relative to root\ndir...\n \n>> This patch tries to fix git-stash.sh to show status relative to \n>> current directory. I can resend the patch with better commit message.\n> \n> Yes, please. There is lots of nice discussion in your email but none of\n> it in the commit message. :)\n\nDidn't want to duplicate ;)\n\n> \n>> diff --git a/git-stash.sh b/git-stash.sh\n>> index 7561b37..586c12f 100755\n>> --- a/git-stash.sh\n>> +++ b/git-stash.sh\n>> @@ -12,6 +12,7 @@ USAGE=\"list [<options>]\n>>  \n>>  SUBDIRECTORY_OK=Yes\n>>  OPTIONS_SPEC=\n>> +START_DIR=`pwd`\n>>  . git-sh-setup\n>>  require_work_tree\n>>  cd_to_toplevel\n>> @@ -394,7 +395,7 @@ apply_stash () {\n>>  \t\tthen\n>>  \t\t\tsquelch='>/dev/null 2>&1'\n>>  \t\tfi\n>> -\t\teval \"git status $squelch\" || :\n>> +\t\t(cd \"$START_DIR\" && eval \"git status $squelch\") || :\n>>  \telse\n>>  \t\t# Merge conflict; keep the exit status from merge-recursive\n>>  \t\tstatus=$?\n> \n> This fix looks reasonable to me. The other option would be to avoid\n> cd_to_toplevel at the beginning (which I am not sure why we really need\n> in the first place, but presumably some code paths rely on it), but it's\n> probably not worth the risk of introducing new confusing bugs.\n> \n> -Peff\n---8<---\nFrom: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>\nDate: Fri, 11 Mar 2011 20:50:49 +0100\nSubject: [PATCH] git stash: show status relative to current directory\n\ngit status shows modified paths relative to current directory, so it's\npossible to copy&paste them directly, even if you're in a subdirectory.\n\nBut \"git stash apply\" always shows status from root of git repository.\nThis is misleading because you can't use the paths without modifications.\n\nThis is caused by changing directory to root of repository at the\nbeginning of git stash.\n\nThis patch makes git stash show status relative to current directory.\nInstead of removing the \"cd to toplevel\", which would affect whole\nscript and might have other side-effects, the fix is to change directory\ntemporarily back to original dir just before displaying status.\n\nSigned-off-by: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>\n---\n git-stash.sh |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 7561b37..b59c201 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -12,6 +12,7 @@ USAGE=\"list [<options>]\n \n SUBDIRECTORY_OK=Yes\n OPTIONS_SPEC=\n+START_DIR=`pwd`\n . git-sh-setup\n require_work_tree\n cd_to_toplevel\n@@ -394,7 +395,7 @@ apply_stash () {\n \t\tthen\n \t\t\tsquelch='>/dev/null 2>&1'\n \t\tfi\n-\t\teval \"git status $squelch\" || :\n+\t\t(cd \"$START_DIR\" && eval \"git status $squelch\") || :\n \telse\n \t\t# Merge conflict; keep the exit status from merge-recursive\n \t\tstatus=$?\n-- \n1.7.4.1.228.g9e388\n"},{"id":"163303","messageId":"7v1v2agnww.fsf@alter.siamese.dyndns.org","threadId":"26718","inReplyTo":"4D7B358A.5010101@gmail.com","subject":"Re: git stash: status from current dir not top dir?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-03-14T07:29:51Z","receivedAt":"2011-03-14T07:29:51Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Piotr Krukowiecki <piotr.krukowiecki@gmail.com> writes:\n\n> Subject: [PATCH] git stash: show status relative to current directory\n>\n> git status shows modified paths relative to current directory, so it's\n> possible to copy&paste them directly, even if you're in a subdirectory.\n>\n> But \"git stash apply\" always shows status from root of git repository.\n> This is misleading because you can't use the paths without modifications.\n>\n> This is caused by changing directory to root of repository at the\n> beginning of git stash.\n>\n> This patch makes git stash show status relative to current directory.\n> Instead of removing the \"cd to toplevel\", which would affect whole\n> script and might have other side-effects, the fix is to change directory\n> temporarily back to original dir just before displaying status.\n>\n> Signed-off-by: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>\n> ---\n\nSensible. Thanks.\n\nDon't we want to protect this output with some tests?\n"},{"id":"163338","messageId":"4D7E7065.20908@gmail.com","threadId":"26718","inReplyTo":"7v1v2agnww.fsf@alter.siamese.dyndns.org","subject":"Re: git stash: status from current dir not top dir?","fromName":"Piotr Krukowiecki","fromEmail":"piotr.krukowiecki@gmail.com","sentAt":"2011-03-14T19:45:41Z","receivedAt":"2011-03-14T19:45:41Z","isPatch":false,"sender":{"key":"piotr.krukowiecki@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3259959?v=4"},"body":"W dniu 14.03.2011 08:29, Junio C Hamano pisze:\n> Piotr Krukowiecki <piotr.krukowiecki@gmail.com> writes:\n> \n>> Subject: [PATCH] git stash: show status relative to current directory\n>>\n>> git status shows modified paths relative to current directory, so it's\n>> possible to copy&paste them directly, even if you're in a subdirectory.\n>>\n>> But \"git stash apply\" always shows status from root of git repository.\n>> This is misleading because you can't use the paths without modifications.\n>>\n>> This is caused by changing directory to root of repository at the\n>> beginning of git stash.\n>>\n>> This patch makes git stash show status relative to current directory.\n>> Instead of removing the \"cd to toplevel\", which would affect whole\n>> script and might have other side-effects, the fix is to change directory\n>> temporarily back to original dir just before displaying status.\n>>\n>> Signed-off-by: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>\n>> ---\n> \n> Sensible. Thanks.\n> \n> Don't we want to protect this output with some tests?\n\nRight. Wrote a test but it fails mysteriously. Looks like a debug output\nis added when test is run as \"sh t3903-stash.sh\" (the \"Merging Version\" etc).\nNo such output when \"git apply\" is run by hand.\n\nNot sure what to do with it?\n\nWith --verbose I see:\n\n[...]\n[master b27a2bc] subdir\n Author: A U Thor <author@example.com>\n 1 files changed, 1 insertions(+), 0 deletions(-)\n create mode 100644 subdir/subfile1\nSaved working directory and index state WIP on master: b27a2bc subdir\nHEAD is now at b27a2bc subdir\n--- ../output\t2011-03-14 19:39:42.473685001 +0000\n+++ ../expect\t2011-03-14 19:39:42.489685001 +0000\n@@ -1,9 +1,3 @@\n-Merging Version stash was based on with Stashed changes\n-Merging:\n-virtual Version stash was based on\n-virtual Stashed changes\n-found 1 common ancestor(s):\n-virtual 13419d0b4f5b097f61dde4c911de99a154f8286f\n # On branch master\n # Changes not staged for commit:\n #   (use \"git add <file>...\" to update what will be committed)\nnot ok - 41 stash apply shows status same as git status (relative to current directory)\n\n\n---8<---\nFrom: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>\nDate: Mon, 14 Mar 2011 20:19:36 +0100\nSubject: [PATCH] Add test: git stash shows status relative to current dir\n\n\nSigned-off-by: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>\n---\n t/t3903-stash.sh |   15 +++++++++++++++\n 1 files changed, 15 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t3903-stash.sh b/t/t3903-stash.sh\nindex 6fd560c..3682f1c 100755\n--- a/t/t3903-stash.sh\n+++ b/t/t3903-stash.sh\n@@ -556,4 +556,19 @@ test_expect_success 'stash branch should not drop the stash if the branch exists\n \tgit rev-parse stash@{0} --\n '\n \n+test_expect_success 'stash apply shows status same as git status (relative to current directory)' '\n+\tgit stash clear &&\n+\techo 1 > subdir/subfile1 &&\n+\techo 2 > subdir/subfile2 &&\n+\tgit add subdir/subfile1 &&\n+\tgit commit -m subdir &&\n+\tcd subdir &&\n+\techo x > subfile1 &&\n+\techo x > ../file &&\n+\tgit stash &&\n+\tgit stash apply > ../output &&\n+\tgit status > ../expect &&\n+\ttest_cmp ../output ../expect\n+'\n+\n test_done\n-- \n1.7.4.1.228.g9e388\n\n\n\n-- \nPiotr Krukowiecki\n"},{"id":"163569","messageId":"4D824F46.70107@gmail.com","threadId":"26718","inReplyTo":"4D7E7065.20908@gmail.com","subject":"Re: git stash: status from current dir not top dir?","fromName":"Piotr Krukowiecki","fromEmail":"piotr.krukowiecki@gmail.com","sentAt":"2011-03-17T18:13:26Z","receivedAt":"2011-03-17T18:13:26Z","isPatch":false,"sender":{"key":"piotr.krukowiecki@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3259959?v=4"},"body":"W dniu 14.03.2011 20:45, Piotr Krukowiecki pisze:\n> Right. Wrote a test but it fails mysteriously. Looks like a debug output\n> is added when test is run as \"sh t3903-stash.sh\" (the \"Merging Version\" etc).\n> No such output when \"git apply\" is run by hand.\n\nTo recap the problem was that \"git stash apply\" run during tests printed some\ndebug messages as shown below. In result I could not compare its output with\nexpected \"git status\" output.\n\n\n> Not sure what to do with it?\n\nI found out it was caused by \n    GIT_MERGE_VERBOSITY=5\nin test-lib.sh\n\nIt was introduced in 8d0fc48f2730 with comment:\n    Its really nice to be able to run a test with -v and automatically\n    see the \"debugging\" dump from merge-recursive, especially if we\n    are actually trying to debug merge-recursive.\n\nNow I don't know how should I handle this:\n\n    1. unset it just before \"git stash apply\" in my test\n       A safe, local change\n\n    2. remove it from test-lib.sh\n       The variable changed git behaviour - might impact tests, should it be\n       set by default?\n\n    3. add new option in test-lib.sh to set it (--merge-verbosity?)\n       Also looks safe, but still some tests would fail with it\n       (which would be mentioned in the option documentation)\n\n    4. change test-lib.sh to set it only when --verbose/--debug is passed\n       This seems to be the intention, but test results would be different\n       with those options (some tests would fail)!\n\nFirst three choices look more or less sensible.\n\n\n> With --verbose I see:\n> \n> [...]\n> [master b27a2bc] subdir\n>  Author: A U Thor <author@example.com>\n>  1 files changed, 1 insertions(+), 0 deletions(-)\n>  create mode 100644 subdir/subfile1\n> Saved working directory and index state WIP on master: b27a2bc subdir\n> HEAD is now at b27a2bc subdir\n> --- ../output\t2011-03-14 19:39:42.473685001 +0000\n> +++ ../expect\t2011-03-14 19:39:42.489685001 +0000\n> @@ -1,9 +1,3 @@\n> -Merging Version stash was based on with Stashed changes\n> -Merging:\n> -virtual Version stash was based on\n> -virtual Stashed changes\n> -found 1 common ancestor(s):\n> -virtual 13419d0b4f5b097f61dde4c911de99a154f8286f\n>  # On branch master\n>  # Changes not staged for commit:\n>  #   (use \"git add <file>...\" to update what will be committed)\n> not ok - 41 stash apply shows status same as git status (relative to current directory)\n> \n> \n> ---8<---\n> From: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>\n> Date: Mon, 14 Mar 2011 20:19:36 +0100\n> Subject: [PATCH] Add test: git stash shows status relative to current dir\n> \n> \n> Signed-off-by: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>\n> ---\n>  t/t3903-stash.sh |   15 +++++++++++++++\n>  1 files changed, 15 insertions(+), 0 deletions(-)\n> \n> diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh\n> index 6fd560c..3682f1c 100755\n> --- a/t/t3903-stash.sh\n> +++ b/t/t3903-stash.sh\n> @@ -556,4 +556,19 @@ test_expect_success 'stash branch should not drop the stash if the branch exists\n>  \tgit rev-parse stash@{0} --\n>  '\n>  \n> +test_expect_success 'stash apply shows status same as git status (relative to current directory)' '\n> +\tgit stash clear &&\n> +\techo 1 > subdir/subfile1 &&\n> +\techo 2 > subdir/subfile2 &&\n> +\tgit add subdir/subfile1 &&\n> +\tgit commit -m subdir &&\n> +\tcd subdir &&\n> +\techo x > subfile1 &&\n> +\techo x > ../file &&\n> +\tgit stash &&\n> +\tgit stash apply > ../output &&\n> +\tgit status > ../expect &&\n> +\ttest_cmp ../output ../expect\n> +'\n> +\n>  test_done\n\n\n-- \nPiotr Krukowiecki\n"},{"id":"163578","messageId":"7vsjul35p3.fsf@alter.siamese.dyndns.org","threadId":"26718","inReplyTo":"4D824F46.70107@gmail.com","subject":"Re: git stash: status from current dir not top dir?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-03-17T19:30:48Z","receivedAt":"2011-03-17T19:30:48Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Piotr Krukowiecki <piotr.krukowiecki@gmail.com> writes:\n\n> Now I don't know how should I handle this:\n>\n>     1. unset it just before \"git stash apply\" in my test\n>        A safe, local change\n\nThis is the preferred method; in addition to \"a safe local\", more\nimportantly, at that point you are testing what you _want_ to be testing,\nnamely, how the output appears to the _real_ end users who do not use\nverbose message. So for that purpose, mucking locally with MERGE_VERBOSITY\nis perfectly acceptable.\n\nYou would not just \"unset it just before\", but \"unset around it\" in a\nsubshell like this:\n\n\tgit stash &&\n\t(\n\t\tsane_unset GIT_MERGE_VERBOSITY &&\n\t        git stash apply\n\t) >../actual &&\n\tgit status >../expect &&\n        test_cmp ../expect ../actual\n\nso that if somebody adds new tests later in the script, they are not\naffected by this change.\n\nWrite your test_cmp always to compare expected with actual, not the other\nway around, so that the diff output you see when the test is run under -v\noption shows the changes from what is expected.\n\nThanks.\n"},{"id":"163737","messageId":"4D847648.6080404@gmail.com","threadId":"26718","inReplyTo":"7vsjul35p3.fsf@alter.siamese.dyndns.org","subject":"Re: git stash: status from current dir not top dir?","fromName":"Piotr Krukowiecki","fromEmail":"piotr.krukowiecki@gmail.com","sentAt":"2011-03-19T09:24:24Z","receivedAt":"2011-03-19T09:24:24Z","isPatch":false,"sender":{"key":"piotr.krukowiecki@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3259959?v=4"},"body":"W dniu 17.03.2011 20:30, Junio C Hamano pisze:\n> Piotr Krukowiecki <piotr.krukowiecki@gmail.com> writes:\n> \n>> Now I don't know how should I handle this:\n>>\n>>     1. unset it just before \"git stash apply\" in my test\n>>        A safe, local change\n> \n> This is the preferred method; in addition to \"a safe local\", more\n> importantly, at that point you are testing what you _want_ to be testing,\n> namely, how the output appears to the _real_ end users who do not use\n> verbose message. So for that purpose, mucking locally with MERGE_VERBOSITY\n> is perfectly acceptable.\n> \n> You would not just \"unset it just before\", but \"unset around it\" in a\n> subshell like this:\n> \n> \tgit stash &&\n> \t(\n> \t\tsane_unset GIT_MERGE_VERBOSITY &&\n> \t        git stash apply\n> \t) >../actual &&\n> \tgit status >../expect &&\n>         test_cmp ../expect ../actual\n> \n> so that if somebody adds new tests later in the script, they are not\n> affected by this change.\n> \n> Write your test_cmp always to compare expected with actual, not the other\n> way around, so that the diff output you see when the test is run under -v\n> option shows the changes from what is expected.\n> \n> Thanks.\n\nThanks, updated according to your suggestions.\n\nI've also added a check to see if the output contains a relative path\n(so we really test not only that git-stash shows the same status\nas git-status, but that the paths are relative).\n    \nI'm not resending the original patch for git-stash.sh - I don't know if\nit's expected to always send full set of patches?\n\n\n---8<---\nFrom: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>\nDate: Mon, 14 Mar 2011 20:19:36 +0100\nSubject: [PATCH 2/2] Add test: git stash shows status relative to current dir\n\n\nSigned-off-by: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>\n---\n t/t3903-stash.sh |   19 +++++++++++++++++++\n 1 files changed, 19 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t3903-stash.sh b/t/t3903-stash.sh\nindex 6fd560c..13f9ae8 100755\n--- a/t/t3903-stash.sh\n+++ b/t/t3903-stash.sh\n@@ -556,4 +556,23 @@ test_expect_success 'stash branch should not drop the stash if the branch exists\n \tgit rev-parse stash@{0} --\n '\n \n+test_expect_success 'stash apply shows status same as git status (relative to current directory)' '\n+\tgit stash clear &&\n+\techo 1 > subdir/subfile1 &&\n+\techo 2 > subdir/subfile2 &&\n+\tgit add subdir/subfile1 &&\n+\tgit commit -m subdir &&\n+\tcd subdir &&\n+\techo x > subfile1 &&\n+\techo x > ../file &&\n+\tgit stash &&\n+\t(\n+\t\tsane_unset GIT_MERGE_VERBOSITY &&\n+\t\tgit stash apply\n+\t) > ../actual &&\n+\tgit status > ../expect &&\n+\ttest_cmp ../expect ../actual &&\n+\tgrep \"[.][.]/actual\" ../actual \n+'\n+\n test_done\n-- \n1.7.4.1.296.gca6da\n\n\n-- \nPiotr Krukowiecki\n"}]}