{"thread":{"id":"25228","subject":"git-1.7.3 breakage: \"git stash show xxx\" doesn't show anything","startedAt":"2010-09-24T19:19:37Z","lastAt":"2010-09-27T15:38:51Z","messageCount":27,"participants":["Robin H. Johnson","Brandon Casey","Brian Gernhardt","Jon Seymour","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"151531","messageId":"robbat2-20100924T191752-102740530Z@orbis-terrarum.net","threadId":"25228","inReplyTo":null,"subject":"git-1.7.3 breakage: \"git stash show xxx\" doesn't show anything","fromName":"Robin H. Johnson","fromEmail":"robbat2@gentoo.org","sentAt":"2010-09-24T19:19:37Z","receivedAt":"2010-09-24T19:19:37Z","isPatch":false,"sender":{"key":"robbat2@gentoo.org","avatar":"https://avatars.githubusercontent.com/u/373898?v=4"},"body":"Downstream bug: http://bugs.gentoo.org/338586\n\ntelling git-stash to show a specific stash no longer works with git-1.7.3:\n  git stash show stash@{0}\n  <no output!?>\n\nDowngrading to dev-vcs/git-1.7.2.3 and it works fine.\nNoticed on two stable amd64 systems.\n\nReproduction:\n$ rm -rf foo && mkdir foo && cd foo\n$ git init\nInitialized empty Git repository in /home/vapier/foo/.git/\n$ echo f > f && git add f && git commit -qmm\n$ > f\n$ git stash\nSaved working directory and index state WIP on master: d287dea m\nHEAD is now at d287dea m\n$ git stash list | cat\nstash@{0}: WIP on master: d287dea m\n$ git stash show | cat\n f |    1 -\n 1 files changed, 0 insertions(+), 1 deletions(-)\n$ git stash show stash@{0} | cat\n<nothing!>\n\n-- \nRobin Hugh Johnson\nGentoo Linux: Developer, Trustee & Infrastructure Lead\nE-Mail     : robbat2@gentoo.org\nGnuPG FP   : 11AC BA4F 4778 E3F6 E4ED  F38E B27B 944E 3488 4E85\n"},{"id":"151540","messageId":"iET3wn06TheqzndLNXxSuZJHDP5RwU5NWenjr2MQJI96tqWxE3MYjw@cipher.nrlssc.navy.mil","threadId":"25228","inReplyTo":"robbat2-20100924T191752-102740530Z@orbis-terrarum.net","subject":"Re: git-1.7.3 breakage: \"git stash show xxx\" doesn't show anything","fromName":"Brandon Casey","fromEmail":"brandon.casey.ctr@nrlssc.navy.mil","sentAt":"2010-09-24T20:01:31Z","receivedAt":"2010-09-24T20:01:31Z","isPatch":false,"sender":{"key":"brandon.casey.ctr@nrlssc.navy.mil","avatar":null},"body":"On 09/24/2010 02:19 PM, Robin H. Johnson wrote:\n> Downstream bug: http://bugs.gentoo.org/338586\n> \n> telling git-stash to show a specific stash no longer works with git-1.7.3:\n>   git stash show stash@{0}\n>   <no output!?>\n> \n> Downgrading to dev-vcs/git-1.7.2.3 and it works fine.\n> Noticed on two stable amd64 systems.\n> \n> Reproduction:\n> $ rm -rf foo && mkdir foo && cd foo\n> $ git init\n> Initialized empty Git repository in /home/vapier/foo/.git/\n> $ echo f > f && git add f && git commit -qmm\n> $ > f\n> $ git stash\n> Saved working directory and index state WIP on master: d287dea m\n> HEAD is now at d287dea m\n> $ git stash list | cat\n> stash@{0}: WIP on master: d287dea m\n> $ git stash show | cat\n>  f |    1 -\n>  1 files changed, 0 insertions(+), 1 deletions(-)\n> $ git stash show stash@{0} | cat\n> <nothing!>\n>\n\nProbably,\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 7ce818b..4fbfb62 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -265,7 +265,7 @@ parse_flags_and_rev()\n        i_tree=\n \n        REV=$(git rev-parse --no-flags --symbolic \"$@\" 2>/dev/null)\n-       FLAGS=$(git rev-parse --no-revs -- \"$@\" 2>/dev/null)\n+       FLAGS=$(git rev-parse --no-revs --flags \"$@\" 2>/dev/null)\n \n        set -- $FLAGS\n \n"},{"id":"151541","messageId":"00400143-1A23-4245-9D7C-4AC9093785F5@gernhardtsoftware.com","threadId":"25228","inReplyTo":"iET3wn06TheqzndLNXxSuZJHDP5RwU5NWenjr2MQJI96tqWxE3MYjw@cipher.nrlssc.navy.mil","subject":"Re: git-1.7.3 breakage: \"git stash show xxx\" doesn't show anything","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2010-09-24T20:27:42Z","receivedAt":"2010-09-24T20:27:42Z","isPatch":false,"sender":{"key":"brian@gernhardtsoftware.com","avatar":"https://avatars.githubusercontent.com/u/133455?v=4"},"body":"\nOn Sep 24, 2010, at 4:01 PM, Brandon Casey wrote:\n\n> Probably,\n> \n> diff --git a/git-stash.sh b/git-stash.sh\n> index 7ce818b..4fbfb62 100755\n> --- a/git-stash.sh\n> +++ b/git-stash.sh\n> @@ -265,7 +265,7 @@ parse_flags_and_rev()\n>        i_tree=\n> \n>        REV=$(git rev-parse --no-flags --symbolic \"$@\" 2>/dev/null)\n> -       FLAGS=$(git rev-parse --no-revs -- \"$@\" 2>/dev/null)\n> +       FLAGS=$(git rev-parse --no-revs --flags \"$@\" 2>/dev/null)\n> \n>        set -- $FLAGS\n\nI bisected the issue to a9bf09e (detached-stash: simplify git stash show), which is when \"git stash show\" started using parse_flags_and_rev (via assert_stash_like()).\n\nMore worrying to me is that the tests for \"git stash show\" don't bother to test the output.  I'll be working on that now.\n\n~~ Brian\n"},{"id":"151545","messageId":"BVPnfVXRBMtK-9WPRRt3RH05x0aSmoFQsrb6lVp2uyULwHxOV-DnAXrmucCvrGrPQX_-AdS0fnA@cipher.nrlssc.navy.mil","threadId":"25228","inReplyTo":"00400143-1A23-4245-9D7C-4AC9093785F5@gernhardtsoftware.com","subject":"[PATCH] t/t3903-stash: improve testing of git-stash show","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2010-09-24T20:40:38Z","receivedAt":"2010-09-24T20:40:38Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"From: Brandon Casey <drafnel@gmail.com>\n\nRecently, the 'stash show' functionality was broken for the case when a\nstash-like argument was supplied.  Since, commit 9bf09e, 'stash show' when\nsupplied a stash-like argument prints nothing and still exists with a zero\nstatus.  Unfortunately, the flaw slipped through the test suite cracks\nsince the output of 'stash show' was not verified to be correct.\n\nImprove and expand on the existing tests so that this flaws is detected.\n\nSigned-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n---\n\n\nOn 09/24/2010 03:27 PM, Brian Gernhardt wrote:\n> I bisected the issue to a9bf09e (detached-stash: simplify git stash show),\n> which is when \"git stash show\" started using parse_flags_and_rev (via\n> assert_stash_like()).\n> \n> More worrying to me is that the tests for \"git stash show\" don't bother\n> to test the output.  I'll be working on that now.\n\nI was preparing these tests when your email came in.\n\nhth,\nBrandon\n\n\n t/t3903-stash.sh |   62 ++++++++++++++++++++++++++++++++++++++++++++++++++---\n 1 files changed, 58 insertions(+), 4 deletions(-)\n\ndiff --git a/t/t3903-stash.sh b/t/t3903-stash.sh\nindex a283dca..e8a7338 100755\n--- a/t/t3903-stash.sh\n+++ b/t/t3903-stash.sh\n@@ -406,7 +406,7 @@ test_expect_success 'stash branch - stashes on stack, stash-like argument' '\n \ttest $(git ls-files --modified | wc -l) -eq 1\n '\n \n-test_expect_success 'stash show - stashes on stack, stash-like argument' '\n+test_expect_failure 'stash show - stashes on stack, stash-like argument' '\n \tgit stash clear &&\n \ttest_when_finished \"git reset --hard HEAD\" &&\n \tgit reset --hard &&\n@@ -416,16 +416,70 @@ test_expect_success 'stash show - stashes on stack, stash-like argument' '\n \techo bar >> file &&\n \tSTASH_ID=$(git stash create) &&\n \tgit reset --hard &&\n-\tgit stash show ${STASH_ID}\n+\tcat >expected <<-EOF &&\n+\t file |    1 +\n+\t 1 files changed, 1 insertions(+), 0 deletions(-)\n+\tEOF\n+\tgit stash show ${STASH_ID} >actual &&\n+\ttest_cmp expected actual\n '\n-test_expect_success 'stash show - no stashes on stack, stash-like argument' '\n+\n+test_expect_failure 'stash show -p - stashes on stack, stash-like argument' '\n+\tgit stash clear &&\n+\ttest_when_finished \"git reset --hard HEAD\" &&\n+\tgit reset --hard &&\n+\techo foo >> file &&\n+\tgit stash &&\n+\ttest_when_finished \"git stash drop\" &&\n+\techo bar >> file &&\n+\tSTASH_ID=$(git stash create) &&\n+\tgit reset --hard &&\n+\tcat >expected <<-EOF &&\n+\tdiff --git a/file b/file\n+\tindex 7601807..935fbd3 100644\n+\t--- a/file\n+\t+++ b/file\n+\t@@ -1 +1,2 @@\n+\t baz\n+\t+bar\n+\tEOF\n+\tgit stash show -p ${STASH_ID} >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_failure 'stash show - no stashes on stack, stash-like argument' '\n+\tgit stash clear &&\n+\ttest_when_finished \"git reset --hard HEAD\" &&\n+\tgit reset --hard &&\n+\techo foo >> file &&\n+\tSTASH_ID=$(git stash create) &&\n+\tgit reset --hard &&\n+\tcat >expected <<-EOF &&\n+\t file |    1 +\n+\t 1 files changed, 1 insertions(+), 0 deletions(-)\n+\tEOF\n+\tgit stash show ${STASH_ID} >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_failure 'stash show -p - no stashes on stack, stash-like argument' '\n \tgit stash clear &&\n \ttest_when_finished \"git reset --hard HEAD\" &&\n \tgit reset --hard &&\n \techo foo >> file &&\n \tSTASH_ID=$(git stash create) &&\n \tgit reset --hard &&\n-\tgit stash show ${STASH_ID}\n+\tcat >expected <<-EOF &&\n+\tdiff --git a/file b/file\n+\tindex 7601807..71b52c4 100644\n+\t--- a/file\n+\t+++ b/file\n+\t@@ -1 +1,2 @@\n+\t baz\n+\t+foo\n+\tEOF\n+\tgit stash show -p ${STASH_ID} >actual &&\n+\ttest_cmp expected actual\n '\n \n test_expect_success 'stash drop - fail early if specified stash is not a stash reference' '\n-- \n1.7.3\n"},{"id":"151547","messageId":"47BAA71F-CF5C-4A98-BBB9-C502C81E3230@silverinsanity.com","threadId":"25228","inReplyTo":"BVPnfVXRBMtK-9WPRRt3RH05x0aSmoFQsrb6lVp2uyULwHxOV-DnAXrmucCvrGrPQX_-AdS0fnA@cipher.nrlssc.navy.mil","subject":"Re: [PATCH] t/t3903-stash: improve testing of git-stash show","fromName":"Brian Gernhardt","fromEmail":"benji@silverinsanity.com","sentAt":"2010-09-24T20:43:18Z","receivedAt":"2010-09-24T20:43:18Z","isPatch":true,"sender":{"key":"benji@silverinsanity.com","avatar":"https://gravatar.com/avatar/e06c101dbc25c68114d859b4a9ec7cf8a2c52fd2b0270ef0eac0e2e63ff22311?d=mp&s=160"},"body":"\nOn Sep 24, 2010, at 4:40 PM, Brandon Casey wrote:\n\n> From: Brandon Casey <drafnel@gmail.com>\n> \n> Recently, the 'stash show' functionality was broken for the case when a\n> stash-like argument was supplied.  Since, commit 9bf09e, 'stash show' when\n> supplied a stash-like argument prints nothing and still exists with a zero\n> status.  Unfortunately, the flaw slipped through the test suite cracks\n> since the output of 'stash show' was not verified to be correct.\n> \n> Improve and expand on the existing tests so that this flaws is detected.\n> \n> Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n> ---\n> \n> \n> On 09/24/2010 03:27 PM, Brian Gernhardt wrote:\n>> I bisected the issue to a9bf09e (detached-stash: simplify git stash show),\n>> which is when \"git stash show\" started using parse_flags_and_rev (via\n>> assert_stash_like()).\n>> \n>> More worrying to me is that the tests for \"git stash show\" don't bother\n>> to test the output.  I'll be working on that now.\n> \n> I was preparing these tests when your email came in.\n\nI spent longer finding the source of the problem than you did.  I was just putting the finishing touches on it when I got this.  Yours is more through than mine, so I won't bother finishing.\n\n~~ Brian\n"},{"id":"151548","messageId":"UNSmPBO95_JSGKkZEyMl028XH9fmWCis39YCV_49wZs7FghyXRqw2Q@cipher.nrlssc.navy.mil","threadId":"25228","inReplyTo":"47BAA71F-CF5C-4A98-BBB9-C502C81E3230@silverinsanity.com","subject":"Re: [PATCH] t/t3903-stash: improve testing of git-stash show","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2010-09-24T20:50:19Z","receivedAt":"2010-09-24T20:50:19Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"On 09/24/2010 03:43 PM, Brian Gernhardt wrote:\n\n>> On 09/24/2010 03:27 PM, Brian Gernhardt wrote:\n>>> I bisected the issue to a9bf09e (detached-stash: simplify git stash show),\n>>> which is when \"git stash show\" started using parse_flags_and_rev (via\n>>> assert_stash_like()).\n>>>\n>>> More worrying to me is that the tests for \"git stash show\" don't bother\n>>> to test the output.  I'll be working on that now.\n>>\n>> I was preparing these tests when your email came in.\n> \n> I spent longer finding the source of the problem than you did.  I was just\n> putting the finishing touches on it when I got this.  Yours is more through\n> than mine, so I won't bother finishing.\n\nI hope you're just abandoning the tests you were creating, and _not_\nabandoning the search for a fix.  The \"solution\" I offered is flawed\nand breaks some of the other tests. :)\n\n-Brandon\n"},{"id":"151556","messageId":"953B8952-8928-43B3-A05D-6AEDC5D4B565@gernhardtsoftware.com","threadId":"25228","inReplyTo":"UNSmPBO95_JSGKkZEyMl028XH9fmWCis39YCV_49wZs7FghyXRqw2Q@cipher.nrlssc.navy.mil","subject":"Re: [PATCH] t/t3903-stash: improve testing of git-stash show","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2010-09-24T21:49:11Z","receivedAt":"2010-09-24T21:49:11Z","isPatch":true,"sender":{"key":"brian@gernhardtsoftware.com","avatar":"https://avatars.githubusercontent.com/u/133455?v=4"},"body":"\nOn Sep 24, 2010, at 4:50 PM, Brandon Casey wrote:\n\n> I hope you're just abandoning the tests you were creating, and _not_\n> abandoning the search for a fix.  The \"solution\" I offered is flawed\n> and breaks some of the other tests. :)\n\nActually, I think the solution you offered exposed what could be considered a bug in git-rev-parse.  The fact that it worked before was just an happy accident, I think...\n\n$ ARGS=\"-q --index stash@{0}\"\n$ # Get only the revision arguments\n$ git rev-parse --no-flags --symbolic $ARGS\nstash@{0}\n$ # What git-stash currently uses to get flags\n$ git rev-parse --no-revs -- $ARGS\n--\n-q\n--index\nstash@{0}\n$ # That was a lot more than just the flags\n$ # What git-stash \"should\" use to get flags\n$ git rev-parse --no-revs --flags $ARGS\n--index\n$ # Huh, it ate -q, let's try --\n$ git rev-parse --no-revs --flags -- $ARGS\n$ # No, that's not right either...\n\ngit-stash's current code \"FLAGS=$(git rev-parse --no-revs -- \"$@\")\" simply returns all of the arguments including a starting --.  The issue is that git-rev-parse eats a -q parameter.  There's no way to distinguish between arguments for rev-parse and arguments it's supposed to parse.  Generally this isn't an issue.\n\nThe simple way to deal with this is to check for -q before using rev-parse.  The better way is to either get rev-parse to stop eating the -q somehow or to switch git-stash to parseopts.\n\nSimple patch coming soon.\n\n~~ Brian\n"},{"id":"151560","messageId":"1285366305-10086-1-git-send-email-brian@gernhardtsoftware.com","threadId":"25228","inReplyTo":"953B8952-8928-43B3-A05D-6AEDC5D4B565@gernhardtsoftware.com","subject":"[PATCH] git-stash: fix flag parsing","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2010-09-24T22:11:45Z","receivedAt":"2010-09-24T22:11:45Z","isPatch":true,"sender":{"key":"brian@gernhardtsoftware.com","avatar":"https://avatars.githubusercontent.com/u/133455?v=4"},"body":"Currently git-stash uses `git rev-parse --no-revs -- \"$@\"` to set its\nFLAGS variable.  This is the same as `FLAGS=\"-- $@\"`.  It should use\n`git rev-parse --no-revs --flags \"$@\"`, but that eats any \"-q\" or\n\"--quiet\" argument.  So move the check for quiet before rev-parse.\n\nSigned-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>\n---\n\n Not the most elegant solution, but it works.\n\n I think we want to add the ability for git rev-parse to understand\n `git rev-parse --no-revs --flags -- \"$@\"`, but I'm not sure if that\n would break anything else and don't have the time to do it right now.\n\n git-stash.sh     |   15 +++++++++++----\n t/t3903-stash.sh |    8 ++++----\n 2 files changed, 15 insertions(+), 8 deletions(-)\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 7ce818b..b44da41 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -264,8 +264,18 @@ parse_flags_and_rev()\n \tb_tree=\n \ti_tree=\n \n+\t# Work around rev-parse --flags eating -q\n+\tfor opt\n+\tdo\n+\t\tcase \"$opt\" in\n+\t\t\t-q|--quiet)\n+\t\t\t\tGIT_QUIET=t\n+\t\t\t;;\n+\t\tesac\n+\tdone\n+\n \tREV=$(git rev-parse --no-flags --symbolic \"$@\" 2>/dev/null)\n-\tFLAGS=$(git rev-parse --no-revs -- \"$@\" 2>/dev/null)\n+\tFLAGS=$(git rev-parse --no-revs --flags \"$@\" 2>/dev/null)\n \n \tset -- $FLAGS\n \n@@ -273,9 +283,6 @@ parse_flags_and_rev()\n \twhile test $# -ne 0\n \tdo\n \t\tcase \"$1\" in\n-\t\t\t-q|--quiet)\n-\t\t\t\tGIT_QUIET=-t\n-\t\t\t;;\n \t\t\t--index)\n \t\t\t\tINDEX_OPTION=--index\n \t\t\t;;\ndiff --git a/t/t3903-stash.sh b/t/t3903-stash.sh\nindex e8a7338..9ed2396 100755\n--- a/t/t3903-stash.sh\n+++ b/t/t3903-stash.sh\n@@ -406,7 +406,7 @@ test_expect_success 'stash branch - stashes on stack, stash-like argument' '\n \ttest $(git ls-files --modified | wc -l) -eq 1\n '\n \n-test_expect_failure 'stash show - stashes on stack, stash-like argument' '\n+test_expect_success 'stash show - stashes on stack, stash-like argument' '\n \tgit stash clear &&\n \ttest_when_finished \"git reset --hard HEAD\" &&\n \tgit reset --hard &&\n@@ -424,7 +424,7 @@ test_expect_failure 'stash show - stashes on stack, stash-like argument' '\n \ttest_cmp expected actual\n '\n \n-test_expect_failure 'stash show -p - stashes on stack, stash-like argument' '\n+test_expect_success 'stash show -p - stashes on stack, stash-like argument' '\n \tgit stash clear &&\n \ttest_when_finished \"git reset --hard HEAD\" &&\n \tgit reset --hard &&\n@@ -447,7 +447,7 @@ test_expect_failure 'stash show -p - stashes on stack, stash-like argument' '\n \ttest_cmp expected actual\n '\n \n-test_expect_failure 'stash show - no stashes on stack, stash-like argument' '\n+test_expect_success 'stash show - no stashes on stack, stash-like argument' '\n \tgit stash clear &&\n \ttest_when_finished \"git reset --hard HEAD\" &&\n \tgit reset --hard &&\n@@ -462,7 +462,7 @@ test_expect_failure 'stash show - no stashes on stack, stash-like argument' '\n \ttest_cmp expected actual\n '\n \n-test_expect_failure 'stash show -p - no stashes on stack, stash-like argument' '\n+test_expect_success 'stash show -p - no stashes on stack, stash-like argument' '\n \tgit stash clear &&\n \ttest_when_finished \"git reset --hard HEAD\" &&\n \tgit reset --hard &&\n-- \n1.7.3.234.g7bba3\n"},{"id":"151561","messageId":"1285366534-10490-1-git-send-email-brian@gernhardtsoftware.com","threadId":"25228","inReplyTo":"953B8952-8928-43B3-A05D-6AEDC5D4B565@gernhardtsoftware.com","subject":"[PATCH] git-stash: fix flag parsing","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2010-09-24T22:15:34Z","receivedAt":"2010-09-24T22:15:34Z","isPatch":true,"sender":{"key":"brian@gernhardtsoftware.com","avatar":"https://avatars.githubusercontent.com/u/133455?v=4"},"body":"Currently git-stash uses `git rev-parse --no-revs -- \"$@\"` to set its\nFLAGS variable.  This is the same as `FLAGS=\"-- $@\"`.  It should use\n`git rev-parse --no-revs --flags \"$@\"`, but that eats any \"-q\" or\n\"--quiet\" argument.  So move the check for quiet before rev-parse.\n\nSigned-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>\n---\n\n Not the most elegant solution, but it works.\n\n I think we want to add the ability for git rev-parse to understand\n `git rev-parse --no-revs --flags -- \"$@\"`, but I'm not sure if that\n would break anything else and don't have the time to do it right now.\n\n (This time with the right CC list.)\n\n git-stash.sh     |   15 +++++++++++----\n t/t3903-stash.sh |    8 ++++----\n 2 files changed, 15 insertions(+), 8 deletions(-)\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 7ce818b..b44da41 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -264,8 +264,18 @@ parse_flags_and_rev()\n \tb_tree=\n \ti_tree=\n \n+\t# Work around rev-parse --flags eating -q\n+\tfor opt\n+\tdo\n+\t\tcase \"$opt\" in\n+\t\t\t-q|--quiet)\n+\t\t\t\tGIT_QUIET=t\n+\t\t\t;;\n+\t\tesac\n+\tdone\n+\n \tREV=$(git rev-parse --no-flags --symbolic \"$@\" 2>/dev/null)\n-\tFLAGS=$(git rev-parse --no-revs -- \"$@\" 2>/dev/null)\n+\tFLAGS=$(git rev-parse --no-revs --flags \"$@\" 2>/dev/null)\n \n \tset -- $FLAGS\n \n@@ -273,9 +283,6 @@ parse_flags_and_rev()\n \twhile test $# -ne 0\n \tdo\n \t\tcase \"$1\" in\n-\t\t\t-q|--quiet)\n-\t\t\t\tGIT_QUIET=-t\n-\t\t\t;;\n \t\t\t--index)\n \t\t\t\tINDEX_OPTION=--index\n \t\t\t;;\ndiff --git a/t/t3903-stash.sh b/t/t3903-stash.sh\nindex e8a7338..9ed2396 100755\n--- a/t/t3903-stash.sh\n+++ b/t/t3903-stash.sh\n@@ -406,7 +406,7 @@ test_expect_success 'stash branch - stashes on stack, stash-like argument' '\n \ttest $(git ls-files --modified | wc -l) -eq 1\n '\n \n-test_expect_failure 'stash show - stashes on stack, stash-like argument' '\n+test_expect_success 'stash show - stashes on stack, stash-like argument' '\n \tgit stash clear &&\n \ttest_when_finished \"git reset --hard HEAD\" &&\n \tgit reset --hard &&\n@@ -424,7 +424,7 @@ test_expect_failure 'stash show - stashes on stack, stash-like argument' '\n \ttest_cmp expected actual\n '\n \n-test_expect_failure 'stash show -p - stashes on stack, stash-like argument' '\n+test_expect_success 'stash show -p - stashes on stack, stash-like argument' '\n \tgit stash clear &&\n \ttest_when_finished \"git reset --hard HEAD\" &&\n \tgit reset --hard &&\n@@ -447,7 +447,7 @@ test_expect_failure 'stash show -p - stashes on stack, stash-like argument' '\n \ttest_cmp expected actual\n '\n \n-test_expect_failure 'stash show - no stashes on stack, stash-like argument' '\n+test_expect_success 'stash show - no stashes on stack, stash-like argument' '\n \tgit stash clear &&\n \ttest_when_finished \"git reset --hard HEAD\" &&\n \tgit reset --hard &&\n@@ -462,7 +462,7 @@ test_expect_failure 'stash show - no stashes on stack, stash-like argument' '\n \ttest_cmp expected actual\n '\n \n-test_expect_failure 'stash show -p - no stashes on stack, stash-like argument' '\n+test_expect_success 'stash show -p - no stashes on stack, stash-like argument' '\n \tgit stash clear &&\n \ttest_when_finished \"git reset --hard HEAD\" &&\n \tgit reset --hard &&\n-- \n1.7.3.234.g7bba3\n"},{"id":"151597","messageId":"1285383273-28378-1-git-send-email-jon.seymour@gmail.com","threadId":"25228","inReplyTo":"robbat2-20100924T191752-102740530Z@orbis-terrarum.net","subject":"[PATCH] stash show: fix breakage in 1.7.3","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-25T02:54:33Z","receivedAt":"2010-09-25T02:54:33Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"The detached-stash series regressed support for\n   git stash show stash@{0}\n\ndue to a faulty assumption that\ngit rev-parse --no-revs stash@{0} would treat\nstash@{0} as a revision reference and thus\nnot display it.\n\nThis patch restores the behaviour of git stash show\nso that only flag like options are assigned\nto the FLAGS variable and thus does not\ndepend git rev-parse behaviour so strongly.\n\nIt has been tested with Brandon Casey's improved t3903 tests.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n Apologies for the breakage.\n Brandon: thanks for improving the tests.\n\n git-stash.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 7ce818b..c2f1b2a 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -282,7 +282,7 @@ parse_flags_and_rev()\n \t\t\t--)\n \t\t\t\t:\n \t\t\t;;\n-\t\t\t*)\n+\t\t\t-*)\n \t\t\t\tFLAGS=\"${FLAGS}${FLAGS:+ }$1\"\n \t\t\t;;\n \t\tesac\n-- \n1.7.2.12.g8788e.dirty\n"},{"id":"151598","messageId":"AANLkTim_sNJYRuAB35GTT-2YXY9oJ8rEWsCgO8qv-6nf@mail.gmail.com","threadId":"25228","inReplyTo":"1285366534-10490-1-git-send-email-brian@gernhardtsoftware.com","subject":"Re: [PATCH] git-stash: fix flag parsing","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-25T02:58:24Z","receivedAt":"2010-09-25T02:58:24Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Thanks Brian. I've submitted what I hope is the simplest possible\nrectification of my regression - apologies for not catching this\nmyself!\n\njon.\n\nOn Sat, Sep 25, 2010 at 8:15 AM, Brian Gernhardt\n<brian@gernhardtsoftware.com> wrote:\n> Currently git-stash uses `git rev-parse --no-revs -- \"$@\"` to set its\n> FLAGS variable.  This is the same as `FLAGS=\"-- $@\"`.  It should use\n> `git rev-parse --no-revs --flags \"$@\"`, but that eats any \"-q\" or\n> \"--quiet\" argument.  So move the check for quiet before rev-parse.\n>\n> Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>\n> ---\n>\n>  Not the most elegant solution, but it works.\n>\n>  I think we want to add the ability for git rev-parse to understand\n>  `git rev-parse --no-revs --flags -- \"$@\"`, but I'm not sure if that\n>  would break anything else and don't have the time to do it right now.\n>\n>  (This time with the right CC list.)\n>\n>  git-stash.sh     |   15 +++++++++++----\n>  t/t3903-stash.sh |    8 ++++----\n>  2 files changed, 15 insertions(+), 8 deletions(-)\n>\n> diff --git a/git-stash.sh b/git-stash.sh\n> index 7ce818b..b44da41 100755\n> --- a/git-stash.sh\n> +++ b/git-stash.sh\n> @@ -264,8 +264,18 @@ parse_flags_and_rev()\n>        b_tree=\n>        i_tree=\n>\n> +       # Work around rev-parse --flags eating -q\n> +       for opt\n> +       do\n> +               case \"$opt\" in\n> +                       -q|--quiet)\n> +                               GIT_QUIET=t\n> +                       ;;\n> +               esac\n> +       done\n> +\n>        REV=$(git rev-parse --no-flags --symbolic \"$@\" 2>/dev/null)\n> -       FLAGS=$(git rev-parse --no-revs -- \"$@\" 2>/dev/null)\n> +       FLAGS=$(git rev-parse --no-revs --flags \"$@\" 2>/dev/null)\n>\n>        set -- $FLAGS\n>\n> @@ -273,9 +283,6 @@ parse_flags_and_rev()\n>        while test $# -ne 0\n>        do\n>                case \"$1\" in\n> -                       -q|--quiet)\n> -                               GIT_QUIET=-t\n> -                       ;;\n>                        --index)\n>                                INDEX_OPTION=--index\n>                        ;;\n> diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh\n> index e8a7338..9ed2396 100755\n> --- a/t/t3903-stash.sh\n> +++ b/t/t3903-stash.sh\n> @@ -406,7 +406,7 @@ test_expect_success 'stash branch - stashes on stack, stash-like argument' '\n>        test $(git ls-files --modified | wc -l) -eq 1\n>  '\n>\n> -test_expect_failure 'stash show - stashes on stack, stash-like argument' '\n> +test_expect_success 'stash show - stashes on stack, stash-like argument' '\n>        git stash clear &&\n>        test_when_finished \"git reset --hard HEAD\" &&\n>        git reset --hard &&\n> @@ -424,7 +424,7 @@ test_expect_failure 'stash show - stashes on stack, stash-like argument' '\n>        test_cmp expected actual\n>  '\n>\n> -test_expect_failure 'stash show -p - stashes on stack, stash-like argument' '\n> +test_expect_success 'stash show -p - stashes on stack, stash-like argument' '\n>        git stash clear &&\n>        test_when_finished \"git reset --hard HEAD\" &&\n>        git reset --hard &&\n> @@ -447,7 +447,7 @@ test_expect_failure 'stash show -p - stashes on stack, stash-like argument' '\n>        test_cmp expected actual\n>  '\n>\n> -test_expect_failure 'stash show - no stashes on stack, stash-like argument' '\n> +test_expect_success 'stash show - no stashes on stack, stash-like argument' '\n>        git stash clear &&\n>        test_when_finished \"git reset --hard HEAD\" &&\n>        git reset --hard &&\n> @@ -462,7 +462,7 @@ test_expect_failure 'stash show - no stashes on stack, stash-like argument' '\n>        test_cmp expected actual\n>  '\n>\n> -test_expect_failure 'stash show -p - no stashes on stack, stash-like argument' '\n> +test_expect_success 'stash show -p - no stashes on stack, stash-like argument' '\n>        git stash clear &&\n>        test_when_finished \"git reset --hard HEAD\" &&\n>        git reset --hard &&\n> --\n> 1.7.3.234.g7bba3\n>\n>\n"},{"id":"151601","messageId":"1285385521-17012-1-git-send-email-jon.seymour@gmail.com","threadId":"25228","inReplyTo":"robbat2-20100924T191752-102740530Z@orbis-terrarum.net","subject":"[PATCH v1] stash show: fix breakage in 1.7.3","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-25T03:32:01Z","receivedAt":"2010-09-25T03:32:01Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"The detached-stash series regressed support for\n   git stash show stash@{0}\n\ndue to a faulty assumption that:\n   git rev-parse --no-revs -- stash@{0}\n\nwould treat stash@{0} as a revision reference and\nthus not output it.\n\nThis patch restores the behaviour of git stash show\nso that git rev-parse is not used for parsing flags\nand only flag like options are assigned to\nthe FLAGS variable.\n\nIt has been tested with Brandon Casey's improved t3903 tests.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n git-stash.sh |    5 +----\n 1 files changed, 1 insertions(+), 4 deletions(-)\n\nThis revision further simplifies the parsing code\nby removing use of git rev-parse for FLAGS parsing\naltogether.\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 7ce818b..8b18bb5 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -265,9 +265,6 @@ parse_flags_and_rev()\n \ti_tree=\n \n \tREV=$(git rev-parse --no-flags --symbolic \"$@\" 2>/dev/null)\n-\tFLAGS=$(git rev-parse --no-revs -- \"$@\" 2>/dev/null)\n-\n-\tset -- $FLAGS\n \n \tFLAGS=\n \twhile test $# -ne 0\n@@ -282,7 +279,7 @@ parse_flags_and_rev()\n \t\t\t--)\n \t\t\t\t:\n \t\t\t;;\n-\t\t\t*)\n+\t\t\t-*)\n \t\t\t\tFLAGS=\"${FLAGS}${FLAGS:+ }$1\"\n \t\t\t;;\n \t\tesac\n-- \n1.7.2.14.g132f5.dirty\n"},{"id":"151607","messageId":"AF7816CF-7515-4386-9736-417005434433@gernhardtsoftware.com","threadId":"25228","inReplyTo":"1285385521-17012-1-git-send-email-jon.seymour@gmail.com","subject":"Re: [PATCH v1] stash show: fix breakage in 1.7.3","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2010-09-25T04:45:42Z","receivedAt":"2010-09-25T04:45:42Z","isPatch":true,"sender":{"key":"brian@gernhardtsoftware.com","avatar":"https://avatars.githubusercontent.com/u/133455?v=4"},"body":"\nOn Sep 24, 2010, at 11:32 PM, Jon Seymour wrote:\n\n> due to a faulty assumption that:\n>   git rev-parse --no-revs -- stash@{0}\n\nThis assumption is faulty, it should be \"git rev-parse --no-revs --flags stash@{0}\", which works properly for all revision arguments and flags _except_ -q and --quiet.\n\n> This revision further simplifies the parsing code\n> by removing use of git rev-parse for FLAGS parsing\n> altogether.\n\nThat is simpler, and does fix this specific issue.  However, I would strongly argue that \"git rev-parse --no-revs --flags\" is broken.  I really don't have the time tonight or probably this weekend to work on it, but git-rev-parse should only take \"-q\" and \"--quiet\" for itself if \"--verify\" was passed.  (Since that is the only mode in which rev-parse uses quiet, AFAIK.)\n\nPossibly rev-parse should also (or instead) separate \"arguments for rev-parse\" and \"arguments rev-parse is parsing\" using the standard \"--\".  I don't know if this will affect any current users.\n\n~~ Brian\n"},{"id":"151614","messageId":"AANLkTimK4nTr9bS0L9xc9mGo5F900pUAOQoDnZ9HMdEz@mail.gmail.com","threadId":"25228","inReplyTo":"AF7816CF-7515-4386-9736-417005434433@gernhardtsoftware.com","subject":"Re: [PATCH v1] stash show: fix breakage in 1.7.3","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-25T06:19:50Z","receivedAt":"2010-09-25T06:19:50Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"On Sat, Sep 25, 2010 at 2:45 PM, Brian Gernhardt\n<brian@gernhardtsoftware.com> wrote:\n>\n> On Sep 24, 2010, at 11:32 PM, Jon Seymour wrote:\n>\n>> due to a faulty assumption that:\n>>   git rev-parse --no-revs -- stash@{0}\n>\n> This assumption is faulty, it should be \"git rev-parse --no-revs --flags stash@{0}\", which works properly for all revision arguments and flags _except_ -q and --quiet.\n\nAgreed. If I recall the evolution of the code, I originally had\n--no-revs --flags, but then found -q was being eaten. The only way to\nprevent it being eaten was to remove --flags and add --, which \"fixed\"\nthe -q problem but created the git stash show xxx problem. Of course,\nhad my unit tests been more thorough, I would have picked this, but\nalas they were not.\n\n>\n>> This revision further simplifies the parsing code\n>> by removing use of git rev-parse for FLAGS parsing\n>> altogether.\n>\n> That is simpler, and does fix this specific issue.  However, I would strongly argue that \"git rev-parse --no-revs --flags\" is broken.  I really don't have the time tonight or probably this weekend to work on it, but git-rev-parse should only take \"-q\" and \"--quiet\" for itself if \"--verify\" was passed.  (Since that is the only mode in which rev-parse uses quiet, AFAIK.)\n>\n\nThis seems like a reasonable compromise to me.\n\n> Possibly rev-parse should also (or instead) separate \"arguments for rev-parse\" and \"arguments rev-parse is parsing\" using the standard \"--\".  I don't know if this will affect any current users.\n>\n\nI suspect this could be problematic.\n\nCurrent behaviour:\n\n   $ git rev-parse --flags -X -- Y -Z\n   -X\n\nHere -- is being used to say, don't interpret anything after -- as\nbeing flag-like even if it could be flag-like.\n\nSo, if a command foo uses git rev-parse to parse its own arguments:\n\n    foo -X -- Y -Z\n\nthen I suspect, it would only want to treat -X as being flag-like,\nfrom the user of foo's point of view, both Y and -Z are not meant to\nbe interpreted by foo.\n\nIt might make sense for --flags to be an instruction to git rev-parse\nnot to interpret any subsequent arguments as git rev-parse options so\nthat:\n\n  $ git rev-parse --flags -q --no-flags -- --revs-only\n\nwould output:\n\n  -q --no-flags\n\nThat is, prevent -q being eaten by git rev-parse, but preserve\nexisting interpretation of --.\n\n> ~~ Brian\n>\n>\n"},{"id":"151615","messageId":"AANLkTikmCR+fYJfYU9RidnD143BsEA-Lz+V8jEO_hs-y@mail.gmail.com","threadId":"25228","inReplyTo":"1285385521-17012-1-git-send-email-jon.seymour@gmail.com","subject":"Re: [PATCH v1] stash show: fix breakage in 1.7.3","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-25T07:15:14Z","receivedAt":"2010-09-25T07:15:14Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"| Added Brandon to distribution - apologies for earlier omission.\n\njon.\n\nOn Sat, Sep 25, 2010 at 1:32 PM, Jon Seymour <jon.seymour@gmail.com> wrote:\n> The detached-stash series regressed support for\n>   git stash show stash@{0}\n>\n> due to a faulty assumption that:\n>   git rev-parse --no-revs -- stash@{0}\n>\n> would treat stash@{0} as a revision reference and\n> thus not output it.\n>\n> This patch restores the behaviour of git stash show\n> so that git rev-parse is not used for parsing flags\n> and only flag like options are assigned to\n> the FLAGS variable.\n>\n> It has been tested with Brandon Casey's improved t3903 tests.\n>\n> Signed-off-by: Jon Seymour <jon.seymour@gmail.com>\n> ---\n>  git-stash.sh |    5 +----\n>  1 files changed, 1 insertions(+), 4 deletions(-)\n>\n> This revision further simplifies the parsing code\n> by removing use of git rev-parse for FLAGS parsing\n> altogether.\n>\n> diff --git a/git-stash.sh b/git-stash.sh\n> index 7ce818b..8b18bb5 100755\n> --- a/git-stash.sh\n> +++ b/git-stash.sh\n> @@ -265,9 +265,6 @@ parse_flags_and_rev()\n>        i_tree=\n>\n>        REV=$(git rev-parse --no-flags --symbolic \"$@\" 2>/dev/null)\n> -       FLAGS=$(git rev-parse --no-revs -- \"$@\" 2>/dev/null)\n> -\n> -       set -- $FLAGS\n>\n>        FLAGS=\n>        while test $# -ne 0\n> @@ -282,7 +279,7 @@ parse_flags_and_rev()\n>                        --)\n>                                :\n>                        ;;\n> -                       *)\n> +                       -*)\n>                                FLAGS=\"${FLAGS}${FLAGS:+ }$1\"\n>                        ;;\n>                esac\n> --\n> 1.7.2.14.g132f5.dirty\n>\n>\n"},{"id":"151616","messageId":"1285399156-21792-1-git-send-email-jon.seymour@gmail.com","threadId":"25228","inReplyTo":"robbat2-20100924T191752-102740530Z@orbis-terrarum.net","subject":"[PATCH/RFC] rev-parse: stop interpreting flags as options to rev-parse once --flags is specified","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-25T07:19:16Z","receivedAt":"2010-09-25T07:19:16Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Current git rev-parse behaviour makes --flags hard to use if the remaining\narguments to git rev-parse contain an option that would otherwise be interpreted\nas an option by git rev-parse itself.\n\nSo, for example:\n\n  $> git rev-parse --flags -q -X\n  -X\n\nNormally one might expect to use -- to prevent -q being interpreted:\n\n  $> git rev-parse --flags -- -q -X\n  -q -X\n\nBut we can't really use -- in this way, because commands that use\ngit rev-parse might reasonably expect:\n\n  $> git rev-parse --flags -Y -- -q -X\n  -Y\n\nThat is, -Y to be regarded as a flag but everything after -- to be uninterpreted.\n\nThis proposed change modifies git rev-parse so that git rev-parse stops\ninterpreting flag arguments as options to git rev-parse once --flags is\ninterpreted. We also exit early once -- is found.\n\nTests will follow in subsequent iterations of this patch, if the consensus\nis that the approach is correct.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n builtin/rev-parse.c |    7 +++++++\n 1 files changed, 7 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex a5a1c86..9e340c7 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -497,8 +497,15 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \t\t\t\t/* Pass on the \"--\" if we show anything but files.. */\n \t\t\t\tif (filter & (DO_FLAGS | DO_REVS))\n \t\t\t\t\tshow_file(arg);\n+\t\t\t\tif (!(filter & DO_NONFLAGS)) {\n+\t\t\t\t\treturn 0;\n+\t\t\t\t}\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!(filter & DO_NONFLAGS)) {\n+\t\t\t\t show_flag(arg);\n+\t\t\t\t continue;\n+\t\t\t}\n \t\t\tif (!strcmp(arg, \"--default\")) {\n \t\t\t\tdef = argv[i+1];\n \t\t\t\ti++;\n-- \n1.7.2.14.gbde03.dirty\n"},{"id":"151617","messageId":"AANLkTi=8gv5arpdOVGHvf7sjNd==G=a4HoBBTbizq=OK@mail.gmail.com","threadId":"25228","inReplyTo":"1285399156-21792-1-git-send-email-jon.seymour@gmail.com","subject":"Re: [PATCH/RFC] rev-parse: stop interpreting flags as options to rev-parse once --flags is specified","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-25T07:19:45Z","receivedAt":"2010-09-25T07:19:45Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"On Sat, Sep 25, 2010 at 5:19 PM, Jon Seymour <jon.seymour@gmail.com> wrote:\n> Current git rev-parse behaviour makes --flags hard to use if the remaining\n> ...\n\nNote that I haven't run the test suite yet to see if it breaks\nanything. I'd also\nexpect to write additional tests and update the documentation.\n\njon.\n"},{"id":"151618","messageId":"AANLkTim0oxhgtgqbrqP-jDL29jj0y=h6BLssEAFzags9@mail.gmail.com","threadId":"25228","inReplyTo":"AANLkTi=8gv5arpdOVGHvf7sjNd==G=a4HoBBTbizq=OK@mail.gmail.com","subject":"Re: [PATCH/RFC] rev-parse: stop interpreting flags as options to rev-parse once --flags is specified","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-25T07:25:16Z","receivedAt":"2010-09-25T07:25:16Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"On Sat, Sep 25, 2010 at 5:19 PM, Jon Seymour <jon.seymour@gmail.com> wrote:\n> On Sat, Sep 25, 2010 at 5:19 PM, Jon Seymour <jon.seymour@gmail.com> wrote:\n>> Current git rev-parse behaviour makes --flags hard to use if the remaining\n>> ...\n>\n> Note that I haven't run the test suite yet to see if it breaks\n> anything. I'd also\n> expect to write additional tests and update the documentation.\n>\n> jon.\n>\n\nMmmm...almost certainly not going to regress anything, since there\ndoes not seem to be a test or script that uses --flags. Ahem.\n\njon.\n"},{"id":"151703","messageId":"7v1v8hnflx.fsf@alter.siamese.dyndns.org","threadId":"25228","inReplyTo":"AANLkTim0oxhgtgqbrqP-jDL29jj0y=h6BLssEAFzags9@mail.gmail.com","subject":"Re: [PATCH/RFC] rev-parse: stop interpreting flags as options to rev-parse once --flags is specified","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-09-26T07:11:54Z","receivedAt":"2010-09-26T07:11:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jon Seymour <jon.seymour@gmail.com> writes:\n\n> Mmmm...almost certainly not going to regress anything, since there\n> does not seem to be a test or script that uses --flags. Ahem.\n\nI've already explained the historical background in a separate message; I\nrealize that my message was missing the important part: conclusion.\n\nIf there weren't rev-parse before and we were about to invent the command,\nI would agree that --flags should suppress output of HEAD.  Also I doubt\nanybody relies on --flags for the purpose of removing non-revision\narguments.  So in that sense, your change would not hurt people.\n\nBut I do not think encouraging the use of rev-parse to pick \"flags\" is a\ngood idea in the longer term anyway, so I do not care too much about this\nissue.  Unless you will teach \"rev-parse --flags\" about all the options\nall other git command take (e.g. it should know --ignore-submodule takes\nan optional option argument and be able to parse \"--ignore-submodule all\"\nout), which is fundamentally impossible (e.g. for some commands \"-n\" does\nnot take argument, for some other \"-n\" takes an integer argument, and the\nrev-parse command fundamentally cannot decide if it should report what\nfollows \"-n\" as part of its \"--flags\" output).\n"},{"id":"151716","messageId":"AANLkTinQU3aoyBtD9-mSm_Oq5xiqNxmfJ-CncFgN1G07@mail.gmail.com","threadId":"25228","inReplyTo":"7v1v8hnflx.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH/RFC] rev-parse: stop interpreting flags as options to rev-parse once --flags is specified","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-26T14:39:54Z","receivedAt":"2010-09-26T14:39:54Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"On Sun, Sep 26, 2010 at 5:11 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Jon Seymour <jon.seymour@gmail.com> writes:\n>\n>> Mmmm...almost certainly not going to regress anything, since there\n>> does not seem to be a test or script that uses --flags. Ahem.\n>\n> I've already explained the historical background in a separate message; I\n> realize that my message was missing the important part: conclusion.\n>\n> If there weren't rev-parse before and we were about to invent the command,\n> I would agree that --flags should suppress output of HEAD.  Also I doubt\n> anybody relies on --flags for the purpose of removing non-revision\n> arguments.  So in that sense, your change would not hurt people.\n>\n> But I do not think encouraging the use of rev-parse to pick \"flags\" is a\n> good idea in the longer term anyway, so I do not care too much about this\n> issue.  Unless you will teach \"rev-parse --flags\" about all the options\n> all other git command take (e.g. it should know --ignore-submodule takes\n> an optional option argument and be able to parse \"--ignore-submodule all\"\n> out), which is fundamentally impossible (e.g. for some commands \"-n\" does\n> not take argument, for some other \"-n\" takes an integer argument, and the\n> rev-parse command fundamentally cannot decide if it should report what\n> follows \"-n\" as part of its \"--flags\" output).\n>\n\nOk, so I have withdrawn the patch that makes --flags imply --no-revs.\n\nv7 has 3 commits. The first commit documents existing behaviour more\naccurately. The second commit adds a test suite for existing\nbehaviour.\n\nI am offering the 3rd commit for discussion since your comments to\ndate have not directly addressed this commit. To recap, this commit\ncauses rev-parse to stop interpreting options once --flags is\ninterpreted.\n\nFor example, this would allow:\n\n$ git rev-parse --flags --all\n--all\n$\n\nwhereas currently:\n\n$ git rev-parse --flags --all\n .. list of revisions ..\n$\n\nAs it stands, --flags really can't be used for any useful purpose. It\ncan't be used to output arbitrary flag or rev-like arguments\ncompatible with rev-list because it eats --all for itself. it can't be\nused with any option that it also recognises (such as -q).\n\nThis being the case, one has to wonder whether we shouldn't just\ndeprecate --flags so that people don't waste time trying to use it.\n\njon.\n"},{"id":"151717","messageId":"1285512247-15600-1-git-send-email-jon.seymour@gmail.com","threadId":"25228","inReplyTo":"7v1v8hnflx.fsf@alter.siamese.dyndns.org","subject":"[PATCH v7 0/3] rev-parse: allow --flags to output rev-parse-like flags","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-26T14:44:04Z","receivedAt":"2010-09-26T14:44:04Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"This series allows git rev-parse --flags to output remaining flag-like arguments\neven if such arguments are valid options to git rev-parse itself.\n\nPreviously:\n  $ git rev-parse --flags -q -X --no-flags -- Y -Z\n  -X\n  $\n\nNow:\n  $ git rev-parse --flags -q -X --no-flags -- Y -Z\n  -q -X --no-flags\n  $\n\nAevar's feedback on v2 and v4 of this series has been incorporated.\n\nThe first commit modifies the documentation so that it accurately\nreflects the current implementation.\n\nThe second commit introduces tests that document existing behaviour.\n\nThe third commit changes the way git rev-parse interprets option-like\narguments after the first --flags option is processed.\n\nThe first and second commits should be non-controversial since they\nmerely document and test existing behaviour. The third commit\nis offered for discussion.\n\nv7 removes the patch that made --flags imply --no-revs.\n\nJon Seymour (3):\n  rev-parse: update Documentation of --flags\n  rev-parse: add tests for git rev-parse --flags.\n  rev-parse: stop interpreting flags as options to rev-parse once\n    --flags is specified\n\n Documentation/git-rev-parse.txt |   12 +++-\n builtin/rev-parse.c             |    8 ++\n t/t1510-rev-parse-flags.sh      |  172 +++++++++++++++++++++++++++++++++++++++\n 3 files changed, 191 insertions(+), 1 deletions(-)\n create mode 100755 t/t1510-rev-parse-flags.sh\n\n-- \n1.7.3.3.g9129b6\n"},{"id":"151718","messageId":"1285512247-15600-2-git-send-email-jon.seymour@gmail.com","threadId":"25228","inReplyTo":"7v1v8hnflx.fsf@alter.siamese.dyndns.org","subject":"[PATCH v7 1/3] rev-parse: update Documentation of --flags","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-26T14:44:05Z","receivedAt":"2010-09-26T14:44:05Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"This change updates the documentation of git rev-parse --flags\nso that the documentation accurately matches the current\nimplementation.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n Documentation/git-rev-parse.txt |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt\nindex 341ca90..27d15b0 100644\n--- a/Documentation/git-rev-parse.txt\n+++ b/Documentation/git-rev-parse.txt\n@@ -49,7 +49,10 @@ OPTIONS\n \t'git rev-list' command.\n \n --flags::\n-\tDo not output non-flag parameters.\n+\tOutput any flag and revision-like values in the remaining parameters.\n++\n+Note that any parameter which is also a valid 'git rev-parse' option\n+will be interpreted as an option to 'git rev-parse' and thus will not be output.\n \n --no-flags::\n \tDo not output flag parameters.\n-- \n1.7.3.3.g9129b6\n"},{"id":"151719","messageId":"1285512247-15600-3-git-send-email-jon.seymour@gmail.com","threadId":"25228","inReplyTo":"7v1v8hnflx.fsf@alter.siamese.dyndns.org","subject":"[PATCH v7 2/3] rev-parse: add tests for git rev-parse --flags.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-26T14:44:06Z","receivedAt":"2010-09-26T14:44:06Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Signed-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n t/t1510-rev-parse-flags.sh |  174 ++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 174 insertions(+), 0 deletions(-)\n create mode 100755 t/t1510-rev-parse-flags.sh\n\ndiff --git a/t/t1510-rev-parse-flags.sh b/t/t1510-rev-parse-flags.sh\nnew file mode 100755\nindex 0000000..e327b96\n--- /dev/null\n+++ b/t/t1510-rev-parse-flags.sh\n@@ -0,0 +1,174 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2010 Jon Seymour\n+#\n+\n+test_description='test git rev-parse --flags'\n+. ./test-lib.sh\n+\n+test_commit \"A\"\n+\n+test_expect_success 'git rev-parse --flags -> \"\"' \\\n+'\n+\t>expected &&\n+\tgit rev-parse --flags >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --flags X -> \"\"' \\\n+'\n+\t>expected &&\n+\tgit rev-parse --flags X >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --no-revs --flags HEAD -> \"\"' \\\n+'\n+\t>expected &&\n+\tgit rev-parse --no-revs --flags HEAD >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --flags HEAD -> sha1 of HEAD' \\\n+'\n+\tgit rev-parse HEAD > expected &&\n+\tgit rev-parse --flags HEAD >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --flags -- -> \"\"' \\\n+'\n+\t>expected &&\n+\tgit rev-parse --flags -- >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --flags -- X -> \"\"' \\\n+'\n+\t>expected &&\n+\tgit rev-parse --flags -- X >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --flags -- -X -> \"\"' \\\n+'\n+\t>expected &&\n+\tgit rev-parse --flags -- -X >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --flags -- -q --> \"\"' \\\n+'\n+\t>expected &&\n+\tgit rev-parse --flags -- -q >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --flags -X -> \"-X\"' \\\n+'\n+\tprintf \"%s\\n\" -X > expected &&\n+\tgit rev-parse --flags -X >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --flags -X -- Y -Z -> \"-X\"' \\\n+'\n+\tprintf \"%s\\n\" -X > expected &&\n+\tgit rev-parse --flags -X -- Y -Z >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --no-flags --flags -X -> \"\"' \\\n+'\n+\t>expected &&\n+\tgit rev-parse --no-flags --flags -X >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --symbolic --no-flags --flags HEAD -> \"HEAD\"' \\\n+'\n+\techo HEAD >expected &&\n+\tgit rev-parse --symbolic --no-flags --flags HEAD >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --flags -q -> \"\"' \\\n+'\n+\t>expected &&\n+\tgit rev-parse --flags -q >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --flags --no-flags -> \"\"' \\\n+'\n+\t>expected &&\n+\tgit rev-parse --flags --no-flags >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --no-revs file -> \"file\"' \\\n+'\n+\techo foo >file &&\n+\techo file >expected &&\n+\tgit rev-parse --no-revs file >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --flags -X file -> \"-X\"' \\\n+'\n+\techo foo >file &&\n+\tprintf \"%s\\n\" \"-X\" >expected &&\n+\tgit rev-parse --flags -X file >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --no-revs -- not-a-file -> \"-- not-a-file\"' \\\n+'\n+\tcat >expected <<-EOF &&\n+--\n+not-a-file\n+\tEOF\n+\tgit rev-parse --no-revs -- not-a-file >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --flags --all -> list of revs' \\\n+'\n+\tcat >expected <<-EOF &&\n+commit\n+\tEOF\n+\tgit cat-file -t $(git rev-parse --flags --all | head -1) >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_failure 'git rev-parse --no-revs --all -> list of revs' \\\n+'\n+\tcat >expected <<-EOF &&\n+commit\n+\tEOF\n+\tgit cat-file -t $(git rev-parse --no-revs --all | head -1) >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --no-revs --min-age=20100203 -> \"\"' \\\n+'\n+\t>expected &&\n+\tgit rev-parse --no-revs --min-age=20100203 > actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --flags --min-age=20100203 -> \"--min-age=20100203\" ' \\\n+'\n+\tprintf \"%s\\n\" \"--min-age=20100203\" >expected &&\n+\tgit rev-parse --flags --min-age=20100203 > actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --no-revs --flags --all -> \"\"' \\\n+'\n+\t>expected &&\n+\tgit rev-parse --no-revs --flags --all >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_done\n-- \n1.7.3.3.g9129b6\n"},{"id":"151720","messageId":"1285512247-15600-4-git-send-email-jon.seymour@gmail.com","threadId":"25228","inReplyTo":"7v1v8hnflx.fsf@alter.siamese.dyndns.org","subject":"[PATCH v7 3/3] rev-parse: stop interpreting flags as options to rev-parse once --flags is specified","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-26T14:44:07Z","receivedAt":"2010-09-26T14:44:07Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Current git rev-parse behaviour makes --flags hard to use if the remaining\narguments to git rev-parse contain an option that would otherwise be interpreted\nas an option by git rev-parse itself.\n\nSo, for example:\n\n  $> git rev-parse --flags -q -X\n  -X\n\nNormally one might expect to use -- to prevent -q being interpreted:\n\n  $> git rev-parse --flags -- -q -X\n  -q -X\n\nBut we can't really use -- in this way, because commands that use\ngit rev-parse might reasonably expect:\n\n  $> git rev-parse --flags -Y -- -q -X\n  -Y\n\nThat is, -Y to be regarded as a flag but everything after -- to be uninterpreted.\n\nThis proposed change modifies git rev-parse so that git rev-parse stops\ninterpreting flag arguments as options to git rev-parse once --flags is\ninterpreted. We also exit early once -- is found.\n\nPreviously:\n $> git rev-parse --flags --all\n {list of sha1 hashes}\n $>\n\nNow:\n $> git rev-parse --flags --all\n --all\n $>\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n Documentation/git-rev-parse.txt |   11 +++++++++--\n builtin/rev-parse.c             |    8 ++++++++\n t/t1510-rev-parse-flags.sh      |   14 ++++++--------\n 3 files changed, 23 insertions(+), 10 deletions(-)\n\ndiff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt\nindex 27d15b0..3eac735 100644\n--- a/Documentation/git-rev-parse.txt\n+++ b/Documentation/git-rev-parse.txt\n@@ -51,11 +51,18 @@ OPTIONS\n --flags::\n \tOutput any flag and revision-like values in the remaining parameters.\n +\n-Note that any parameter which is also a valid 'git rev-parse' option\n-will be interpreted as an option to 'git rev-parse' and thus will not be output.\n+If specified, this option causes 'git rev-parse' to stop\n+interpreting remaining arguments as options for its own\n+consumption. As such, this option should be specified\n+after all other options that 'git rev-parse' is expected\n+to interpret.\n \n --no-flags::\n \tDo not output flag parameters.\n++\n+If both `--flags` and `--no-flags` are specified, the first\n+option specified wins and the other option is treated like\n+a non-option argument.\n \n --default <arg>::\n \tIf there is no parameter given by the user, use `<arg>`\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex a5a1c86..2ad269a 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -497,8 +497,16 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \t\t\t\t/* Pass on the \"--\" if we show anything but files.. */\n \t\t\t\tif (filter & (DO_FLAGS | DO_REVS))\n \t\t\t\t\tshow_file(arg);\n+\t\t\t\tif (!(filter & DO_NONFLAGS)) {\n+\t\t\t\t\treturn 0;\n+\t\t\t\t}\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!(filter & DO_NONFLAGS)) {\n+\t\t\t\t/* once we see --flags, we stop interpreting other flags */\n+\t\t\t\t show_flag(arg);\n+\t\t\t\t continue;\n+\t\t\t}\n \t\t\tif (!strcmp(arg, \"--default\")) {\n \t\t\t\tdef = argv[i+1];\n \t\t\t\ti++;\ndiff --git a/t/t1510-rev-parse-flags.sh b/t/t1510-rev-parse-flags.sh\nindex e327b96..1e8311e 100755\n--- a/t/t1510-rev-parse-flags.sh\n+++ b/t/t1510-rev-parse-flags.sh\n@@ -92,16 +92,16 @@ test_expect_success 'git rev-parse --symbolic --no-flags --flags HEAD -> \"HEAD\"'\n \ttest_cmp expected actual\n '\n \n-test_expect_success 'git rev-parse --flags -q -> \"\"' \\\n+test_expect_success 'git rev-parse --flags -q -> \"-q\"' \\\n '\n-\t>expected &&\n+\tprintf \"%s\\n\" -q > expected &&\n \tgit rev-parse --flags -q >actual &&\n \ttest_cmp expected actual\n '\n \n-test_expect_success 'git rev-parse --flags --no-flags -> \"\"' \\\n+test_expect_success 'git rev-parse --flags --no-flags -> \"--no-flags\"' \\\n '\n-\t>expected &&\n+\tprintf \"%s\\n\" --no-flags > expected &&\n \tgit rev-parse --flags --no-flags >actual &&\n \ttest_cmp expected actual\n '\n@@ -134,10 +134,8 @@ not-a-file\n \n test_expect_success 'git rev-parse --flags --all -> list of revs' \\\n '\n-\tcat >expected <<-EOF &&\n-commit\n-\tEOF\n-\tgit cat-file -t $(git rev-parse --flags --all | head -1) >actual &&\n+\tprintf \"%s\\n\" \"--all\" >expected &&\n+\tgit rev-parse --flags --all >actual &&\n \ttest_cmp expected actual\n '\n \n-- \n1.7.3.3.g9129b6\n"},{"id":"151785","messageId":"7vzkv3hkg1.fsf@alter.siamese.dyndns.org","threadId":"25228","inReplyTo":"1285366534-10490-1-git-send-email-brian@gernhardtsoftware.com","subject":"Re: [PATCH] git-stash: fix flag parsing","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-09-27T04:36:14Z","receivedAt":"2010-09-27T04:36:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brian Gernhardt <brian@gernhardtsoftware.com> writes:\n\n> Currently git-stash uses `git rev-parse --no-revs -- \"$@\"` to set its\n> FLAGS variable.  This is the same as `FLAGS=\"-- $@\"`.  It should use\n> `git rev-parse --no-revs --flags \"$@\"`, but that eats any \"-q\" or\n> \"--quiet\" argument.  So move the check for quiet before rev-parse.\n>\n> Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>\n> ---\n>\n>  Not the most elegant solution, but it works.\n\nThanks.\n\nrev-parse as a flag parser was useful hack when most of the log family was\n\"rev-list | diff-tree\" with various options, but the recent push to make\nflags consistent across commands inevitably has made it fundamentally\nimpossible for the function to function sensibly in all cases, as it\nitself has to share some options, like \"-q\", with others.\n\nAfter the push of rewriting everything as C builtin, combined with the\nimprovement of parse-options, I have to say that rev-parse flag parser\nhack has outlived its usefulness.  The former means there is less reason\nto script end-user commands as a \"rev-list | diff-tree\" pipeline (I am not\ntalking about special purpose statistics commands that use rev-list here),\nand the latter means that it has become easier for a Porcelain script to\nparse _its_ command line options and come up with a set of sensible\noptions to underlying rev-list and the command at the downstream of the\npipe, without following the original hacky pattern of \"we let random\noptions and args and without interpreting them we guess which ones to\nthrow at rev-list and which ones to throw at diff-tree\".\n"},{"id":"151831","messageId":"1285601565-24709-1-git-send-email-jon.seymour@gmail.com","threadId":"25228","inReplyTo":"7vzkv3hkg1.fsf@alter.siamese.dyndns.org","subject":"[PATCH] stash: simplify parsing fixes","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-27T15:32:45Z","receivedAt":"2010-09-27T15:32:45Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"This patch simplifies Brian's fix for the recent regression by:\n\n* eliminating the extra loop\n* eliminating use of git rev-parse for parsing flags\n* making use of the for opt idiom for the retained loop\n* eliminating the redundant -- case\n\nThe patch has been tested with the tests in current maint.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n git-stash.sh |   28 +++++++---------------------\n 1 files changed, 7 insertions(+), 21 deletions(-)\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 57f36ce..23a9ab5 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -264,36 +264,22 @@ parse_flags_and_rev()\n \tb_tree=\n \ti_tree=\n \n-\t# Work around rev-parse --flags eating -q\n-\tfor opt\n-\tdo\n-\t\tcase \"$opt\" in\n-\t\t-q|--quiet)\n-\t\t\tGIT_QUIET=t\n-\t\t\t;;\n-\t\tesac\n-\tdone\n-\n \tREV=$(git rev-parse --no-flags --symbolic \"$@\" 2>/dev/null)\n-\tFLAGS=$(git rev-parse --no-revs --flags \"$@\" 2>/dev/null)\n-\n-\tset -- $FLAGS\n \n \tFLAGS=\n-\twhile test $# -ne 0\n+\tfor opt\n \tdo\n-\t\tcase \"$1\" in\n+\t\tcase \"$opt\" in\n+\t\t\t-q|--quiet)\n+\t\t\t\tGIT_QUIET=-t\n+\t\t\t;;\n \t\t\t--index)\n \t\t\t\tINDEX_OPTION=--index\n \t\t\t;;\n-\t\t\t--)\n-\t\t\t\t:\n-\t\t\t;;\n-\t\t\t*)\n-\t\t\t\tFLAGS=\"${FLAGS}${FLAGS:+ }$1\"\n+\t\t\t-*)\n+\t\t\t\tFLAGS=\"${FLAGS}${FLAGS:+ }$opt\"\n \t\t\t;;\n \t\tesac\n-\t\tshift\n \tdone\n \n \tset -- $REV\n-- \n1.7.3.2.g9027fa.dirty\n"},{"id":"151839","messageId":"AANLkTinzx7Tj2dGp5UJw-uef-p7HVCYNa4p1a0b6Q6ri@mail.gmail.com","threadId":"25228","inReplyTo":"1285385521-17012-1-git-send-email-jon.seymour@gmail.com","subject":"Re: [PATCH v1] stash show: fix breakage in 1.7.3","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-27T15:38:51Z","receivedAt":"2010-09-27T15:38:51Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"This patch has been superceded by:\n\n    [PATCH] stash: simplify parsing fixes\n\nwhich applies on the Brian's fix that has been applied to maint.\n\nOn Sat, Sep 25, 2010 at 1:32 PM, Jon Seymour <jon.seymour@gmail.com> wrote:\n> The detached-stash series regressed support for\n>   git stash show stash@{0}\n>\n> due to a faulty assumption that:\n>   git rev-parse --no-revs -- stash@{0}\n>\n> would treat stash@{0} as a revision reference and\n> thus not output it.\n>\n> This patch restores the behaviour of git stash show\n> so that git rev-parse is not used for parsing flags\n> and only flag like options are assigned to\n> the FLAGS variable.\n>\n> It has been tested with Brandon Casey's improved t3903 tests.\n>\n> Signed-off-by: Jon Seymour <jon.seymour@gmail.com>\n> ---\n>  git-stash.sh |    5 +----\n>  1 files changed, 1 insertions(+), 4 deletions(-)\n>\n> This revision further simplifies the parsing code\n> by removing use of git rev-parse for FLAGS parsing\n> altogether.\n>\n> diff --git a/git-stash.sh b/git-stash.sh\n> index 7ce818b..8b18bb5 100755\n> --- a/git-stash.sh\n> +++ b/git-stash.sh\n> @@ -265,9 +265,6 @@ parse_flags_and_rev()\n>        i_tree=\n>\n>        REV=$(git rev-parse --no-flags --symbolic \"$@\" 2>/dev/null)\n> -       FLAGS=$(git rev-parse --no-revs -- \"$@\" 2>/dev/null)\n> -\n> -       set -- $FLAGS\n>\n>        FLAGS=\n>        while test $# -ne 0\n> @@ -282,7 +279,7 @@ parse_flags_and_rev()\n>                        --)\n>                                :\n>                        ;;\n> -                       *)\n> +                       -*)\n>                                FLAGS=\"${FLAGS}${FLAGS:+ }$1\"\n>                        ;;\n>                esac\n> --\n> 1.7.2.14.g132f5.dirty\n>\n>\n"}]}