{"thread":{"id":"24580","subject":"git rev-parse broken on Git for Windows","startedAt":"2010-07-30T05:25:52Z","lastAt":"2010-07-30T16:44:20Z","messageCount":7,"participants":["Joshua Jensen","Johannes Schindelin","Thomas Rast","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"146754","messageId":"4C526260.6000104@workspacewhiz.com","threadId":"24580","inReplyTo":null,"subject":"git rev-parse broken on Git for Windows","fromName":"Joshua Jensen","fromEmail":"jjensen@workspacewhiz.com","sentAt":"2010-07-30T05:25:52Z","receivedAt":"2010-07-30T05:25:52Z","isPatch":false,"sender":{"key":"jjensen@workspacewhiz.com","avatar":"https://avatars.githubusercontent.com/u/111687?v=4"},"body":"  9c7304e3e39ed397b3cc6566573333e2698a52b4 (print the usage string on \nstdout instead of stderr) and then \n47e9cd28f8a404a0d6293935252ddca5fc243931 (parseopt: wrap rev-parse \n--parseopt usage for eval consumption) break the following line from the \nmanual and 'git subtree' on msysGit:\n\neval $(echo \"$OPTS_SPEC\" | git rev-parse --parseopt -- \"$@\" || echo exit $?)\n\nRunning 'git revert' on both changelists causes the 'git rev-parse \n--parseopt' to work again.\n\nWhat was 9c7304e trying to solve?\n\nThanks.\n\nJosh\n"},{"id":"146759","messageId":"alpine.DEB.1.00.1007301022310.2983@bonsai2","threadId":"24580","inReplyTo":"4C526260.6000104@workspacewhiz.com","subject":"Re: [msysGit] git rev-parse broken on Git for Windows","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2010-07-30T08:26:48Z","receivedAt":"2010-07-30T08:26:48Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 29 Jul 2010, Joshua Jensen wrote:\n\n>  9c7304e3e39ed397b3cc6566573333e2698a52b4 (print the usage string on stdout\n> instead of stderr) and then 47e9cd28f8a404a0d6293935252ddca5fc243931\n> (parseopt: wrap rev-parse --parseopt usage for eval consumption) break the\n> following line from the manual and 'git subtree' on msysGit:\n> \n> eval $(echo \"$OPTS_SPEC\" | git rev-parse --parseopt -- \"$@\" || echo exit $?)\n\nBoth commits are from Junio's 'next' branch. I Cc:ed the authors of both \ncommits.\n\n> Running 'git revert' on both changelists causes the 'git rev-parse \n> --parseopt' to work again.\n> \n> What was 9c7304e trying to solve?\n\nProbably it tried to follow some GNU convention or some such. It does not \nsay in the commit message, and neither in the code.\n\nThanks,\nJohannes\n"},{"id":"146769","messageId":"201007301102.15274.trast@student.ethz.ch","threadId":"24580","inReplyTo":"alpine.DEB.1.00.1007301022310.2983@bonsai2","subject":"Re: [msysGit] git rev-parse broken on Git for Windows","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-07-30T09:02:15Z","receivedAt":"2010-07-30T09:02:15Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Johannes Schindelin wrote:\n> Hi,\n> \n> On Thu, 29 Jul 2010, Joshua Jensen wrote:\n> \n> >  9c7304e3e39ed397b3cc6566573333e2698a52b4 (print the usage string on stdout\n> > instead of stderr) and then 47e9cd28f8a404a0d6293935252ddca5fc243931\n> > (parseopt: wrap rev-parse --parseopt usage for eval consumption) break the\n> > following line from the manual and 'git subtree' on msysGit:\n> > \n> > eval $(echo \"$OPTS_SPEC\" | git rev-parse --parseopt -- \"$@\" || echo exit $?)\n> \n> Both commits are from Junio's 'next' branch. I Cc:ed the authors of both \n> commits.\n\nCan you elaborate on \"break\"?\n\nBecause as you can see in git-sh-setup.sh, the \"official\" user of\nparseopt does\n\n\teval \"$(\n\t\techo \"$OPTIONS_SPEC\" |\n\t\t\tgit rev-parse --parseopt $parseopt_extra -- \"$@\" ||\n\t\techo exit $?\n\t)\"\n\nSo AFAICS they only differ in the quoting.  And the latter works.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"146778","messageId":"4C52E125.1020004@workspacewhiz.com","threadId":"24580","inReplyTo":"201007301102.15274.trast@student.ethz.ch","subject":"Re: [msysGit] git rev-parse broken on Git for Windows","fromName":"Joshua Jensen","fromEmail":"jjensen@workspacewhiz.com","sentAt":"2010-07-30T14:26:45Z","receivedAt":"2010-07-30T14:26:45Z","isPatch":false,"sender":{"key":"jjensen@workspacewhiz.com","avatar":"https://avatars.githubusercontent.com/u/111687?v=4"},"body":"  ----- Original Message -----\nFrom: Thomas Rast\nDate: 7/30/2010 3:02 AM\n> Johannes Schindelin wrote:\n>> On Thu, 29 Jul 2010, Joshua Jensen wrote:\n>>>   9c7304e3e39ed397b3cc6566573333e2698a52b4 (print the usage string on stdout\n>>> instead of stderr) and then 47e9cd28f8a404a0d6293935252ddca5fc243931\n>>> (parseopt: wrap rev-parse --parseopt usage for eval consumption) break the\n>>> following line from the manual and 'git subtree' on msysGit:\n>>>\n>>> eval $(echo \"$OPTS_SPEC\" | git rev-parse --parseopt -- \"$@\" || echo exit $?)\n>> Both commits are from Junio's 'next' branch. I Cc:ed the authors of both\n>> commits.\n> Can you elaborate on \"break\"?\n>\n> Because as you can see in git-sh-setup.sh, the \"official\" user of\n> parseopt does\n>\n> \teval \"$(\n> \t\techo \"$OPTIONS_SPEC\" |\n> \t\t\tgit rev-parse --parseopt $parseopt_extra -- \"$@\" ||\n> \t\techo exit $?\n> \t)\"\n>\n> So AFAICS they only differ in the quoting.  And the latter works.\nHere is the output from Git Bash:\n\n$ git subtree\nC:\\Program Files (x86)\\Git/libexec/git-core/git-subtree: eval: line 31: \nsyntax error near unexpected token `<'\nC:\\Program Files (x86)\\Git/libexec/git-core/git-subtree: eval: line 31: \n`cat <<\\EOF usage: git subtree add --prefix=<prefix> <commit\n > or: git subtree merge --prefix=<prefix> <commit> or: git subtree pull \n--prefix=<prefix> <repository> <refspec...> or: git subtree\npush --prefix=<prefix> <repository> <refspec...> or: git subtree split \n--prefix=<prefix> <commit...> -h, --help show the help -q qui\net -d show debug messages -P, --prefix ... the name of the subdir to \nsplit out -m, --message ... use the given message as the commit\n  message for the merge commit options for 'split' --annotate ... add a \nprefix to commit message of new commits -b, --branch ... crea\nte a new branch from the split subtree --ignore-joins ignore prior \n--rejoin commits --onto ... try connecting new tree to an existin\ng one --rejoin merge the new branch back into HEAD options for 'add', \n'merge', 'pull' and 'push' --squash merge subtree changes as a\n  single commit EOF exit 129'\nUsage: git subtree\n\nThe example from the git rev-parse documentation fails in the same way:\n\neval `echo \"$OPTS_SPEC\" | git rev-parse --parseopt $parseopt_extra -- \n\"$@\" || echo exit $?`\n\nWhat does work is the example you gave with the quotes:\n\neval \"$(echo \"$OPTS_SPEC\" | git rev-parse --parseopt $parseopt_extra -- \n\"$@\" || echo exit $?)\"\n\nI can live with modifying 'git subtree' in this manner, but something \nabout one or both of those rev-parse commits cause the non-quoted \nversion $(echo...) version in git subtree and the `echo...` version to \nbreak.\n\nJosh\n"},{"id":"146779","messageId":"201007301643.50730.trast@student.ethz.ch","threadId":"24580","inReplyTo":"4C52E125.1020004@workspacewhiz.com","subject":"Re: [msysGit] git rev-parse broken on Git for Windows","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-07-30T14:43:50Z","receivedAt":"2010-07-30T14:43:50Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Joshua Jensen wrote:\n> Thomas Rast wrote:\n> > Johannes Schindelin wrote:\n> >>> eval $(echo \"$OPTS_SPEC\" | git rev-parse --parseopt -- \"$@\" || echo exit $?)\n> > Can you elaborate on \"break\"?\n> >\n> > Because as you can see in git-sh-setup.sh, the \"official\" user of\n> > parseopt does\n> >\n> > \teval \"$(\n> > \t\techo \"$OPTIONS_SPEC\" |\n> > \t\t\tgit rev-parse --parseopt $parseopt_extra -- \"$@\" ||\n> > \t\techo exit $?\n> > \t)\"\n> >\n> > So AFAICS they only differ in the quoting.  And the latter works.\n> Here is the output from Git Bash:\n> \n> $ git subtree\n> C:\\Program Files (x86)\\Git/libexec/git-core/git-subtree: eval: line 31: \n> syntax error near unexpected token `<'\n[...]\n> The example from the git rev-parse documentation fails in the same way:\n> \n> eval `echo \"$OPTS_SPEC\" | git rev-parse --parseopt $parseopt_extra -- \n> \"$@\" || echo exit $?`\n\nOh, sorry that I was so dense in the first reply.  Of course the\nquoting is the problem.  When unquoted, the shell first splits along\nwhitespace and then eval reassembles with *one space* between each\npair of words.  The change just exacerbated the issue; there are other\nways to trigger bad behaviour if the eval uses an unquoted --parseopt:\n\n  # what you saw\n  $ echo eval $( (echo 'description'; echo --; echo \"s,long= foo\") | git rev-parse --parseopt -- --help || echo exit $?)\n  eval cat <<\\EOF usage: description -s, --long ... foo EOF exit 129\n\n  # newlines are clobbered\n  $ echo eval $( (echo 'description'; echo --; echo \"s,long= foo\") | git rev-parse --parseopt -- --long=\"$(printf 'argument\\nwith\\nnewlines')\" || echo exit $?)\n  eval set -- -s 'argument with newlines' --\n\n  # consecutive spaces are also clobbered\n  echo eval $( (echo 'description'; echo --; echo \"s,long= foo\") | git rev-parse --parseopt -- --long=\"three   spaces\" || echo exit $?)\n  eval set -- -s 'three spaces' --\n\nSo I'm afraid Avery will have to fix this in git-subtree.  I'll also\nfollow up with a doc patch for git-rev-parse.  Luckily there are no\nusers in git outside of tests and git-sh-setup, so there are no bugs.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"146781","messageId":"8ef69f9855ca0719c03d7dac320b3a3beb657bca.1280501949.git.trast@student.ethz.ch","threadId":"24580","inReplyTo":"201007301643.50730.trast@student.ethz.ch","subject":"[PATCH] Documentation/rev-parse: quoting is required with --parseopt","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-07-30T15:01:50Z","receivedAt":"2010-07-30T15:01:50Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"When calling rev-parse --parseopt, as in the (now fixed) documented\nexample\n\n  eval \"$(echo \"$OPTS_SPEC\" | git rev-parse --parseopt -- \"$@\" || echo exit $?)\"\n\nthe outermost quoting is required, as otherwise all runs of arbitrary\nwhitespace inside the resulting 'set -- ...' call would be collapsed\ninto a single space.\n\nThis was exposed as a result of our new use of cat <<\\EOF since\n47e9cd2 (parseopt: wrap rev-parse --parseopt usage for eval\nconsumption, 2010-06-12), but has always been a problem when handling\narguments containing e.g. newlines.\n\nPoint this out in the documentation, and in particular correct the\nexample that did not have the quotes.\n\nNoticed-by: Joshua Jensen <jjensen@workspacewhiz.com>\nSigned-off-by: Thomas Rast <trast@student.ethz.ch>\n---\n Documentation/git-rev-parse.txt |    7 +++++--\n 1 files changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt\nindex 0727f43..be4c053 100644\n--- a/Documentation/git-rev-parse.txt\n+++ b/Documentation/git-rev-parse.txt\n@@ -184,10 +184,13 @@ scripts the same facilities C builtins have. It works as an option normalizer\n (e.g. splits single switches aggregate values), a bit like `getopt(1)` does.\n \n It takes on the standard input the specification of the options to parse and\n-understand, and echoes on the standard output a line suitable for `sh(1)` `eval`\n+understand, and echoes on the standard output a string suitable for `sh(1)` `eval`\n to replace the arguments with normalized ones.  In case of error, it outputs\n usage on the standard error stream, and exits with code 129.\n \n+Note: Make sure you quote the result when passing it to `eval`.  See\n+below for an example.\n+\n Input Format\n ~~~~~~~~~~~~\n \n@@ -244,7 +247,7 @@ bar=      some cool option --bar with an argument\n   An option group Header\n C?        option C with an optional argument\"\n \n-eval `echo \"$OPTS_SPEC\" | git rev-parse --parseopt -- \"$@\" || echo exit $?`\n+eval \"$(echo \"$OPTS_SPEC\" | git rev-parse --parseopt -- \"$@\" || echo exit $?)\"\n ------------\n \n SQ-QUOTE\n-- \n1.7.2.1.342.g676a4\n"},{"id":"146787","messageId":"7vd3u4rkbf.fsf@alter.siamese.dyndns.org","threadId":"24580","inReplyTo":"201007301643.50730.trast@student.ethz.ch","subject":"Re: [msysGit] git rev-parse broken on Git for Windows","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-07-30T16:44:20Z","receivedAt":"2010-07-30T16:44:20Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thomas Rast <trast@student.ethz.ch> writes:\n\n> ...  I'll also\n> follow up with a doc patch for git-rev-parse.  Luckily there are no\n> users in git outside of tests and git-sh-setup, so there are no bugs.\n\nThanks.\n"}]}