#!/bin/sh global test_description := ''setup taking and sanitizing funny paths'' source ./test-lib.sh test_expect_success setup ' mkdir -p a/b/c a/e && D=$(pwd) && >a/b/c/d && >a/e/f ' test_expect_success 'git add (absolute)' ' git add "$D/a/b/c/d" && git ls-files >current && echo a/b/c/d >expect && test_cmp expect current ' test_expect_success 'git add (funny relative)' ' rm -f .git/index && ( cd a/b && git add "../e/./f" ) && git ls-files >current && echo a/e/f >expect && test_cmp expect current ' test_expect_success 'git rm (absolute)' ' rm -f .git/index && git add a && git rm -f --cached "$D/a/b/c/d" && git ls-files >current && echo a/e/f >expect && test_cmp expect current ' test_expect_success 'git rm (funny relative)' ' rm -f .git/index && git add a && ( cd a/b && git rm -f --cached "../e/./f" ) && git ls-files >current && echo a/b/c/d >expect && test_cmp expect current ' test_expect_success 'git ls-files (absolute)' ' rm -f .git/index && git add a && git ls-files "$D/a/e/../b" >current && echo a/b/c/d >expect && test_cmp expect current ' test_expect_success 'git ls-files (relative #1)' ' rm -f .git/index && git add a && ( cd a/b && git ls-files "../b/c" ) >current && echo c/d >expect && test_cmp expect current ' test_expect_success 'git ls-files (relative #2)' ' rm -f .git/index && git add a && ( cd a/b && git ls-files --full-name "../e/f" ) >current && echo a/e/f >expect && test_cmp expect current ' test_expect_success 'git ls-files (relative #3)' ' rm -f .git/index && git add a && ( cd a/b && git ls-files "../e/f" ) >current && echo ../e/f >expect && test_cmp expect current ' test_expect_success 'commit using absolute path names' ' git commit -m "foo" && echo aa >>a/b/c/d && git commit -m "aa" "$(pwd)/a/b/c/d" ' test_expect_success 'log using absolute path names' ' echo bb >>a/b/c/d && git commit -m "bb" "$(pwd)/a/b/c/d" && git log a/b/c/d >f1.txt && git log "$(pwd)/a/b/c/d" >f2.txt && test_cmp f1.txt f2.txt ' test_expect_success 'blame using absolute path names' ' git blame a/b/c/d >f1.txt && git blame "$(pwd)/a/b/c/d" >f2.txt && test_cmp f1.txt f2.txt ' test_expect_success 'setup deeper work tree' ' test_create_repo tester ' test_expect_success 'add a directory outside the work tree' '( cd tester && d1="$(cd .. ; pwd)" && test_must_fail git add "$d1" )' test_expect_success 'add a file outside the work tree, nasty case 1' '( cd tester && f="$(pwd)x" && echo "$f" && touch "$f" && test_must_fail git add "$f" )' test_expect_success 'add a file outside the work tree, nasty case 2' '( cd tester && f="$(pwd | sed "s/.$//")x" && echo "$f" && touch "$f" && test_must_fail git add "$f" )' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"setup taking and sanitizing funny paths">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(setup)} { (SQ <"\n"> <"\n"> <"\tmkdir -p a/b/c a/e &&\n"> <"\tD=$(pwd) &&\n"> <"\t>a/b/c/d &&\n"> <"\t>a/e/f\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git add (absolute)">)} { (SQ <"\n"> <"\n"> <"\tgit add \"$D/a/b/c/d\" &&\n"> <"\tgit ls-files >current &&\n"> <"\techo a/b/c/d >expect &&\n"> <"\ttest_cmp expect current\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git add (funny relative)">)} { (SQ <"\n"> <"\n"> <"\trm -f .git/index &&\n"> <"\t(\n"> <"\t\tcd a/b &&\n"> <"\t\tgit add \"../e/./f\"\n"> <"\t) &&\n"> <"\tgit ls-files >current &&\n"> <"\techo a/e/f >expect &&\n"> <"\ttest_cmp expect current\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git rm (absolute)">)} { (SQ <"\n"> <"\n"> <"\trm -f .git/index &&\n"> <"\tgit add a &&\n"> <"\tgit rm -f --cached \"$D/a/b/c/d\" &&\n"> <"\tgit ls-files >current &&\n"> <"\techo a/e/f >expect &&\n"> <"\ttest_cmp expect current\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git rm (funny relative)">)} { (SQ <"\n"> <"\n"> <"\trm -f .git/index &&\n"> <"\tgit add a &&\n"> <"\t(\n"> <"\t\tcd a/b &&\n"> <"\t\tgit rm -f --cached \"../e/./f\"\n"> <"\t) &&\n"> <"\tgit ls-files >current &&\n"> <"\techo a/b/c/d >expect &&\n"> <"\ttest_cmp expect current\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git ls-files (absolute)">)} { (SQ <"\n"> <"\n"> <"\trm -f .git/index &&\n"> <"\tgit add a &&\n"> <"\tgit ls-files \"$D/a/e/../b\" >current &&\n"> <"\techo a/b/c/d >expect &&\n"> <"\ttest_cmp expect current\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git ls-files (relative #1)">)} { (SQ <"\n"> <"\n"> <"\trm -f .git/index &&\n"> <"\tgit add a &&\n"> <"\t(\n"> <"\t\tcd a/b &&\n"> <"\t\tgit ls-files \"../b/c\"\n"> <"\t) >current &&\n"> <"\techo c/d >expect &&\n"> <"\ttest_cmp expect current\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git ls-files (relative #2)">)} { (SQ <"\n"> <"\n"> <"\trm -f .git/index &&\n"> <"\tgit add a &&\n"> <"\t(\n"> <"\t\tcd a/b &&\n"> <"\t\tgit ls-files --full-name \"../e/f\"\n"> <"\t) >current &&\n"> <"\techo a/e/f >expect &&\n"> <"\ttest_cmp expect current\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"git ls-files (relative #3)">)} { (SQ <"\n"> <"\n"> <"\trm -f .git/index &&\n"> <"\tgit add a &&\n"> <"\t(\n"> <"\t\tcd a/b &&\n"> <"\t\tgit ls-files \"../e/f\"\n"> <"\t) >current &&\n"> <"\techo ../e/f >expect &&\n"> <"\ttest_cmp expect current\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"commit using absolute path names">)} { (SQ <"\n"> <"\tgit commit -m \"foo\" &&\n"> <"\techo aa >>a/b/c/d &&\n"> <"\tgit commit -m \"aa\" \"$(pwd)/a/b/c/d\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"log using absolute path names">)} { (SQ <"\n"> <"\techo bb >>a/b/c/d &&\n"> <"\tgit commit -m \"bb\" \"$(pwd)/a/b/c/d\" &&\n"> <"\n"> <"\tgit log a/b/c/d >f1.txt &&\n"> <"\tgit log \"$(pwd)/a/b/c/d\" >f2.txt &&\n"> <"\ttest_cmp f1.txt f2.txt\n"> ) } ) (C {(test_expect_success)} {(SQ <"blame using absolute path names">)} { (SQ <"\n"> <"\tgit blame a/b/c/d >f1.txt &&\n"> <"\tgit blame \"$(pwd)/a/b/c/d\" >f2.txt &&\n"> <"\ttest_cmp f1.txt f2.txt\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup deeper work tree">)} {(SQ <"\n"> <"\ttest_create_repo tester\n">)} ) (C {(test_expect_success)} {(SQ <"add a directory outside the work tree">)} { (SQ <"(\n"> <"\tcd tester &&\n"> <"\td1=\"$(cd .. ; pwd)\" &&\n"> <"\ttest_must_fail git add \"$d1\"\n"> <")"> ) } ) (C {(test_expect_success)} {(SQ <"add a file outside the work tree, nasty case 1">)} { (SQ <"(\n"> <"\tcd tester &&\n"> <"\tf=\"$(pwd)x\" &&\n"> <"\techo \"$f\" &&\n"> <"\ttouch \"$f\" &&\n"> <"\ttest_must_fail git add \"$f\"\n"> <")"> ) } ) (C {(test_expect_success)} {(SQ <"add a file outside the work tree, nasty case 2">)} { (SQ <"(\n"> <"\tcd tester &&\n"> <"\tf=\"$(pwd | sed \"s/.$//\")x\" &&\n"> <"\techo \"$f\" &&\n"> <"\ttouch \"$f\" &&\n"> <"\ttest_must_fail git add \"$f\"\n"> <")"> ) } ) (C {(test_done)}) ] )