t3703, t4208: add test cases for magic pathspec
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
May 8, 2011 at 18:08 UTC
6fd09f537c7a1b0a92587aa6f00ef7302a546a1e
3 files changed
+93
Documentation/glossary-content.txt
+3
@@ -324,6 +324,9 @@ top `/`;;
324
Currently only the slash `/` is recognized as the "magic signature",
325
but it is envisioned that we will support more types of magic in later
326
versions of git.
327
++
328
+A pathspec with only a colon means "there is no pathspec". This form
329
+should not be combined with other pathspec.
330
331
[[def_parent]]parent::
332
A <<def_commit_object,commit object>> contains a (possibly empty) list
t/t3703-add-magic-pathspec.sh
new
+54
@@ -0,0 +1,54 @@
1
+#!/bin/sh
2
+
3
+test_description='magic pathspec tests using git-add'
4
+
5
+. ./test-lib.sh
6
+
7
+test_expect_success 'setup' '
8
+ mkdir sub anothersub &&
9
+ : >sub/foo &&
10
+ : >anothersub/foo
11
+'
12
+
13
+test_expect_success 'add :/' "
14
+ cat >expected <<-EOF &&
15
+ add 'anothersub/foo'
16
+ add 'expected'
17
+ add 'sub/actual'
18
+ add 'sub/foo'
19
+ EOF
20
+ (cd sub && git add -n :/ >actual) &&
21
+ test_cmp expected sub/actual
22
+"
23
+
24
+cat >expected <<EOF
25
+add 'anothersub/foo'
26
+EOF
27
+
28
+test_expect_success 'add :/anothersub' '
29
+ (cd sub && git add -n :/anothersub >actual) &&
30
+ test_cmp expected sub/actual
31
+'
32
+
33
+test_expect_success 'add :/non-existent' '
34
+ (cd sub && test_must_fail git add -n :/non-existent)
35
+'
36
+
37
+cat >expected <<EOF
38
+add 'sub/foo'
39
+EOF
40
+
41
+test_expect_success 'a file with the same (long) magic name exists' '
42
+ : >":(icase)ha" &&
43
+ test_must_fail git add -n ":(icase)ha" &&
44
+ git add -n "./:(icase)ha"
45
+'
46
+
47
+test_expect_success 'a file with the same (short) magic name exists' '
48
+ mkdir ":" &&
49
+ : >":/bar" &&
50
+ test_must_fail git add -n :/bar &&
51
+ git add -n "./:/bar"
52
+'
53
+
54
+test_done
t/t4208-log-magic-pathspec.sh
new
+36
@@ -0,0 +1,36 @@
1
+#!/bin/sh
2
+
3
+test_description='magic pathspec tests using git-log'
4
+
5
+. ./test-lib.sh
6
+
7
+test_expect_success 'setup' '
8
+ test_commit initial &&
9
+ test_tick &&
10
+ git commit --allow-empty -m empty &&
11
+ mkdir sub
12
+'
13
+
14
+test_expect_success '"git log :/" should be ambiguous' '
15
+ test_must_fail git log :/ 2>error &&
16
+ grep ambiguous error
17
+'
18
+
19
+test_expect_success '"git log :" should be ambiguous' '
20
+ test_must_fail git log : 2>error &&
21
+ grep ambiguous error
22
+'
23
+
24
+test_expect_success 'git log -- :' '
25
+ git log -- :
26
+'
27
+
28
+test_expect_success 'git log HEAD -- :/' '
29
+ cat >expected <<-EOF &&
30
+ 24b24cf initial
31
+ EOF
32
+ (cd sub && git log --oneline HEAD -- :/ >../actual) &&
33
+ test_cmp expected actual
34
+'
35
+
36
+test_done