{"thread":{"id":"42282","subject":"Bug: `git-filter-branch −−subdirectory−filter` fails on Darwin, others?","startedAt":"2016-05-11T13:47:20Z","lastAt":"2016-05-11T14:47:52Z","messageCount":3,"participants":["Geoff Nixon","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"286267","messageId":"154a01265c2.c271895e226206.8641058706319152212@geoff.codes","threadId":"42282","inReplyTo":null,"subject":"Bug: `git-filter-branch −−subdirectory−filter` fails on Darwin, others?","fromName":"Geoff Nixon","fromEmail":"geoff@geoff.codes","sentAt":"2016-05-11T13:47:20Z","receivedAt":"2016-05-11T13:47:20Z","isPatch":false,"sender":{"key":"geoff@geoff.codes","avatar":null},"body":"May 11, 2016\nGeoff Nixon\ngeoff@geoff.codes\n\nTo Whom It May Concern:\n\n    I believe I have found a bug in git. On Mac OS X (at least 10.9 through 10.11), and versions of git from the current HEAD down through at least 1.8.x, `git filter-branch −−subdirectory−filter ...` fails. Using, e.g., the following example (from the docs for git-filter-branch), `git filter-branch --subdirectory-filter foodir -- --all`, and using the git repository as the example repository, `git filter-branch --subdirectory-filter Documentation -- --all`, the \"error message\" one receives is \"fatal: bad revision '−−subdirectory−filter'\".\n\n    I have tried to find and eliminate the bug myself, but despite my efforts it has proved elusive. Here is what I can tell you:\n\n    - It is apparently Darwin specific, or at least, I cannot reproduce on Linux\n    - It applies across a wide swath of versions of git and Mac OS X.\n    - Debugging is a challenge, because the code is pretty wack sauce,\n    - I.e., I don't understand how it `s\n     Doesn't matter which version of the OS or which version of git, at least going back to 10.9 and 1.8, I believe.\n    - There is some extremely strange magic going on here, i.e.,\n      - I don't understand how it sources `git-sh-setup` on line 90, while still in $PWD\n      - It begins with a heredoc of fuctions which are then immediately,\n      - `eval`'d, for no apparent reason.\n      - There's way to many uses of `eval` to follow, many of them needless, and it resets its own positional arguments to the result of the expansion of command substitution in places, withought saving the original parameters \n      - It possibly seems to be expanding '-' to an octal sequence at some point?\n    - Exporting PS4 to 'WTF: $LINENO ' and setting `-x` is practically of no use, except that the last line before it fails appears to be `git rev-parse --no-flags --revs-only --symbolic-full-name --default HEAD $'�\\210\\222�\\210\\222subdirectory�\\210\\222filter` (including the octal sequences and bad-unicode character, those are not email artifacts)\n\nThank you for you time and consideration.\n\nYours,\n\nGeoff Nixon\n"},{"id":"286268","messageId":"20160511140802.GA20134@sigill.intra.peff.net","threadId":"42282","inReplyTo":"154a01265c2.c271895e226206.8641058706319152212@geoff.codes","subject":"Re: Bug: `git-filter-branch −−subdirectory−filter` fails on Darwin, others?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-05-11T14:08:02Z","receivedAt":"2016-05-11T14:08:02Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, May 11, 2016 at 06:47:20AM -0700, Geoff Nixon wrote:\n\n> I believe I have found a bug in git. On Mac OS X (at least 10.9\n> through 10.11), and versions of git from the current HEAD down through\n> at least 1.8.x, `git filter-branch −−subdirectory−filter ...` fails.\n> Using, e.g., the following example (from the docs for\n> git-filter-branch), `git filter-branch --subdirectory-filter foodir --\n> --all`, and using the git repository as the example repository, `git\n> filter-branch --subdirectory-filter Documentation -- --all`, the\n> \"error message\" one receives is \"fatal: bad revision\n> '−−subdirectory−filter'\".\n\nI just double-checked, and it works fine for me in a simple test:\n\n  git init\n  mkdir subdir\n  for i in 1 2 3 4 5; do\n    echo $i >base-$i\n    echo $i >subdir/sub-$i\n    git add .\n    git commit -m $i\n  done\n  git filter-branch --subdirectory-filter subdir -- --all\n\nThat's on:\n\n  $ sw_vers\n  ProductName:    Mac OS X\n  ProductVersion: 10.9.5\n  BuildVersion:   13F34\n\nHowever, I notice the error message you show has non-ascii dashes when\nit prints \"--subdirectory-filter\". That matches what you said below:\n\n>     - Exporting PS4 to 'WTF: $LINENO ' and setting `-x` is practically\n>     of no use, except that the last line before it fails appears to be\n>     `git rev-parse --no-flags --revs-only --symbolic-full-name\n>     --default HEAD $'�\\210\\222�\\210\\222subdirectory�\\210\\222filter`\n>     (including the octal sequences and bad-unicode character, those\n>     are not email artifacts)\n\nAre you sure that you are invoking filter-branch with regular ascii\ndashes, and not Unicode \"minus-sign\" (U+2212)?\n\nI seem to recall this coming up once before related to OS X, but I can't\nseem to find it in the archive. And I don't recall if it was related to\nthe terminal, a keyboard setting, or something else.\n\n-Peff\n"},{"id":"286269","messageId":"154a049cf1d.12555f552239176.4375238071436036595@geoff.codes","threadId":"42282","inReplyTo":"20160511140802.GA20134@sigill.intra.peff.net","subject":"Re: Bug: `git-filter-branch −−subdirectory−filter` fails on Darwin, others?","fromName":"Geoff Nixon","fromEmail":"geoff@geoff.codes","sentAt":"2016-05-11T14:47:52Z","receivedAt":"2016-05-11T14:47:52Z","isPatch":false,"sender":{"key":"geoff@geoff.codes","avatar":null},"body":"\n\n\n ---- On Wed, 11 May 2016 07:08:02 -0700 Jeff King <peff@peff.net> wrote ---- \n > On Wed, May 11, 2016 at 06:47:20AM -0700, Geoff Nixon wrote: \n >  \n > >    the last line before it fails appears to be \n > >     `git rev-parse --no-flags --revs-only --symbolic-full-name \n > >     --default HEAD \n \\210\\222 \\210\\222subdirectory \\210\\222filter` \n > >     (including the octal sequences and bad-unicode character, those \n > >     are not email artifacts) \n >  \n > Are you sure that you are invoking filter-branch with regular ascii \n > dashes, and not Unicode \"minus-sign\" (U+2212)? \n >  \n > I seem to recall this coming up once before related to OS X, but I can't \n > seem to find it in the archive. And I don't recall if it was related to \n > the terminal, a keyboard setting, or something else. \n\nThat was it. I'm an idiot.\n\nI sometimes use `man -t` to generate postscript for lengthy man pages so I can \"page through\" outside my terminal.\nIt appears that for reasons unknown this converts all \"-\"s to \"−\"s. I must have copy-pasted the example.\nThen I kept using my shell history completion, never typing it out again.\n\nSorry for wasting your time, thanks for helping me figure this out.\n\n-Geoff\n\n >  \n > -Peff \n >\n"}]}