summaryrefslogtreecommitdiff
path: root/git-filter-branch.sh
diff options
context:
space:
mode:
authorCharles Bailey <cbailey32@bloomberg.net>2014-06-30 21:20:27 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-07-01 15:30:41 (GMT)
commit79bc4ef3686bc6795aa79a1d4aa6d3060a2cbd93 (patch)
tree51a1c1d703693b4e74a9bc728ea75e669cfbc1a0 /git-filter-branch.sh
parent341e7e8eda3dbeb6867f4f8f45b671201b807de5 (diff)
downloadgit-79bc4ef3686bc6795aa79a1d4aa6d3060a2cbd93.zip
git-79bc4ef3686bc6795aa79a1d4aa6d3060a2cbd93.tar.gz
git-79bc4ef3686bc6795aa79a1d4aa6d3060a2cbd93.tar.bz2
filter-branch: eliminate duplicate mapped parents
When multiple parents of a merge commit get mapped to the same commit, filter-branch used to pass all instances of the parent commit to the parent and commit filters and to "git commit-tree" or "git_commit_non_empty_tree". This can often happen when extracting a small project from a large repository; merges can join history with no commits on any branch which affect the paths being retained. Once the intermediate commits have been filtered out, all the immediate parents of the merge commit can end up being mapped to the same commit - either the original merge-base or an ancestor of it. "git commit-tree" would display an error but write the commit with the normalized parents in any case. "git_commit_non_empty_tree" would fail to notice that the commit being made was in fact a non-merge commit and would retain it even if a further pass with "--prune-empty" would discard the commit as empty. Ensure that duplicate parents are pruned before the parent filter to make "--prune-empty" idempotent, removing all empty non-merge commits in a singe pass. Signed-off-by: Charles Bailey <cbailey32@bloomberg.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-filter-branch.sh')
-rwxr-xr-xgit-filter-branch.sh8
1 files changed, 7 insertions, 1 deletions
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 86d6994..e6e99f5 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -332,7 +332,13 @@ while read commit parents; do
parentstr=
for parent in $parents; do
for reparent in $(map "$parent"); do
- parentstr="$parentstr -p $reparent"
+ case "$parentstr " in
+ *" -p $reparent "*)
+ ;;
+ *)
+ parentstr="$parentstr -p $reparent"
+ ;;
+ esac
done
done
if [ "$filter_parent" ]; then