{"thread":{"id":"23063","subject":"help with git filter-branch","startedAt":"2010-03-18T14:43:18Z","lastAt":"2010-03-18T15:19:11Z","messageCount":2,"participants":["Yann Simon","Johannes Sixt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"137096","messageId":"551f769b1003180743n2b2dde99laf00aa9bfe0141bf@mail.gmail.com","threadId":"23063","inReplyTo":null,"subject":"help with git filter-branch","fromName":"Yann Simon","fromEmail":"yann.simon.fr@gmail.com","sentAt":"2010-03-18T14:43:18Z","receivedAt":"2010-03-18T14:43:18Z","isPatch":false,"sender":{"key":"yann.simon.fr@gmail.com","avatar":"https://gravatar.com/avatar/2d926895d27ac988c5c8e591887e5a6a4c7036390403c74fce92519119b887a0?d=mp&s=160"},"body":"Hi,\n\nI am trying to use the script found on the following page:\nhttp://ebixio.com/blog/2009/10/15/git-filter-branch-incantations/\n\nThe idea is to add a missing parent to a certain commit.\nI wrote the following bash script:\n\n#!/bin/sh\ndie () {\n    echo >&2 \"$@\"\n    exit 1\n}\n[ \"$#\" -eq 3 ] || die \"usage: add_parent <commit_to_update>\n<present_parent> <parent_to_add>\"\ngit filter-branch --parent-filter \\\n    'test $GIT_COMMIT = $1 && \\\n    echo \"-p $2 -p $3\" \\\n    || cat' \\\n    --tag-name-filter 'cat' \\\n    $2..master\n\nWhen I try to use it an a test repository, I get the following error:\n\n./add_parent.sh ad12d20974cad91ddedd055f5335b7471e48dd1d\n1541f3ae456556edc7e15cead1ae76f470961be0\n88b5d6f190f9d7135148c67c4d949c0c06e179ff\nRewrite ad12d20974cad91ddedd055f5335b7471e48dd1d (1/1)test: 3: =:\nargument expected\n\nI am using git version 1.7.0.2.\n\nAny help appreciated!\nThank you\nYann\n"},{"id":"137099","messageId":"4BA2446F.1080002@viscovery.net","threadId":"23063","inReplyTo":"551f769b1003180743n2b2dde99laf00aa9bfe0141bf@mail.gmail.com","subject":"Re: help with git filter-branch","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2010-03-18T15:19:11Z","receivedAt":"2010-03-18T15:19:11Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Yann Simon schrieb:\n> The idea is to add a missing parent to a certain commit.\n> I wrote the following bash script:\n> \n> #!/bin/sh\n> die () {\n>     echo >&2 \"$@\"\n>     exit 1\n> }\n> [ \"$#\" -eq 3 ] || die \"usage: add_parent <commit_to_update>\n> <present_parent> <parent_to_add>\"\n> git filter-branch --parent-filter \\\n>     'test $GIT_COMMIT = $1 && \\\n>     echo \"-p $2 -p $3\" \\\n>     || cat' \\\n>     --tag-name-filter 'cat' \\\n>     $2..master\n> \n> When I try to use it an a test repository, I get the following error:\n> \n> ./add_parent.sh ad12d20974cad91ddedd055f5335b7471e48dd1d\n> 1541f3ae456556edc7e15cead1ae76f470961be0\n> 88b5d6f190f9d7135148c67c4d949c0c06e179ff\n> Rewrite ad12d20974cad91ddedd055f5335b7471e48dd1d (1/1)test: 3: =:\n> argument expected\n\nThe $1, $2, $3 are expanded too late in your script, namely when the\n--parent-filter is evaluated, not when it is passed as argument to\nfilter-branch. Make it\n\ngit filter-branch --parent-filter \"\n\ttest \\$GIT_COMMIT = $1 &&\n\techo -p $2 -p $3 ||\n\tcat\" \\\n\t--tag-name-filter cat \\\n\t$2..master\n\nOf course, you can achieve this particular task slightly easier using a\ngraft as the manual of filter-branch shows.\n\n-- Hannes\n"}]}