@matheusbsbs / matheus-bagliano / commits / cfabd6eee1
Fork 0

filter-branch: subdirectory filter needs --full-history

When two branches are merged that modify a subdirectory (possibly in different intermediate steps) such that both end up identical, then rev-list chooses only one branch. But when we filter history, we want to keep both branches. Therefore, we must use --full-history. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Sixt committed Jun 8, 2007 at 23:28 UTC cfabd6eee1745cfec58cfcb794ce8847e43b888a
2 files changed +22 -1
git-filter-branch.sh
+1 -1
@@ -323,7 +323,7 @@ case "$filter_subdir" in
323 ;;
324 *)
325 git-rev-list --reverse --topo-order --default HEAD \
326 - --parents "$@" -- "$filter_subdir"
326 + --parents --full-history "$@" -- "$filter_subdir"
327 esac > ../revs
328 commits=$(cat ../revs | wc -l | tr -d " ")
329
t/t7003-filter-branch.sh
+21
@@ -78,4 +78,25 @@ test_expect_success 'subdirectory filter result looks okay' '
78 ! git show sub:subdir
79 '
80
81 +test_expect_success 'setup and filter history that requires --full-history' '
82 + git checkout master &&
83 + mkdir subdir &&
84 + echo A > subdir/new &&
85 + git add subdir/new &&
86 + test_tick &&
87 + git commit -m "subdir on master" subdir/new &&
88 + git rm a &&
89 + test_tick &&
90 + git commit -m "again subdir on master" &&
91 + git merge branch &&
92 + git-filter-branch --subdirectory-filter subdir sub-master
93 +'
94 +
95 +test_expect_success 'subdirectory filter result looks okay' '
96 + test 3 = $(git-rev-list -1 --parents sub-master | wc -w) &&
97 + git show sub-master^:new &&
98 + git show sub-master^2:new &&
99 + ! git show sub:subdir
100 +'
101 +
102 test_done