~ubuntu-branches/ubuntu/intrepid/git-core/intrepid-security

« back to all changes in this revision

Viewing changes to t/t3700-add.sh

  • Committer: Package Import Robot
  • Author(s): Gerrit Pape
  • Date: 2007-10-04 08:27:01 UTC
  • mfrom: (1.1.23)
  • Revision ID: package-import@ubuntu.com-20071004082701-rsd058ontoqz4i30
Tags: 1:1.5.3.4-1
new upstream point release (closes: #445188).

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
# Copyright (c) 2006 Carl D. Worth
4
4
#
5
5
 
6
 
test_description='Test of git-add, including the -- option.'
 
6
test_description='Test of git add, including the -- option.'
7
7
 
8
8
. ./test-lib.sh
9
9
 
10
10
test_expect_success \
11
 
    'Test of git-add' \
12
 
    'touch foo && git-add foo'
 
11
    'Test of git add' \
 
12
    'touch foo && git add foo'
13
13
 
14
14
test_expect_success \
15
15
    'Post-check that foo is in the index' \
16
 
    'git-ls-files foo | grep foo'
17
 
 
18
 
test_expect_success \
19
 
    'Test that "git-add -- -q" works' \
20
 
    'touch -- -q && git-add -- -q'
21
 
 
22
 
test_expect_success \
23
 
        'git-add: Test that executable bit is not used if core.filemode=0' \
 
16
    'git ls-files foo | grep foo'
 
17
 
 
18
test_expect_success \
 
19
    'Test that "git add -- -q" works' \
 
20
    'touch -- -q && git add -- -q'
 
21
 
 
22
test_expect_success \
 
23
        'git add: Test that executable bit is not used if core.filemode=0' \
24
24
        'git config core.filemode 0 &&
25
25
         echo foo >xfoo1 &&
26
26
         chmod 755 xfoo1 &&
27
 
         git-add xfoo1 &&
28
 
         case "`git-ls-files --stage xfoo1`" in
 
27
         git add xfoo1 &&
 
28
         case "`git ls-files --stage xfoo1`" in
29
29
         100644" "*xfoo1) echo ok;;
30
 
         *) echo fail; git-ls-files --stage xfoo1; (exit 1);;
 
30
         *) echo fail; git ls-files --stage xfoo1; (exit 1);;
31
31
         esac'
32
32
 
33
 
test_expect_success 'git-add: filemode=0 should not get confused by symlink' '
 
33
test_expect_success 'git add: filemode=0 should not get confused by symlink' '
34
34
        rm -f xfoo1 &&
35
35
        ln -s foo xfoo1 &&
36
 
        git-add xfoo1 &&
37
 
        case "`git-ls-files --stage xfoo1`" in
 
36
        git add xfoo1 &&
 
37
        case "`git ls-files --stage xfoo1`" in
38
38
        120000" "*xfoo1) echo ok;;
39
 
        *) echo fail; git-ls-files --stage xfoo1; (exit 1);;
 
39
        *) echo fail; git ls-files --stage xfoo1; (exit 1);;
40
40
        esac
41
41
'
42
42
 
43
43
test_expect_success \
44
 
        'git-update-index --add: Test that executable bit is not used...' \
 
44
        'git update-index --add: Test that executable bit is not used...' \
45
45
        'git config core.filemode 0 &&
46
46
         echo foo >xfoo2 &&
47
47
         chmod 755 xfoo2 &&
48
 
         git-update-index --add xfoo2 &&
49
 
         case "`git-ls-files --stage xfoo2`" in
 
48
         git update-index --add xfoo2 &&
 
49
         case "`git ls-files --stage xfoo2`" in
50
50
         100644" "*xfoo2) echo ok;;
51
 
         *) echo fail; git-ls-files --stage xfoo2; (exit 1);;
 
51
         *) echo fail; git ls-files --stage xfoo2; (exit 1);;
52
52
         esac'
53
53
 
54
 
test_expect_success 'git-add: filemode=0 should not get confused by symlink' '
 
54
test_expect_success 'git add: filemode=0 should not get confused by symlink' '
55
55
        rm -f xfoo2 &&
56
56
        ln -s foo xfoo2 &&
57
57
        git update-index --add xfoo2 &&
58
 
        case "`git-ls-files --stage xfoo2`" in
 
58
        case "`git ls-files --stage xfoo2`" in
59
59
        120000" "*xfoo2) echo ok;;
60
 
        *) echo fail; git-ls-files --stage xfoo2; (exit 1);;
 
60
        *) echo fail; git ls-files --stage xfoo2; (exit 1);;
61
61
        esac
62
62
'
63
63
 
64
64
test_expect_success \
65
 
        'git-update-index --add: Test that executable bit is not used...' \
 
65
        'git update-index --add: Test that executable bit is not used...' \
66
66
        'git config core.filemode 0 &&
67
67
         ln -s xfoo2 xfoo3 &&
68
 
         git-update-index --add xfoo3 &&
