#!/bin/sh global test_description := ''checkout must not overwrite an untracked objects'' source ./test-lib.sh test_expect_success 'setup' ' mkdir -p a/b/c && >a/b/c/d && git add -A && git commit -m base && git tag start ' test_expect_success 'create a commit where dir a/b changed to file' ' git checkout -b file && rm -rf a/b && >a/b && git add -A && git commit -m "dir to file" ' test_expect_success 'checkout commit with dir must not remove untracked a/b' ' git rm --cached a/b && git commit -m "un-track the file" && test_must_fail git checkout start && test -f a/b ' test_expect_success 'create a commit where dir a/b changed to symlink' ' rm -rf a/b && # cleanup if previous test failed git checkout -f -b symlink start && rm -rf a/b && git add -A && test_ln_s_add foo a/b && git commit -m "dir to symlink" ' test_expect_success 'checkout commit with dir must not remove untracked a/b' ' git rm --cached a/b && git commit -m "un-track the symlink" && test_must_fail git checkout start ' test_expect_success SYMLINKS 'the symlink remained' ' test -h a/b ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"checkout must not overwrite an untracked objects">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ )} { (SQ <"\n"> <"\n"> <"\tmkdir -p a/b/c &&\n"> <"\t>a/b/c/d &&\n"> <"\tgit add -A &&\n"> <"\tgit commit -m base &&\n"> <"\tgit tag start\n"> ) } ) (C {(test_expect_success)} {(SQ <"create a commit where dir a/b changed to file">)} { (SQ <"\n"> <"\n"> <"\tgit checkout -b file &&\n"> <"\trm -rf a/b &&\n"> <"\t>a/b &&\n"> <"\tgit add -A &&\n"> <"\tgit commit -m \"dir to file\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"checkout commit with dir must not remove untracked a/b">)} { (SQ <"\n"> <"\n"> <"\tgit rm --cached a/b &&\n"> <"\tgit commit -m \"un-track the file\" &&\n"> <"\ttest_must_fail git checkout start &&\n"> <"\ttest -f a/b\n"> ) } ) (C {(test_expect_success)} {(SQ <"create a commit where dir a/b changed to symlink">)} { (SQ <"\n"> <"\n"> <"\trm -rf a/b &&\t# cleanup if previous test failed\n"> <"\tgit checkout -f -b symlink start &&\n"> <"\trm -rf a/b &&\n"> <"\tgit add -A &&\n"> <"\ttest_ln_s_add foo a/b &&\n"> <"\tgit commit -m \"dir to symlink\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"checkout commit with dir must not remove untracked a/b">)} { (SQ <"\n"> <"\n"> <"\tgit rm --cached a/b &&\n"> <"\tgit commit -m \"un-track the symlink\" &&\n"> <"\ttest_must_fail git checkout start\n"> ) } ) (C {(test_expect_success)} {(SYMLINKS)} {(SQ <"the symlink remained">)} {(SQ <"\n"> <"\n"> <"\ttest -h a/b\n">)} ) (C {(test_done)}) ] )