@matheusbsbs / matheus-bagliano / commits / 1f7d57ff76
Fork 0

filter-branch: Add tests for submodules in tree-filter

Add tests to make sure that: 1) a submodule can be removed and its content replaced with regular files ('rewrite submodule with another content'). This test passes only with the previous patch applied. 2) it is possible to replace submodule revision by direct index manipulation ('replace submodule revision'). Although it would be better to run such a filter in --index-filter, this test shows that this functionality is not broken by the previous patch. This succeeds both with and without the previous patch. Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michal Sojka committed Jan 28, 2010 at 10:08 UTC 1f7d57ff76dc21e9d4ff07b8dd26a1c926c4f29b
1 file changed +39
t/t7003-filter-branch.sh
+39
@@ -306,4 +306,43 @@ test_expect_success '--remap-to-ancestor with filename filters' '
306 test $orig_invariant = $(git rev-parse invariant)
307 '
308
309 +test_expect_success 'setup submodule' '
310 + rm -fr ?* .git &&
311 + git init &&
312 + test_commit file &&
313 + mkdir submod &&
314 + submodurl="$PWD/submod" &&
315 + ( cd submod &&
316 + git init &&
317 + test_commit file-in-submod ) &&
318 + git submodule add "$submodurl" &&
319 + git commit -m "added submodule" &&
320 + test_commit add-file &&
321 + ( cd submod && test_commit add-in-submodule ) &&
322 + git add submod &&
323 + git commit -m "changed submodule" &&
324 + git branch original HEAD
325 +'
326 +
327 +orig_head=`git show-ref --hash --head HEAD`
328 +
329 +test_expect_success 'rewrite submodule with another content' '
330 + git filter-branch --tree-filter "test -d submod && {
331 + rm -rf submod &&
332 + git rm -rf --quiet submod &&
333 + mkdir submod &&
334 + : > submod/file
335 + } || :" HEAD &&
336 + test $orig_head != `git show-ref --hash --head HEAD`
337 +'
338 +
339 +test_expect_success 'replace submodule revision' '
340 + git reset --hard original &&
341 + git filter-branch -f --tree-filter \
342 + "if git ls-files --error-unmatch -- submod > /dev/null 2>&1
343 + then git update-index --cacheinfo 160000 0123456789012345678901234567890123456789 submod
344 + fi" HEAD &&
345 + test $orig_head != `git show-ref --hash --head HEAD`
346 +'
347 +
348 test_done