69
 
         case "`git-ls-files --stage xfoo3`" in
 
68
         git update-index --add xfoo3 &&
 
69
         case "`git ls-files --stage xfoo3`" in
70
70
         120000" "*xfoo3) echo ok;;
71
 
         *) echo fail; git-ls-files --stage xfoo3; (exit 1);;
 
71
         *) echo fail; git ls-files --stage xfoo3; (exit 1);;
72
72
         esac'
73
73
 
74
74
test_expect_success '.gitignore test setup' '
80
80
'
81
81
 
82
82
test_expect_success '.gitignore is honored' '
83
 
        git-add . &&
84
 
        ! git-ls-files | grep "\\.ig"
85
 
'
86
 
 
87
 
test_expect_success 'error out when attempting to add ignored ones without -f' '
88
 
        ! git-add a.?? &&
89
 
        ! git-ls-files | grep "\\.ig"
90
 
'
91
 
 
92
 
test_expect_success 'error out when attempting to add ignored ones without -f' '
93
 
        ! git-add d.?? &&
94
 
        ! git-ls-files | grep "\\.ig"
95
 
'
96
 
 
97
 
test_expect_success 'add ignored ones with -f' '
98
 
        git-add -f a.?? &&
99
 
        git-ls-files --error-unmatch a.ig
100
 
'
101
 
 
102
 
test_expect_success 'add ignored ones with -f' '
103
 
        git-add -f d.??/* &&
104
 
        git-ls-files --error-unmatch d.ig/d.if d.ig/d.ig
 
83
        git add . &&
 
84
        ! git ls-files | grep "\\.ig"
 
85
'
 
86
 
 
87
test_expect_success 'error out when attempting to add ignored ones without -f' '
 
88
        ! git add a.?? &&
 
89
        ! git ls-files | grep "\\.ig"
 
90
'
 
91
 
 
92
test_expect_success 'error out when attempting to add ignored ones without -f' '
 
93
        ! git add d.?? &&
 
94
        ! git ls-files | grep "\\.ig"
 
95
'
 
96
 
 
97
test_expect_success 'add ignored ones with -f' '
 
98
        git add -f a.?? &&
 
99
        git ls-files --error-unmatch a.ig
 
100
'
 
101
 
 
102
test_expect_success 'add ignored ones with -f' '
 
103
        git add -f d.??/* &&
 
104
        git ls-files --error-unmatch d.ig/d.if d.ig/d.ig
105
105
'
106
106
 
107
107
mkdir 1 1/2 1/3
110
110
        git add 1/2/a 1/3/b 1/2/c
111
111
'
112
112
 
 
113
test_expect_success 'git add with filemode=0, symlinks=0, and unmerged entries' '
 
114
        for s in 1 2 3
 
115
        do
 
116
                echo $s > stage$s
 
117
                echo "100755 $(git hash-object -w stage$s) $s   file"
 
118
                echo "120000 $(printf $s | git hash-object -w -t blob --stdin) $s       symlink"
 
119
        done | git update-index --index-info &&
 
120
        git config core.filemode 0 &&
 
121
        git config core.symlinks 0 &&
 
122
        echo new > file &&
 
123
        echo new > symlink &&
 
124
        git add file symlink &&
 
125
        git ls-files --stage | grep "^100755 .* 0       file$" &&
 
126
        git ls-files --stage | grep "^120000 .* 0       symlink$"
 
127
'
 
128
 
 
129
test_expect_success 'git add with filemode=0, symlinks=0 prefers stage 2 over stage 1' '
 
130
        git rm --cached -f file symlink &&
 
131
        (
 
132
                echo "100644 $(git hash-object -w stage1) 1     file"
 
133
                echo "100755 $(git hash-object -w stage2) 2     file"
 
134
                echo "100644 $(printf 1 | git hash-object -w -t blob --stdin) 1 symlink"
 
135
                echo "120000 $(printf 2 | git hash-object -w -t blob --stdin) 2 symlink"
 
136
        ) | git update-index --index-info &&
 
137
        git config core.filemode 0 &&
 
138
        git config core.symlinks 0 &&
 
139
        echo new > file &&
 
140
        echo new > symlink &&
 
141
        git add file symlink &&
 
142
        git ls-files --stage | grep "^100755 .* 0       file$" &&
 
143
        git ls-files --stage | grep "^120000 .* 0       symlink$"
 
144
'
 
145
 
 
146
test_expect_success 'git add --refresh' '
 
147
        >foo && git add foo && git commit -a -m "commit all" &&
 
148
        test -z "`git diff-index HEAD -- foo`" &&
 
149
        git read-tree HEAD &&
 
150
        case "`git diff-index HEAD -- foo`" in
 
151
        :100644" "*"M   foo") echo ok;;
 
152
        *) echo fail; (exit 1);;
 
153
        esac &&
 
154
        git add --refresh -- foo &&
 
155
        test -z "`git diff-index HEAD -- foo`"
 
156
'
 
157
 
113
158
test_done