{"thread":{"id":"28035","subject":"[PATCH] filter-branch: Export variable `workdir' for --commit-filter","startedAt":"2011-08-07T02:03:45Z","lastAt":"2011-08-08T19:11:09Z","messageCount":2,"participants":["Michael Witten","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"173075","messageId":"f06dd070abcc485e98c054ec3ee298f9-mfwitten@gmail.com","threadId":"28035","inReplyTo":null,"subject":"[PATCH] filter-branch: Export variable `workdir' for --commit-filter","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":null,"receivedAt":"2011-08-07T02:03:45Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"According to `git help filter-branch':\n\n       --commit-filter <command>\n           ...\n           You can use the _map_ convenience function in this filter,\n           and other convenience functions, too...\n           ...\n\nHowever, it turns out that `map' hasn't been usable because it depends\non the variable `workdir', which is not propogated to the environment\nof the shell that runs the commit-filter <command> because the\nshell is created via a simple-command rather than a compound-command\nsubshell:\n\n @SHELL_PATH@ -c \"$filter_commit\" \"git commit-tree\" \\\n                 $(git write-tree) $parentstr < ../message > ../map/$commit ||\n                         die \"could not write rewritten commit\"\n\nOne solution is simply to export `workdir'. However, it seems rather\nheavy-handed to export `workdir' to the environments of all commands,\nso instead this commit exports `workdir' for only the duration of the\nshell command in question:\n\n workdir=$workdir @SHELL_PATH@ -c \"$filter_commit\" \"git commit-tree\" \\\n                 $(git write-tree) $parentstr < ../message > ../map/$commit ||\n                         die \"could not write rewritten commit\"\n\nSigned-off-by: Michael Witten <mfwitten@gmail.com>\n---\n git-filter-branch.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git-filter-branch.sh b/git-filter-branch.sh\nindex 962a93b..6b5f225 100755\n--- a/git-filter-branch.sh\n+++ b/git-filter-branch.sh\n@@ -363,7 +363,7 @@ while read commit parents; do\n \tsed -e '1,/^$/d' <../commit | \\\n \t\teval \"$filter_msg\" > ../message ||\n \t\t\tdie \"msg filter failed: $filter_msg\"\n-\t@SHELL_PATH@ -c \"$filter_commit\" \"git commit-tree\" \\\n+\tworkdir=$workdir @SHELL_PATH@ -c \"$filter_commit\" \"git commit-tree\" \\\n \t\t$(git write-tree) $parentstr < ../message > ../map/$commit ||\n \t\t\tdie \"could not write rewritten commit\"\n done <../revs\n-- \n1.7.6.134.gcf13f6\n"},{"id":"173151","messageId":"7vzkjjwvuk.fsf@alter.siamese.dyndns.org","threadId":"28035","inReplyTo":"f06dd070abcc485e98c054ec3ee298f9-mfwitten@gmail.com","subject":"Re: [PATCH] filter-branch: Export variable `workdir' for --commit-filter","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-08-08T19:11:09Z","receivedAt":"2011-08-08T19:11:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Witten <mfwitten@gmail.com> writes:\n\n> According to `git help filter-branch':\n>\n>        --commit-filter <command>\n>            ...\n>            You can use the _map_ convenience function in this filter,\n>            and other convenience functions, too...\n>            ...\n>\n> However, it turns out that `map' hasn't been usable because it depends\n> on the variable `workdir', which is not propogated to the environment\n> of the shell that runs the commit-filter <command>...\n\nThanks.\n"}]}