Code

filter-branch: subdirectory filter needs --full-history
authorJohannes Sixt <johannes.sixt@telecom.at>
Fri, 8 Jun 2007 21:28:50 +0000 (23:28 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sat, 9 Jun 2007 19:24:16 +0000 (12:24 -0700)
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>
git-filter-branch.sh
t/t7003-filter-branch.sh

index cb43b59740e763da922ac93cd1fbace64c07acab..bfd118cd3ba070bbcc611be4c8d6adcd2a4d294a 100755 (executable)
@@ -323,7 +323,7 @@ case "$filter_subdir" in
        ;;
 *)
        git-rev-list --reverse --topo-order --default HEAD \
-               --parents "$@" -- "$filter_subdir"
+               --parents --full-history "$@" -- "$filter_subdir"
 esac > ../revs
 commits=$(cat ../revs | wc -l | tr -d " ")
 
index 292b83766d3de23cba5112af8ef8740f8839d92b..0fabe4904f7bfb942ba24287862d054e9a4d174c 100755 (executable)
@@ -78,4 +78,25 @@ test_expect_success 'subdirectory filter result looks okay' '
        ! git show sub:subdir
 '
 
+test_expect_success 'setup and filter history that requires --full-history' '
+       git checkout master &&
+       mkdir subdir &&
+       echo A > subdir/new &&
+       git add subdir/new &&
+       test_tick &&
+       git commit -m "subdir on master" subdir/new &&
+       git rm a &&
+       test_tick &&
+       git commit -m "again subdir on master" &&
+       git merge branch &&
+       git-filter-branch --subdirectory-filter subdir sub-master
+'
+
+test_expect_success 'subdirectory filter result looks okay' '
+       test 3 = $(git-rev-list -1 --parents sub-master | wc -w) &&
+       git show sub-master^:new &&
+       git show sub-master^2:new &&
+       ! git show sub:subdir
+'
+
 test_done