diff options
author | Andreas Heiduk <asheiduk@gmail.com> | 2017-06-10 10:54:44 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-06-12 18:44:54 +0200 |
commit | 3b117f730185ec8acdc8f1b680b9f0a9b647fc0f (patch) | |
tree | 75bf64d5d8600a47921cfaa7a3d0bd7abc601c99 /git-filter-branch.sh | |
parent | Merge branch 'master' of git://bogomips.org/git-svn (diff) | |
download | git-3b117f730185ec8acdc8f1b680b9f0a9b647fc0f.tar.xz git-3b117f730185ec8acdc8f1b680b9f0a9b647fc0f.zip |
filter-branch: add `--setup` step
A `--setup` step in `git filter-branch` makes it much easier to
define the initial values of variables used in the real filters.
Also sourcing/defining utility functions here instead of
`--env-filter` improves performance and minimizes clogging the
output in case of errors.
Signed-off-by: Andreas Heiduk <asheiduk@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-filter-branch.sh')
-rwxr-xr-x | git-filter-branch.sh | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/git-filter-branch.sh b/git-filter-branch.sh index aafaf708da..2758ae5ebf 100755 --- a/git-filter-branch.sh +++ b/git-filter-branch.sh @@ -81,11 +81,12 @@ set_ident () { finish_ident COMMITTER } -USAGE="[--env-filter <command>] [--tree-filter <command>] - [--index-filter <command>] [--parent-filter <command>] - [--msg-filter <command>] [--commit-filter <command>] - [--tag-name-filter <command>] [--subdirectory-filter <directory>] - [--original <namespace>] [-d <directory>] [-f | --force] +USAGE="[--setup <command>] [--env-filter <command>] + [--tree-filter <command>] [--index-filter <command>] + [--parent-filter <command>] [--msg-filter <command>] + [--commit-filter <command>] [--tag-name-filter <command>] + [--subdirectory-filter <directory>] [--original <namespace>] + [-d <directory>] [-f | --force] [<rev-list options>...]" OPTIONS_SPEC= @@ -96,6 +97,7 @@ if [ "$(is_bare_repository)" = false ]; then fi tempdir=.git-rewrite +filter_setup= filter_env= filter_tree= filter_index= @@ -148,6 +150,9 @@ do -d) tempdir="$OPTARG" ;; + --setup) + filter_setup="$OPTARG" + ;; --env-filter) filter_env="$OPTARG" ;; @@ -317,6 +322,9 @@ else need_index= fi +eval "$filter_setup" < /dev/null || + die "filter setup failed: $filter_setup" + while read commit parents; do git_filter_branch__commit_count=$(($git_filter_branch__commit_count+1)) |