Nguyễn Thái Ngọc Duy | 6fd09f5 | 2011-05-08 18:08:26 +0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='magic pathspec tests using git-add' |
| 4 | |
Ævar Arnfjörð Bjarmason | aecb85b | 2021-10-31 00:24:20 +0200 | [diff] [blame] | 5 | TEST_PASSES_SANITIZE_LEAK=true |
Nguyễn Thái Ngọc Duy | 6fd09f5 | 2011-05-08 18:08:26 +0700 | [diff] [blame] | 6 | . ./test-lib.sh |
| 7 | |
| 8 | test_expect_success 'setup' ' |
| 9 | mkdir sub anothersub && |
| 10 | : >sub/foo && |
| 11 | : >anothersub/foo |
| 12 | ' |
| 13 | |
| 14 | test_expect_success 'add :/' " |
| 15 | cat >expected <<-EOF && |
| 16 | add 'anothersub/foo' |
| 17 | add 'expected' |
| 18 | add 'sub/actual' |
| 19 | add 'sub/foo' |
| 20 | EOF |
| 21 | (cd sub && git add -n :/ >actual) && |
| 22 | test_cmp expected sub/actual |
| 23 | " |
| 24 | |
| 25 | cat >expected <<EOF |
| 26 | add 'anothersub/foo' |
| 27 | EOF |
| 28 | |
| 29 | test_expect_success 'add :/anothersub' ' |
| 30 | (cd sub && git add -n :/anothersub >actual) && |
| 31 | test_cmp expected sub/actual |
| 32 | ' |
| 33 | |
| 34 | test_expect_success 'add :/non-existent' ' |
| 35 | (cd sub && test_must_fail git add -n :/non-existent) |
| 36 | ' |
| 37 | |
| 38 | cat >expected <<EOF |
| 39 | add 'sub/foo' |
| 40 | EOF |
| 41 | |
Johannes Schindelin | 4539a89 | 2016-01-27 17:20:26 +0100 | [diff] [blame] | 42 | if test_have_prereq !MINGW && mkdir ":" 2>/dev/null |
Johannes Sixt | 650af7a | 2011-05-12 10:21:33 +0200 | [diff] [blame] | 43 | then |
| 44 | test_set_prereq COLON_DIR |
| 45 | fi |
| 46 | |
Alex Riesen | 038e2e5 | 2011-06-07 11:49:44 +0200 | [diff] [blame] | 47 | test_expect_success COLON_DIR 'a file with the same (long) magic name exists' ' |
| 48 | : >":(icase)ha" && |
| 49 | test_must_fail git add -n ":(icase)ha" && |
| 50 | git add -n "./:(icase)ha" |
| 51 | ' |
| 52 | |
Johannes Sixt | 650af7a | 2011-05-12 10:21:33 +0200 | [diff] [blame] | 53 | test_expect_success COLON_DIR 'a file with the same (short) magic name exists' ' |
Nguyễn Thái Ngọc Duy | 6fd09f5 | 2011-05-08 18:08:26 +0700 | [diff] [blame] | 54 | : >":/bar" && |
| 55 | test_must_fail git add -n :/bar && |
| 56 | git add -n "./:/bar" |
| 57 | ' |
| 58 | |
| 59 | test_done |