{"thread":{"id":"9727","subject":"[PATCH 1/2] filter-branch: provide the convenience functions also for commit filters","startedAt":"2007-08-31T19:05:36Z","lastAt":"2007-08-31T21:10:46Z","messageCount":3,"participants":["Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"52066","messageId":"Pine.LNX.4.64.0708312005070.28586@racer.site","threadId":"9727","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-08-31T19:05:36Z","receivedAt":"2007-08-31T19:05:36Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nMove the convenience functions to the top of git-filter-branch.sh, and\nreturn from the script when the environment variable SOURCE_FUNCTIONS is\nset.\n\nBy sourcing git-filter-branch with that variable set automatically, all\ncommit filters may access the convenience functions like \"map\".\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tEvidently, this is on top of my documentation cleanup...\n\n\tObviously, I think that these two changes are simple enough to be\n\tincluded even this late in the game for 1.5.3.  But I understand\n\tcompletely when people shout at me: \"What exactly does deep\n\tfeature freeze mean to you *knocks on Dscho's head*?\"\n\n Documentation/git-filter-branch.txt |    3 ---\n git-filter-branch.sh                |   25 +++++++++++++++----------\n t/t7003-filter-branch.sh            |   10 ++++++++++\n 3 files changed, 25 insertions(+), 13 deletions(-)\n\ndiff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt\nindex 4f89c04..456d52b 100644\n--- a/Documentation/git-filter-branch.txt\n+++ b/Documentation/git-filter-branch.txt\n@@ -112,9 +112,6 @@ OPTIONS\n As a special extension, the commit filter may emit multiple\n commit ids; in that case, ancestors of the original commit will\n have all of them as parents.\n-+\n-Note that the 'map' function is not available in the commit filter yet.\n-This will be changed in a future version.\n \n --tag-name-filter <command>::\n \tThis is the filter for rewriting tag names. When passed,\ndiff --git a/git-filter-branch.sh b/git-filter-branch.sh\nindex c166c97..3b041d8 100755\n--- a/git-filter-branch.sh\n+++ b/git-filter-branch.sh\n@@ -8,15 +8,6 @@\n # a new branch. You can specify a number of filters to modify the commits,\n # files and trees.\n \n-USAGE=\"[--env-filter <command>] [--tree-filter <command>] \\\n-[--index-filter <command>] [--parent-filter <command>] \\\n-[--msg-filter <command>] [--commit-filter <command>] \\\n-[--tag-name-filter <command>] [--subdirectory-filter <directory>] \\\n-[--original <namespace>] [-d <directory>] [-f | --force] \\\n-[<rev-list options>...]\"\n-\n-. git-sh-setup\n-\n warn () {\n         echo \"$*\" >&2\n }\n@@ -75,6 +66,20 @@ 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=\"[--env-filter <command>] [--tree-filter <command>] \\\n+[--index-filter <command>] [--parent-filter <command>] \\\n+[--msg-filter <command>] [--commit-filter <command>] \\\n+[--tag-name-filter <command>] [--subdirectory-filter <directory>] \\\n+[--original <namespace>] [-d <directory>] [-f | --force] \\\n+[<rev-list options>...]\"\n+\n+. git-sh-setup\n+\n tempdir=.git-rewrite\n filter_env=\n filter_tree=\n@@ -131,7 +136,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\"\ndiff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh\nindex bc6e2dd..c79853d 100755\n--- a/t/t7003-filter-branch.sh\n+++ b/t/t7003-filter-branch.sh\n@@ -159,4 +159,14 @@ test_expect_success 'barf on invalid name' '\n \t! git filter-branch -f HEAD^\n '\n \n+test_expect_success '\"map\" works in commit filter' '\n+\tgit filter-branch -f --commit-filter \"\\\n+\t\tparent=\\$(git rev-parse \\$GIT_COMMIT^) &&\n+\t\tmapped=\\$(map \\$parent) &&\n+\t\tactual=\\$(echo \\\"\\$@\\\" | sed \\\"s/^.*-p //\\\") &&\n+\t\ttest \\$mapped = \\$actual &&\n+\t\tgit commit-tree \\\"\\$@\\\";\" master~2..master &&\n+\tgit rev-parse --verify master\n+'\n+\n test_done\n-- \n1.5.3.rc7.18.gc9b59\n"},{"id":"52077","messageId":"7vzm07xvwa.fsf@gitster.siamese.dyndns.org","threadId":"9727","inReplyTo":"Pine.LNX.4.64.0708312005070.28586@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-08-31T20:59:49Z","receivedAt":"2007-08-31T20:59:49Z","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> \tObviously, I think that these two changes are simple enough to be\n> \tincluded even this late in the game for 1.5.3.  But I understand\n> \tcompletely when people shout at me: \"What exactly does deep\n> \tfeature freeze mean to you *knocks on Dscho's head*?\"\n\nMy response to those people who might shout is that this is\nmerely a step to complete a _new_ program that was not in _any_\nreleased version to make it feature complete.  You do not have\nto even pretend that filter-branch did not exist before -- it\nactually didn't.  The new part might be buggier than other\nparts, but that's the same way as any other software development\nprocess.  If the new 'map' does not work as advertised there is\nalways 1.5.3.1.\n\nThanks.\n"},{"id":"52082","messageId":"Pine.LNX.4.64.0708312209480.28586@racer.site","threadId":"9727","inReplyTo":"7vzm07xvwa.fsf@gitster.siamese.dyndns.org","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-08-31T21:10:46Z","receivedAt":"2007-08-31T21:10:46Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 31 Aug 2007, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > \tObviously, I think that these two changes are simple enough to be\n> > \tincluded even this late in the game for 1.5.3.  But I understand\n> > \tcompletely when people shout at me: \"What exactly does deep\n> > \tfeature freeze mean to you *knocks on Dscho's head*?\"\n> \n> My response to those people who might shout is that this is merely a \n> step to complete a _new_ program that was not in _any_ released version \n> to make it feature complete.  You do not have to even pretend that \n> filter-branch did not exist before -- it actually didn't.  The new part \n> might be buggier than other parts, but that's the same way as any other \n> software development process.  If the new 'map' does not work as \n> advertised there is always 1.5.3.1.\n\nThank you for your encouraging words.\n\nAnd yes, if there are bugs, I will be more than happy to fix them; and a \nreleased version always gets more eyes than an unreleased one.\n\nThanks,\nDscho\n"}]}