#!/bin/sh # # Copyright (c) 2009 Eric Wong global test_description := ''git svn creates empty directories'' source ./lib-git-svn.sh test_expect_success 'initialize repo' ' for i in a b c d d/e d/e/f "weird file name" do svn_cmd mkdir -m "mkdir $i" "$svnrepo"/"$i" done ' test_expect_success 'clone' 'git svn clone "$svnrepo" cloned' test_expect_success 'empty directories exist' ' ( cd cloned && for i in a b c d d/e d/e/f "weird file name" do if ! test -d "$i" then echo >&2 "$i does not exist" exit 1 fi done ) ' test_expect_success 'option automkdirs set to false' ' ( git svn init "$svnrepo" cloned-no-mkdirs && cd cloned-no-mkdirs && git config svn-remote.svn.automkdirs false && git svn fetch && for i in a b c d d/e d/e/f "weird file name" do if test -d "$i" then echo >&2 "$i exists" exit 1 fi done ) ' test_expect_success 'more emptiness' ' svn_cmd mkdir -m "bang bang" "$svnrepo"/"! !" ' test_expect_success 'git svn rebase creates empty directory' ' ( cd cloned && git svn rebase ) && test -d cloned/"! !" ' test_expect_success 'git svn mkdirs recreates empty directories' ' ( cd cloned && rm -r * && git svn mkdirs && for i in a b c d d/e d/e/f "weird file name" "! !" do if ! test -d "$i" then echo >&2 "$i does not exist" exit 1 fi done ) ' test_expect_success 'git svn mkdirs -r works' ' ( cd cloned && rm -r * && git svn mkdirs -r7 && for i in a b c d d/e d/e/f "weird file name" do if ! test -d "$i" then echo >&2 "$i does not exist" exit 1 fi done if test -d "! !" then echo >&2 "$i should not exist" exit 1 fi git svn mkdirs -r8 && if ! test -d "! !" then echo >&2 "$i not exist" exit 1 fi ) ' test_expect_success 'initialize trunk' ' for i in trunk trunk/a trunk/"weird file name" do svn_cmd mkdir -m "mkdir $i" "$svnrepo"/"$i" done ' test_expect_success 'clone trunk' 'git svn clone -s "$svnrepo" trunk' test_expect_success 'empty directories in trunk exist' ' ( cd trunk && for i in a "weird file name" do if ! test -d "$i" then echo >&2 "$i does not exist" exit 1 fi done ) ' test_expect_success 'remove a top-level directory from svn' ' svn_cmd rm -m "remove d" "$svnrepo"/d ' test_expect_success 'removed top-level directory does not exist' ' git svn clone "$svnrepo" removed && test ! -e removed/d ' global unhandled := '.git/svn/refs/remotes/git-svn/unhandled.log' test_expect_success 'git svn gc-ed files work' ' ( cd removed && git svn gc && : Compress::Zlib may not be available && if test -f "$unhandled".gz then svn_cmd mkdir -m gz "$svnrepo"/gz && git reset --hard $(git rev-list HEAD | tail -1) && git svn rebase && test -f "$unhandled".gz && test -f "$unhandled" && for i in a b c "weird file name" gz "! !" do if ! test -d "$i" then echo >&2 "$i does not exist" exit 1 fi done fi ) ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"git svn creates empty directories">)} spids: [10] ) ] spids: [10] ) (C {(.)} {(./lib-git-svn.sh)}) (C {(test_expect_success)} {(SQ <"initialize repo">)} { (SQ <"\n"> <"\tfor i in a b c d d/e d/e/f \"weird file name\"\n"> <"\tdo\n"> <"\t\tsvn_cmd mkdir -m \"mkdir $i\" \"$svnrepo\"/\"$i\"\n"> <"\tdone\n"> ) } ) (C {(test_expect_success)} {(SQ )} {(SQ <"git svn clone \"$svnrepo\" cloned">)}) (C {(test_expect_success)} {(SQ <"empty directories exist">)} { (SQ <"\n"> <"\t(\n"> <"\t\tcd cloned &&\n"> <"\t\tfor i in a b c d d/e d/e/f \"weird file name\"\n"> <"\t\tdo\n"> <"\t\t\tif ! test -d \"$i\"\n"> <"\t\t\tthen\n"> <"\t\t\t\techo >&2 \"$i does not exist\"\n"> <"\t\t\t\texit 1\n"> <"\t\t\tfi\n"> <"\t\tdone\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"option automkdirs set to false">)} { (SQ <"\n"> <"\t(\n"> <"\t\tgit svn init \"$svnrepo\" cloned-no-mkdirs &&\n"> <"\t\tcd cloned-no-mkdirs &&\n"> <"\t\tgit config svn-remote.svn.automkdirs false &&\n"> <"\t\tgit svn fetch &&\n"> <"\t\tfor i in a b c d d/e d/e/f \"weird file name\"\n"> <"\t\tdo\n"> <"\t\t\tif test -d \"$i\"\n"> <"\t\t\tthen\n"> <"\t\t\t\techo >&2 \"$i exists\"\n"> <"\t\t\t\texit 1\n"> <"\t\t\tfi\n"> <"\t\tdone\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"more emptiness">)} {(SQ <"\n"> <"\tsvn_cmd mkdir -m \"bang bang\" \"$svnrepo\"/\"! !\"\n">)} ) (C {(test_expect_success)} {(SQ <"git svn rebase creates empty directory">)} {(SQ <"\n"> <"\t( cd cloned && git svn rebase ) &&\n"> <"\ttest -d cloned/\"! !\"\n">)} ) (C {(test_expect_success)} {(SQ <"git svn mkdirs recreates empty directories">)} { (SQ <"\n"> <"\t(\n"> <"\t\tcd cloned &&\n"> <"\t\trm -r * &&\n"> <"\t\tgit svn mkdirs &&\n"> <"\t\tfor i in a b c d d/e d/e/f \"weird file name\" \"! !\"\n"> <"\t\tdo\n"> <"\t\t\tif ! test -d \"$i\"\n"> <"\t\t\tthen\n"> <"\t\t\t\techo >&2 \"$i does not exist\"\n"> <"\t\t\t\texit 1\n"> <"\t\t\tfi\n"> <"\t\tdone\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"git svn mkdirs -r works">)} { (SQ <"\n"> <"\t(\n"> <"\t\tcd cloned &&\n"> <"\t\trm -r * &&\n"> <"\t\tgit svn mkdirs -r7 &&\n"> <"\t\tfor i in a b c d d/e d/e/f \"weird file name\"\n"> <"\t\tdo\n"> <"\t\t\tif ! test -d \"$i\"\n"> <"\t\t\tthen\n"> <"\t\t\t\techo >&2 \"$i does not exist\"\n"> <"\t\t\t\texit 1\n"> <"\t\t\tfi\n"> <"\t\tdone\n"> <"\n"> <"\t\tif test -d \"! !\"\n"> <"\t\tthen\n"> <"\t\t\techo >&2 \"$i should not exist\"\n"> <"\t\t\texit 1\n"> <"\t\tfi\n"> <"\n"> <"\t\tgit svn mkdirs -r8 &&\n"> <"\t\tif ! test -d \"! !\"\n"> <"\t\tthen\n"> <"\t\t\techo >&2 \"$i not exist\"\n"> <"\t\t\texit 1\n"> <"\t\tfi\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"initialize trunk">)} { (SQ <"\n"> <"\tfor i in trunk trunk/a trunk/\"weird file name\"\n"> <"\tdo\n"> <"\t\tsvn_cmd mkdir -m \"mkdir $i\" \"$svnrepo\"/\"$i\"\n"> <"\tdone\n"> ) } ) (C {(test_expect_success)} {(SQ <"clone trunk">)} {(SQ <"git svn clone -s \"$svnrepo\" trunk">)}) (C {(test_expect_success)} {(SQ <"empty directories in trunk exist">)} { (SQ <"\n"> <"\t(\n"> <"\t\tcd trunk &&\n"> <"\t\tfor i in a \"weird file name\"\n"> <"\t\tdo\n"> <"\t\t\tif ! test -d \"$i\"\n"> <"\t\t\tthen\n"> <"\t\t\t\techo >&2 \"$i does not exist\"\n"> <"\t\t\t\texit 1\n"> <"\t\t\tfi\n"> <"\t\tdone\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"remove a top-level directory from svn">)} {(SQ <"\n"> <"\tsvn_cmd rm -m \"remove d\" \"$svnrepo\"/d\n">)} ) (C {(test_expect_success)} {(SQ <"removed top-level directory does not exist">)} {(SQ <"\n"> <"\tgit svn clone \"$svnrepo\" removed &&\n"> <"\ttest ! -e removed/d\n"> <"\n">)} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:unhandled) op: Equal rhs: {(.git/svn/refs/remotes/git-svn/unhandled.log)} spids: [252] ) ] spids: [252] ) (C {(test_expect_success)} {(SQ <"git svn gc-ed files work">)} { (SQ <"\n"> <"\t(\n"> <"\t\tcd removed &&\n"> <"\t\tgit svn gc &&\n"> <"\t\t: Compress::Zlib may not be available &&\n"> <"\t\tif test -f \"$unhandled\".gz\n"> <"\t\tthen\n"> <"\t\t\tsvn_cmd mkdir -m gz \"$svnrepo\"/gz &&\n"> <"\t\t\tgit reset --hard $(git rev-list HEAD | tail -1) &&\n"> <"\t\t\tgit svn rebase &&\n"> <"\t\t\ttest -f \"$unhandled\".gz &&\n"> <"\t\t\ttest -f \"$unhandled\" &&\n"> <"\t\t\tfor i in a b c \"weird file name\" gz \"! !\"\n"> <"\t\t\tdo\n"> <"\t\t\t\tif ! test -d \"$i\"\n"> <"\t\t\t\tthen\n"> <"\t\t\t\t\techo >&2 \"$i does not exist\"\n"> <"\t\t\t\t\texit 1\n"> <"\t\t\t\tfi\n"> <"\t\t\tdone\n"> <"\t\tfi\n"> <"\t)\n"> ) } ) (C {(test_done)}) ] )