diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-02-02 21:48:34 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-02-02 21:48:34 -0800 |
commit | 4b7acc186f33037178f4d137b2e6099c67492bde (patch) | |
tree | 5ee3edd5a5b85795b54e0b26cda06d4b09c4c1b4 | |
parent | 484e669aa772a3f6386d0f03f7c75af603801813 (diff) | |
parent | 1f7d57ff76dc21e9d4ff07b8dd26a1c926c4f29b (diff) | |
download | git-4b7acc186f33037178f4d137b2e6099c67492bde.tar.gz |
Merge branch 'ms/filter-branch-submodule'
* ms/filter-branch-submodule:
filter-branch: Add tests for submodules in tree-filter
filter-branch: Fix to allow replacing submodules with another content
-rwxr-xr-x | git-filter-branch.sh | 2 | ||||
-rwxr-xr-x | t/t7003-filter-branch.sh | 39 |
2 files changed, 40 insertions, 1 deletions
diff --git a/git-filter-branch.sh b/git-filter-branch.sh index 81fd3dba3d..e95845c0d6 100755 --- a/git-filter-branch.sh +++ b/git-filter-branch.sh @@ -331,7 +331,7 @@ while read commit parents; do die "tree filter failed: $filter_tree" ( - git diff-index -r --name-only $commit && + git diff-index -r --name-only --ignore-submodules $commit && git ls-files --others ) > "$tempdir"/tree-state || exit git update-index --add --replace --remove --stdin \ diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh index 9503875e97..0da13a8d6b 100755 --- a/t/t7003-filter-branch.sh +++ b/t/t7003-filter-branch.sh @@ -306,4 +306,43 @@ test_expect_success '--remap-to-ancestor with filename filters' ' test $orig_invariant = $(git rev-parse invariant) ' +test_expect_success 'setup submodule' ' + rm -fr ?* .git && + git init && + test_commit file && + mkdir submod && + submodurl="$PWD/submod" && + ( cd submod && + git init && + test_commit file-in-submod ) && + git submodule add "$submodurl" && + git commit -m "added submodule" && + test_commit add-file && + ( cd submod && test_commit add-in-submodule ) && + git add submod && + git commit -m "changed submodule" && + git branch original HEAD +' + +orig_head=`git show-ref --hash --head HEAD` + +test_expect_success 'rewrite submodule with another content' ' + git filter-branch --tree-filter "test -d submod && { + rm -rf submod && + git rm -rf --quiet submod && + mkdir submod && + : > submod/file + } || :" HEAD && + test $orig_head != `git show-ref --hash --head HEAD` +' + +test_expect_success 'replace submodule revision' ' + git reset --hard original && + git filter-branch -f --tree-filter \ + "if git ls-files --error-unmatch -- submod > /dev/null 2>&1 + then git update-index --cacheinfo 160000 0123456789012345678901234567890123456789 submod + fi" HEAD && + test $orig_head != `git show-ref --hash --head HEAD` +' + test_done |