{"thread":{"id":"46106","subject":"[PATCH 1/2] add setup step to filter-branch","startedAt":"2017-06-03T10:18:10Z","lastAt":"2017-06-10T08:56:12Z","messageCount":10,"participants":["Andreas Heiduk","Junio C Hamano","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"321475","messageId":"20170603101755.13619-1-asheiduk@gmail.com","threadId":"46106","inReplyTo":null,"subject":"[PATCH 1/2] add setup step to filter-branch","fromName":"Andreas Heiduk","fromEmail":"asheiduk@gmail.com","sentAt":"2017-06-03T10:17:54Z","receivedAt":"2017-06-03T10:18:10Z","isPatch":true,"sender":{"key":"asheiduk@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9371344?v=4"},"body":"A specific `--setup` step in `git filter-branch` makes it much easier\nto define the initial values of variables used in the real filters.\nAlso sourcing/defining utility functions here instead of\n`--env-filter` improves performance and minimizes clogging the output\nin case of errors.\n\nSigned-off-by: Andreas Heiduk <asheiduk@gmail.com>\n---\n Documentation/git-filter-branch.txt | 16 +++++++++++-----\n git-filter-branch.sh                | 18 +++++++++++++-----\n 2 files changed, 24 insertions(+), 10 deletions(-)\n\ndiff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt\nindex 6e4bb0220..45c849d8c 100644\n--- a/Documentation/git-filter-branch.txt\n+++ b/Documentation/git-filter-branch.txt\n@@ -8,11 +8,11 @@ git-filter-branch - Rewrite branches\n SYNOPSIS\n --------\n [verse]\n-'git filter-branch' [--env-filter <command>] [--tree-filter <command>]\n-\t[--index-filter <command>] [--parent-filter <command>]\n-\t[--msg-filter <command>] [--commit-filter <command>]\n-\t[--tag-name-filter <command>] [--subdirectory-filter <directory>]\n-\t[--prune-empty]\n+'git filter-branch' [--setup <command>] [--env-filter <command>]\n+\t[--tree-filter <command>] [--index-filter <command>]\n+\t[--parent-filter <command>] [--msg-filter <command>]\n+\t[--commit-filter <command>] [--tag-name-filter <command>]\n+\t[--subdirectory-filter <directory>] [--prune-empty]\n \t[--original <namespace>] [-d <directory>] [-f | --force]\n \t[--] [<rev-list options>...]\n \n@@ -82,6 +82,12 @@ multiple commits.\n OPTIONS\n -------\n \n+--setup <command>::\n+\tThis is not a real filter executed for each commit but a one\n+\ttime setup just before the loop. Therefore no commit-specific\n+\tvariables are defined yet.  Functions or variables defined here\n+\tcan be used or modified in the following filter steps.\n+\n --env-filter <command>::\n \tThis filter may be used if you only need to modify the environment\n \tin which the commit will be performed.  Specifically, you might\ndiff --git a/git-filter-branch.sh b/git-filter-branch.sh\nindex aafaf708d..2758ae5eb 100755\n--- a/git-filter-branch.sh\n+++ b/git-filter-branch.sh\n@@ -81,11 +81,12 @@ set_ident () {\n \tfinish_ident COMMITTER\n }\n \n-USAGE=\"[--env-filter <command>] [--tree-filter <command>]\n-\t[--index-filter <command>] [--parent-filter <command>]\n-\t[--msg-filter <command>] [--commit-filter <command>]\n-\t[--tag-name-filter <command>] [--subdirectory-filter <directory>]\n-\t[--original <namespace>] [-d <directory>] [-f | --force]\n+USAGE=\"[--setup <command>] [--env-filter <command>]\n+\t[--tree-filter <command>] [--index-filter <command>]\n+\t[--parent-filter <command>] [--msg-filter <command>]\n+\t[--commit-filter <command>] [--tag-name-filter <command>]\n+\t[--subdirectory-filter <directory>] [--original <namespace>]\n+\t[-d <directory>] [-f | --force]\n \t[<rev-list options>...]\"\n \n OPTIONS_SPEC=\n@@ -96,6 +97,7 @@ if [ \"$(is_bare_repository)\" = false ]; then\n fi\n \n tempdir=.git-rewrite\n+filter_setup=\n filter_env=\n filter_tree=\n filter_index=\n@@ -148,6 +150,9 @@ do\n \t-d)\n \t\ttempdir=\"$OPTARG\"\n \t\t;;\n+\t--setup)\n+\t\tfilter_setup=\"$OPTARG\"\n+\t\t;;\n \t--env-filter)\n \t\tfilter_env=\"$OPTARG\"\n \t\t;;\n@@ -317,6 +322,9 @@ else\n \tneed_index=\n fi\n \n+eval \"$filter_setup\" < /dev/null ||\n+\tdie \"filter setup failed: $filter_setup\"\n+\n while read commit parents; do\n \tgit_filter_branch__commit_count=$(($git_filter_branch__commit_count+1))\n \n-- \n2.13.0\n\n"},{"id":"321476","messageId":"20170603101755.13619-2-asheiduk@gmail.com","threadId":"46106","inReplyTo":"20170603101755.13619-1-asheiduk@gmail.com","subject":"[PATCH 2/2] add [--] to usage of filter-branch","fromName":"Andreas Heiduk","fromEmail":"asheiduk@gmail.com","sentAt":"2017-06-03T10:17:55Z","receivedAt":"2017-06-03T10:18:15Z","isPatch":true,"sender":{"key":"asheiduk@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9371344?v=4"},"body":"Signed-off-by: Andreas Heiduk <asheiduk@gmail.com>\n---\n Documentation/git-filter-branch.txt | 3 ++-\n git-filter-branch.sh                | 2 +-\n 2 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt\nindex 45c849d8c..1efdda804 100644\n--- a/Documentation/git-filter-branch.txt\n+++ b/Documentation/git-filter-branch.txt\n@@ -86,7 +86,8 @@ OPTIONS\n \tThis is not a real filter executed for each commit but a one\n \ttime setup just before the loop. Therefore no commit-specific\n \tvariables are defined yet.  Functions or variables defined here\n-\tcan be used or modified in the following filter steps.\n+\tcan be used or modified in the following filter steps except\n+\tthe commit filter, for technical reasons.\n \n --env-filter <command>::\n \tThis filter may be used if you only need to modify the environment\ndiff --git a/git-filter-branch.sh b/git-filter-branch.sh\nindex 2758ae5eb..3a74602ef 100755\n--- a/git-filter-branch.sh\n+++ b/git-filter-branch.sh\n@@ -87,7 +87,7 @@ USAGE=\"[--setup <command>] [--env-filter <command>]\n \t[--commit-filter <command>] [--tag-name-filter <command>]\n \t[--subdirectory-filter <directory>] [--original <namespace>]\n \t[-d <directory>] [-f | --force]\n-\t[<rev-list options>...]\"\n+\t[--] [<rev-list options>...]\"\n \n OPTIONS_SPEC=\n . git-sh-setup\n-- \n2.13.0\n\n"},{"id":"321520","messageId":"xmqq1sqzuqmh.fsf@gitster.mtv.corp.google.com","threadId":"46106","inReplyTo":"20170603101755.13619-1-asheiduk@gmail.com","subject":"Re: [PATCH 1/2] add setup step to filter-branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-05T02:15:18Z","receivedAt":"2017-06-05T02:15:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andreas Heiduk <asheiduk@gmail.com> writes:\n\n> A specific `--setup` step in `git filter-branch` makes it much easier\n> to define the initial values of variables used in the real filters.\n> Also sourcing/defining utility functions here instead of\n> `--env-filter` improves performance and minimizes clogging the output\n> in case of errors.\n>\n> Signed-off-by: Andreas Heiduk <asheiduk@gmail.com>\n> ---\n\nI was placed on To: line, but I do not have a strong opinion on this\nchange, either for or against.\n\n\"filter-branch\" program itself may probably already be hard to port\nto C, but I need to point out that this makes it even harder than it\ncurrently is [*1*], and it is likely that it has to stay implemented\nin shell forever, though.  I do not mind that future myself, but\nthose on platforms with weaker implementation of shells might.\n\n[Footnote]\n\n *1* The issue is *not* that these individual filter commands expect\n     <command> written as a shell scriptlet; it is that these\n     scriptlets expect to be evaled inside a single shell process,\n     making an update to a shell variable in one command visible to\n     the next command that runs.\n\n\n>  Documentation/git-filter-branch.txt | 16 +++++++++++-----\n>  git-filter-branch.sh                | 18 +++++++++++++-----\n>  2 files changed, 24 insertions(+), 10 deletions(-)\n>\n> diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt\n> index 6e4bb0220..45c849d8c 100644\n> --- a/Documentation/git-filter-branch.txt\n> +++ b/Documentation/git-filter-branch.txt\n> @@ -8,11 +8,11 @@ git-filter-branch - Rewrite branches\n>  SYNOPSIS\n>  --------\n>  [verse]\n> -'git filter-branch' [--env-filter <command>] [--tree-filter <command>]\n> -\t[--index-filter <command>] [--parent-filter <command>]\n> -\t[--msg-filter <command>] [--commit-filter <command>]\n> -\t[--tag-name-filter <command>] [--subdirectory-filter <directory>]\n> -\t[--prune-empty]\n> +'git filter-branch' [--setup <command>] [--env-filter <command>]\n> +\t[--tree-filter <command>] [--index-filter <command>]\n> +\t[--parent-filter <command>] [--msg-filter <command>]\n> +\t[--commit-filter <command>] [--tag-name-filter <command>]\n> +\t[--subdirectory-filter <directory>] [--prune-empty]\n>  \t[--original <namespace>] [-d <directory>] [-f | --force]\n>  \t[--] [<rev-list options>...]\n>  \n> @@ -82,6 +82,12 @@ multiple commits.\n>  OPTIONS\n>  -------\n>  \n> +--setup <command>::\n> +\tThis is not a real filter executed for each commit but a one\n> +\ttime setup just before the loop. Therefore no commit-specific\n> +\tvariables are defined yet.  Functions or variables defined here\n> +\tcan be used or modified in the following filter steps.\n> +\n>  --env-filter <command>::\n>  \tThis filter may be used if you only need to modify the environment\n>  \tin which the commit will be performed.  Specifically, you might\n> diff --git a/git-filter-branch.sh b/git-filter-branch.sh\n> index aafaf708d..2758ae5eb 100755\n> --- a/git-filter-branch.sh\n> +++ b/git-filter-branch.sh\n> @@ -81,11 +81,12 @@ set_ident () {\n>  \tfinish_ident COMMITTER\n>  }\n>  \n> -USAGE=\"[--env-filter <command>] [--tree-filter <command>]\n> -\t[--index-filter <command>] [--parent-filter <command>]\n> -\t[--msg-filter <command>] [--commit-filter <command>]\n> -\t[--tag-name-filter <command>] [--subdirectory-filter <directory>]\n> -\t[--original <namespace>] [-d <directory>] [-f | --force]\n> +USAGE=\"[--setup <command>] [--env-filter <command>]\n> +\t[--tree-filter <command>] [--index-filter <command>]\n> +\t[--parent-filter <command>] [--msg-filter <command>]\n> +\t[--commit-filter <command>] [--tag-name-filter <command>]\n> +\t[--subdirectory-filter <directory>] [--original <namespace>]\n> +\t[-d <directory>] [-f | --force]\n>  \t[<rev-list options>...]\"\n>  \n>  OPTIONS_SPEC=\n> @@ -96,6 +97,7 @@ if [ \"$(is_bare_repository)\" = false ]; then\n>  fi\n>  \n>  tempdir=.git-rewrite\n> +filter_setup=\n>  filter_env=\n>  filter_tree=\n>  filter_index=\n> @@ -148,6 +150,9 @@ do\n>  \t-d)\n>  \t\ttempdir=\"$OPTARG\"\n>  \t\t;;\n> +\t--setup)\n> +\t\tfilter_setup=\"$OPTARG\"\n> +\t\t;;\n>  \t--env-filter)\n>  \t\tfilter_env=\"$OPTARG\"\n>  \t\t;;\n> @@ -317,6 +322,9 @@ else\n>  \tneed_index=\n>  fi\n>  \n> +eval \"$filter_setup\" < /dev/null ||\n> +\tdie \"filter setup failed: $filter_setup\"\n> +\n>  while read commit parents; do\n>  \tgit_filter_branch__commit_count=$(($git_filter_branch__commit_count+1))\n"},{"id":"321526","messageId":"ef30e8f5-8206-7b42-e229-6cd4b0492e76@gmail.com","threadId":"46106","inReplyTo":"20170603101755.13619-2-asheiduk@gmail.com","subject":"Re: [PATCH 2/2] add [--] to usage of filter-branch","fromName":"Andreas Heiduk","fromEmail":"asheiduk@gmail.com","sentAt":"2017-06-05T08:51:09Z","receivedAt":"2017-06-05T08:51:17Z","isPatch":true,"sender":{"key":"asheiduk@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9371344?v=4"},"body":"Am 03.06.2017 um 12:17 schrieb Andreas Heiduk:\n> Signed-off-by: Andreas Heiduk <asheiduk@gmail.com>\n> ---\n>  Documentation/git-filter-branch.txt | 3 ++-\n>  git-filter-branch.sh                | 2 +-\n>  2 files changed, 3 insertions(+), 2 deletions(-)\n> \n> diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt\n> index 45c849d8c..1efdda804 100644\n> --- a/Documentation/git-filter-branch.txt\n> +++ b/Documentation/git-filter-branch.txt\n> @@ -86,7 +86,8 @@ OPTIONS\n>  \tThis is not a real filter executed for each commit but a one\n>  \ttime setup just before the loop. Therefore no commit-specific\n>  \tvariables are defined yet.  Functions or variables defined here\n> -\tcan be used or modified in the following filter steps.\n> +\tcan be used or modified in the following filter steps except\n> +\tthe commit filter, for technical reasons.\n\nI'll move that into the previous commit.\n"},{"id":"321815","messageId":"20170609054955.y52cro2c3bwhl2sh@sigill.intra.peff.net","threadId":"46106","inReplyTo":"xmqq1sqzuqmh.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 1/2] add setup step to filter-branch","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-06-09T05:49:55Z","receivedAt":"2017-06-09T05:50:03Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jun 05, 2017 at 11:15:18AM +0900, Junio C Hamano wrote:\n\n> Andreas Heiduk <asheiduk@gmail.com> writes:\n> \n> > A specific `--setup` step in `git filter-branch` makes it much easier\n> > to define the initial values of variables used in the real filters.\n> > Also sourcing/defining utility functions here instead of\n> > `--env-filter` improves performance and minimizes clogging the output\n> > in case of errors.\n> >\n> > Signed-off-by: Andreas Heiduk <asheiduk@gmail.com>\n> > ---\n> \n> I was placed on To: line, but I do not have a strong opinion on this\n> change, either for or against.\n> \n> \"filter-branch\" program itself may probably already be hard to port\n> to C, but I need to point out that this makes it even harder than it\n> currently is [*1*], and it is likely that it has to stay implemented\n> in shell forever, though.  I do not mind that future myself, but\n> those on platforms with weaker implementation of shells might.\n\nI have a feeling that if we were ever to rewrite filter-branch, it would\nprobably be worth allowing people to write snippets in a better language\n(possibly even a domain-specific language). I'm sure that most of the\nprogram being written in shell doesn't help, but if we're spawning one\nor more shell instances per commit (plus the Git programs they spawn!),\nit's always going to be slow.\n\nBut I suspect that would be an uphill battle, as our only stable API\ninvolves starting external processes anyway. You'd probably do better to\npick a language you like and rewrite it in using libgit2's bindings to\nthat language. It's not feature complete, but basic stuff like \"put this\nentry in the tree\" is certainly mature.\n\n>  *1* The issue is *not* that these individual filter commands expect\n>      <command> written as a shell scriptlet; it is that these\n>      scriptlets expect to be evaled inside a single shell process,\n>      making an update to a shell variable in one command visible to\n>      the next command that runs.\n\nI think you'd need a shell \"helper\" that's a single long-running process\nand just reads \"eval the index snippet now\" instructions from the C\ncontroller. At which point I don't think Andreas's \"setup\" feature is\nany harder to support. We just send an \"eval the setup snippet\"\ninstruction first.\n\nI guess one way to think of that is that the C program is itself\ngenerating a shell script.\n\n-Peff\n"},{"id":"321827","messageId":"xmqqo9tx71bn.fsf@gitster.mtv.corp.google.com","threadId":"46106","inReplyTo":"20170609054955.y52cro2c3bwhl2sh@sigill.intra.peff.net","subject":"Re: [PATCH 1/2] add setup step to filter-branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-09T13:11:40Z","receivedAt":"2017-06-09T13:11:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> I have a feeling that if we were ever to rewrite filter-branch, it would\n> probably be worth allowing people to write snippets in a better language\n> (possibly even a domain-specific language). I'm sure that most of the\n> program being written in shell doesn't help, but if we're spawning one\n> or more shell instances per commit (plus the Git programs they spawn!),\n> it's always going to be slow.\n>\n> But I suspect that would be an uphill battle, as our only stable API\n> involves starting external processes anyway. You'd probably do better to\n> pick a language you like and rewrite it in using libgit2's bindings to\n> that language. It's not feature complete, but basic stuff like \"put this\n> entry in the tree\" is certainly mature.\n>\n>>  *1* The issue is *not* that these individual filter commands expect\n>>      <command> written as a shell scriptlet; it is that these\n>>      scriptlets expect to be evaled inside a single shell process,\n>>      making an update to a shell variable in one command visible to\n>>      the next command that runs.\n>\n> I think you'd need a shell \"helper\" that's a single long-running process\n> and just reads \"eval the index snippet now\" instructions from the C\n> controller. At which point I don't think Andreas's \"setup\" feature is\n> any harder to support. We just send an \"eval the setup snippet\"\n> instruction first.\n\nYes.  I do not think this particular one makes things any worse than\nit already is.  As I said, I do not have a strong opinion against\nthe topic; as long as people find the feature useful, I do not mind\napplying it.\n\nThanks.\n"},{"id":"321828","messageId":"xmqqk24l717a.fsf@gitster.mtv.corp.google.com","threadId":"46106","inReplyTo":"ef30e8f5-8206-7b42-e229-6cd4b0492e76@gmail.com","subject":"Re: [PATCH 2/2] add [--] to usage of filter-branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-09T13:14:17Z","receivedAt":"2017-06-09T13:14:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andreas Heiduk <asheiduk@gmail.com> writes:\n\n> Am 03.06.2017 um 12:17 schrieb Andreas Heiduk:\n>> Signed-off-by: Andreas Heiduk <asheiduk@gmail.com>\n>> ---\n>>  Documentation/git-filter-branch.txt | 3 ++-\n>>  git-filter-branch.sh                | 2 +-\n>>  2 files changed, 3 insertions(+), 2 deletions(-)\n>> \n>> diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt\n>> index 45c849d8c..1efdda804 100644\n>> --- a/Documentation/git-filter-branch.txt\n>> +++ b/Documentation/git-filter-branch.txt\n>> @@ -86,7 +86,8 @@ OPTIONS\n>>  \tThis is not a real filter executed for each commit but a one\n>>  \ttime setup just before the loop. Therefore no commit-specific\n>>  \tvariables are defined yet.  Functions or variables defined here\n>> -\tcan be used or modified in the following filter steps.\n>> +\tcan be used or modified in the following filter steps except\n>> +\tthe commit filter, for technical reasons.\n>\n> I'll move that into the previous commit.\n\nYeah, the description of \"technical limitation\" is different from\nclarifying the disambiguating \"--\" in the documentation.\n\nI am curious what the \"technical reason\" really is, though ;-)\n"},{"id":"321831","messageId":"243a8308-6696-1494-49e9-ccd01acfaa46@gmail.com","threadId":"46106","inReplyTo":"xmqqk24l717a.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 2/2] add [--] to usage of filter-branch","fromName":"Andreas Heiduk","fromEmail":"asheiduk@gmail.com","sentAt":"2017-06-09T14:33:06Z","receivedAt":"2017-06-09T14:33:16Z","isPatch":true,"sender":{"key":"asheiduk@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9371344?v=4"},"body":"Am 09.06.2017 um 15:14 schrieb Junio C Hamano:\n> Andreas Heiduk <asheiduk@gmail.com> writes:\n> \n>> Am 03.06.2017 um 12:17 schrieb Andreas Heiduk:\n>>> Signed-off-by: Andreas Heiduk <asheiduk@gmail.com>\n>>> ---\n>>>  Documentation/git-filter-branch.txt | 3 ++-\n>>>  git-filter-branch.sh                | 2 +-\n>>>  2 files changed, 3 insertions(+), 2 deletions(-)\n>>>\n>>> diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt\n>>> index 45c849d8c..1efdda804 100644\n>>> --- a/Documentation/git-filter-branch.txt\n>>> +++ b/Documentation/git-filter-branch.txt\n>>> @@ -86,7 +86,8 @@ OPTIONS\n>>>  \tThis is not a real filter executed for each commit but a one\n>>>  \ttime setup just before the loop. Therefore no commit-specific\n>>>  \tvariables are defined yet.  Functions or variables defined here\n>>> -\tcan be used or modified in the following filter steps.\n>>> +\tcan be used or modified in the following filter steps except\n>>> +\tthe commit filter, for technical reasons.\n>>\n>> I'll move that into the previous commit.\n> \n> Yeah, the description of \"technical limitation\" is different from\n> clarifying the disambiguating \"--\" in the documentation.\n> \n> I am curious what the \"technical reason\" really is, though ;-)\n> \n\nWell, I just picked up the wording from the \"Filter\" section a \ncouple paragraphs above:\n\n> The filters are applied in the order as listed below.  The <command>\n> argument is always evaluated in the shell context using the 'eval' command\n> (with the notable exception of the commit filter, for technical reasons).\n\nBecause these reasons exist independently from my change I think I\ncan get away with just that snappy reference :-]\n"},{"id":"321897","messageId":"20170610085445.6470-1-asheiduk@gmail.com","threadId":"46106","inReplyTo":"20170603101755.13619-1-asheiduk@gmail.com","subject":"[PATCH v2 1/2] add setup step to filter-branch","fromName":"Andreas Heiduk","fromEmail":"asheiduk@gmail.com","sentAt":"2017-06-10T08:54:44Z","receivedAt":"2017-06-10T08:56:10Z","isPatch":true,"sender":{"key":"asheiduk@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9371344?v=4"},"body":"A specific `--setup` step in `git filter-branch` makes it much easier\nto define the initial values of variables used in the real filters.\nAlso sourcing/defining utility functions here instead of\n`--env-filter` improves performance and minimizes clogging the output\nin case of errors.\n\nSigned-off-by: Andreas Heiduk <asheiduk@gmail.com>\n---\n Documentation/git-filter-branch.txt | 17 ++++++++++++-----\n git-filter-branch.sh                | 18 +++++++++++++-----\n 2 files changed, 25 insertions(+), 10 deletions(-)\n\ndiff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt\nindex 7b695dbb7..9e5169aa6 100644\n--- a/Documentation/git-filter-branch.txt\n+++ b/Documentation/git-filter-branch.txt\n@@ -8,11 +8,11 @@ git-filter-branch - Rewrite branches\n SYNOPSIS\n --------\n [verse]\n-'git filter-branch' [--env-filter <command>] [--tree-filter <command>]\n-\t[--index-filter <command>] [--parent-filter <command>]\n-\t[--msg-filter <command>] [--commit-filter <command>]\n-\t[--tag-name-filter <command>] [--subdirectory-filter <directory>]\n-\t[--prune-empty]\n+'git filter-branch' [--setup <command>] [--env-filter <command>]\n+\t[--tree-filter <command>] [--index-filter <command>]\n+\t[--parent-filter <command>] [--msg-filter <command>]\n+\t[--commit-filter <command>] [--tag-name-filter <command>]\n+\t[--subdirectory-filter <directory>] [--prune-empty]\n \t[--original <namespace>] [-d <directory>] [-f | --force]\n \t[--] [<rev-list options>...]\n \n@@ -82,6 +82,13 @@ multiple commits.\n OPTIONS\n -------\n \n+--setup <command>::\n+\tThis is not a real filter executed for each commit but a one\n+\ttime setup just before the loop. Therefore no commit-specific\n+\tvariables are defined yet.  Functions or variables defined here\n+\tcan be used or modified in the following filter steps except\n+\tthe commit filter, for technical reasons.\n+\n --env-filter <command>::\n \tThis filter may be used if you only need to modify the environment\n \tin which the commit will be performed.  Specifically, you might\ndiff --git a/git-filter-branch.sh b/git-filter-branch.sh\nindex aafaf708d..2758ae5eb 100755\n--- a/git-filter-branch.sh\n+++ b/git-filter-branch.sh\n@@ -81,11 +81,12 @@ set_ident () {\n \tfinish_ident COMMITTER\n }\n \n-USAGE=\"[--env-filter <command>] [--tree-filter <command>]\n-\t[--index-filter <command>] [--parent-filter <command>]\n-\t[--msg-filter <command>] [--commit-filter <command>]\n-\t[--tag-name-filter <command>] [--subdirectory-filter <directory>]\n-\t[--original <namespace>] [-d <directory>] [-f | --force]\n+USAGE=\"[--setup <command>] [--env-filter <command>]\n+\t[--tree-filter <command>] [--index-filter <command>]\n+\t[--parent-filter <command>] [--msg-filter <command>]\n+\t[--commit-filter <command>] [--tag-name-filter <command>]\n+\t[--subdirectory-filter <directory>] [--original <namespace>]\n+\t[-d <directory>] [-f | --force]\n \t[<rev-list options>...]\"\n \n OPTIONS_SPEC=\n@@ -96,6 +97,7 @@ if [ \"$(is_bare_repository)\" = false ]; then\n fi\n \n tempdir=.git-rewrite\n+filter_setup=\n filter_env=\n filter_tree=\n filter_index=\n@@ -148,6 +150,9 @@ do\n \t-d)\n \t\ttempdir=\"$OPTARG\"\n \t\t;;\n+\t--setup)\n+\t\tfilter_setup=\"$OPTARG\"\n+\t\t;;\n \t--env-filter)\n \t\tfilter_env=\"$OPTARG\"\n \t\t;;\n@@ -317,6 +322,9 @@ else\n \tneed_index=\n fi\n \n+eval \"$filter_setup\" < /dev/null ||\n+\tdie \"filter setup failed: $filter_setup\"\n+\n while read commit parents; do\n \tgit_filter_branch__commit_count=$(($git_filter_branch__commit_count+1))\n \n-- \n2.13.0\n\n"},{"id":"321898","messageId":"20170610085445.6470-2-asheiduk@gmail.com","threadId":"46106","inReplyTo":"20170610085445.6470-1-asheiduk@gmail.com","subject":"[PATCH v2 2/2] add [--] to usage of filter-branch","fromName":"Andreas Heiduk","fromEmail":"asheiduk@gmail.com","sentAt":"2017-06-10T08:54:45Z","receivedAt":"2017-06-10T08:56:12Z","isPatch":true,"sender":{"key":"asheiduk@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9371344?v=4"},"body":"Signed-off-by: Andreas Heiduk <asheiduk@gmail.com>\n---\n git-filter-branch.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/git-filter-branch.sh b/git-filter-branch.sh\nindex 2758ae5eb..3a74602ef 100755\n--- a/git-filter-branch.sh\n+++ b/git-filter-branch.sh\n@@ -87,7 +87,7 @@ USAGE=\"[--setup <command>] [--env-filter <command>]\n \t[--commit-filter <command>] [--tag-name-filter <command>]\n \t[--subdirectory-filter <directory>] [--original <namespace>]\n \t[-d <directory>] [-f | --force]\n-\t[<rev-list options>...]\"\n+\t[--] [<rev-list options>...]\"\n \n OPTIONS_SPEC=\n . git-sh-setup\n-- \n2.13.0\n\n"}]}