Skip to content

Commit 0906f6e

Browse files
mfwittengitster
authored andcommitted
filter-branch: Export variable `workdir' for --commit-filter
According to `git help filter-branch': --commit-filter <command> ... You can use the _map_ convenience function in this filter, and other convenience functions, too... ... However, it turns out that `map' hasn't been usable because it depends on the variable `workdir', which is not propogated to the environment of the shell that runs the commit-filter <command> because the shell is created via a simple-command rather than a compound-command subshell: @SHELL_PATH@ -c "$filter_commit" "git commit-tree" \ $(git write-tree) $parentstr < ../message > ../map/$commit || die "could not write rewritten commit" One solution is simply to export `workdir'. However, it seems rather heavy-handed to export `workdir' to the environments of all commands, so instead this commit exports `workdir' for only the duration of the shell command in question: workdir=$workdir @SHELL_PATH@ -c "$filter_commit" "git commit-tree" \ $(git write-tree) $parentstr < ../message > ../map/$commit || die "could not write rewritten commit" Signed-off-by: Michael Witten <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ae8044a commit 0906f6e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

git-filter-branch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ while read commit parents; do
363363
sed -e '1,/^$/d' <../commit | \
364364
eval "$filter_msg" > ../message ||
365365
die "msg filter failed: $filter_msg"
366-
@SHELL_PATH@ -c "$filter_commit" "git commit-tree" \
366+
workdir=$workdir @SHELL_PATH@ -c "$filter_commit" "git commit-tree" \
367367
$(git write-tree) $parentstr < ../message > ../map/$commit ||
368368
die "could not write rewritten commit"
369369
done <../revs

0 commit comments

Comments
 (0)