{"thread":{"id":"9092","subject":"[PATCH 1/2] filter-branch: provide the convenience functions also for commit filters","startedAt":"2007-07-18T15:52:00Z","lastAt":"2007-07-19T01:25:17Z","messageCount":4,"participants":["Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"47744","messageId":"Pine.LNX.4.64.0707181650080.14781@racer.site","threadId":"9092","inReplyTo":null,"subject":"[PATCH 1/2] filter-branch: provide the convenience functions also for commit filters","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-18T15:52:00Z","receivedAt":"2007-07-18T15:52:00Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nBy sourcing git-filter-branch and stopping after the function definitions,\nthe commit filter can now access the convenience functions like \"map\".\n\nThis is done automatically if you specify a commit filter.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n git-filter-branch.sh |   12 ++++++++----\n 1 files changed, 8 insertions(+), 4 deletions(-)\n\ndiff --git a/git-filter-branch.sh b/git-filter-branch.sh\nindex 0d000ed..b574612 100755\n--- a/git-filter-branch.sh\n+++ b/git-filter-branch.sh\n@@ -8,9 +8,6 @@\n # a new branch. You can specify a number of filters to modify the commits,\n # files and trees.\n \n-USAGE=\"git-filter-branch [-d TEMPDIR] [FILTERS] DESTBRANCH [REV-RANGE]\"\n-. git-sh-setup\n-\n warn () {\n         echo \"$*\" >&2\n }\n@@ -69,6 +66,13 @@ set_ident () {\n \techo \"[ -n \\\"\\$GIT_${uid}_NAME\\\" ] || export GIT_${uid}_NAME=\\\"\\${GIT_${uid}_EMAIL%%@*}\\\"\"\n }\n \n+# This script can be sourced by the commit filter to get the functions\n+test \"a$SOURCE_FUNCTIONS\" = a1 && return\n+this_script=\"$(cd \"$(dirname \"$0\")\"; pwd)\"/$(basename \"$0\")\n+\n+USAGE=\"git-filter-branch [-d TEMPDIR] [FILTERS] DESTBRANCH [REV-RANGE]\"\n+. git-sh-setup\n+\n tempdir=.git-rewrite\n filter_env=\n filter_tree=\n@@ -118,7 +122,7 @@ do\n \t\tfilter_msg=\"$OPTARG\"\n \t\t;;\n \t--commit-filter)\n-\t\tfilter_commit=\"$OPTARG\"\n+\t\tfilter_commit=\"SOURCE_FUNCTIONS=1 . \\\"$this_script\\\"; $OPTARG\"\n \t\t;;\n \t--tag-name-filter)\n \t\tfilter_tag_name=\"$OPTARG\"\n-- \n1.5.3.rc1.16.g9d6f-dirty\n"},{"id":"47787","messageId":"7vfy3l5jo4.fsf@assigned-by-dhcp.cox.net","threadId":"9092","inReplyTo":"Pine.LNX.4.64.0707181650080.14781@racer.site","subject":"Re: [PATCH 1/2] filter-branch: provide the convenience functions also for commit filters","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-19T00:19:55Z","receivedAt":"2007-07-19T00:19:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> +this_script=\"$(cd \"$(dirname \"$0\")\"; pwd)\"/$(basename \"$0\")\n> ...\n> +\t\tfilter_commit=\"SOURCE_FUNCTIONS=1 . \\\"$this_script\\\"; $OPTARG\"\n\nHmmmmmm.\n\nCare to enlighten why this is not just:\n\n\tfilter_commit=\"SOURCE_FUNCTIONS=1 . \\\"$0\\\"; $OPTARG\"\n\nIs it because you cd(1) around in the script, and it can be\nrelative to where you started?\n\nIn either case, are you quoting potential funnies (such as '\"'\nor '\\\\') in \"$0\" sufficiently?  Exporting this_script variable,\nand changing the above to\n\n\tfilter_commit='SOURCE_FUNCTIONS=1 . \"$this_script\";'\" $OPTARG\"\n\nto arrange the shell that is invoked with 'sh -c' to expand its\nvalue would make it smaller problem, I suspect.\n"},{"id":"47792","messageId":"Pine.LNX.4.64.0707190215460.14781@racer.site","threadId":"9092","inReplyTo":"7vfy3l5jo4.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 1/2] filter-branch: provide the convenience functions also for commit filters","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-19T01:16:56Z","receivedAt":"2007-07-19T01:16:56Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 18 Jul 2007, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > +this_script=\"$(cd \"$(dirname \"$0\")\"; pwd)\"/$(basename \"$0\")\n> > ...\n> > +\t\tfilter_commit=\"SOURCE_FUNCTIONS=1 . \\\"$this_script\\\"; $OPTARG\"\n> \n> Hmmmmmm.\n> \n> Care to enlighten why this is not just:\n> \n> \tfilter_commit=\"SOURCE_FUNCTIONS=1 . \\\"$0\\\"; $OPTARG\"\n> \n> Is it because you cd(1) around in the script, and it can be\n> relative to where you started?\n\nYes.\n\n> In either case, are you quoting potential funnies (such as '\"'\n> or '\\\\') in \"$0\" sufficiently?  Exporting this_script variable,\n> and changing the above to\n> \n> \tfilter_commit='SOURCE_FUNCTIONS=1 . \"$this_script\";'\" $OPTARG\"\n> \n> to arrange the shell that is invoked with 'sh -c' to expand its\n> value would make it smaller problem, I suspect.\n\nWill do.  You know, I do have my problems with correct quoting, and the \nway I did it in this patch was always good enough for me.  Which does not \nmean much...\n\nCiao,\nDscho\n"},{"id":"47796","messageId":"Pine.LNX.4.64.0707190224010.14781@racer.site","threadId":"9092","inReplyTo":"7vfy3l5jo4.fsf@assigned-by-dhcp.cox.net","subject":"[REVISED PATCH 1/2] filter-branch: provide the convenience functions also for commit filters","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-19T01:25:17Z","receivedAt":"2007-07-19T01:25:17Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nBy sourcing git-filter-branch and stopping after the function definitions,\nthe commit filter can now access the convenience functions like \"map\".\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tOn Wed, 18 Jul 2007, Junio C Hamano wrote:\n\n\t> Exporting this_script variable, and changing the above to\n\t> \n\t> \tfilter_commit='SOURCE_FUNCTIONS=1 . \"$this_script\";'\" $OPTARG\"\n\t> \n\t> to arrange the shell that is invoked with 'sh -c' to expand its \n\t> value would make it smaller problem, I suspect.\n\n\tHereby done.\n\n\t<shameless plug>rebase -i rocks</shameless>\n\n git-filter-branch.sh |   13 +++++++++----\n 1 files changed, 9 insertions(+), 4 deletions(-)\n\ndiff --git a/git-filter-branch.sh b/git-filter-branch.sh\nindex 0d000ed..3113937 100755\n--- a/git-filter-branch.sh\n+++ b/git-filter-branch.sh\n@@ -8,9 +8,6 @@\n # a new branch. You can specify a number of filters to modify the commits,\n # files and trees.\n \n-USAGE=\"git-filter-branch [-d TEMPDIR] [FILTERS] DESTBRANCH [REV-RANGE]\"\n-. git-sh-setup\n-\n warn () {\n         echo \"$*\" >&2\n }\n@@ -69,6 +66,14 @@ set_ident () {\n \techo \"[ -n \\\"\\$GIT_${uid}_NAME\\\" ] || export GIT_${uid}_NAME=\\\"\\${GIT_${uid}_EMAIL%%@*}\\\"\"\n }\n \n+# This script can be sourced by the commit filter to get the functions\n+test \"a$SOURCE_FUNCTIONS\" = a1 && return\n+this_script=\"$(cd \"$(dirname \"$0\")\"; pwd)\"/$(basename \"$0\")\n+export this_script\n+\n+USAGE=\"git-filter-branch [-d TEMPDIR] [FILTERS] DESTBRANCH [REV-RANGE]\"\n+. git-sh-setup\n+\n tempdir=.git-rewrite\n filter_env=\n filter_tree=\n@@ -118,7 +123,7 @@ do\n \t\tfilter_msg=\"$OPTARG\"\n \t\t;;\n \t--commit-filter)\n-\t\tfilter_commit=\"$OPTARG\"\n+\t\tfilter_commit='SOURCE_FUNCTIONS=1 . \"$this_script\";'\" $OPTARG\"\n \t\t;;\n \t--tag-name-filter)\n \t\tfilter_tag_name=\"$OPTARG\"\n-- \n1.5.3.rc1.16.g9d6f-dirty\n"}]}