@@ -116,3 +116,92 @@ begin_test "post-checkout"
116
116
117
117
)
118
118
end_test
119
+
120
+ begin_test " post-checkout with subdirectories"
121
+ (
122
+ set -e
123
+
124
+ reponame=" post-checkout-subdirectories"
125
+ setup_remote_repo " $reponame "
126
+
127
+ clone_repo " $reponame " " $reponame "
128
+
129
+ git lfs track --lockable " bin/*.dat"
130
+ git lfs track " *.big" # not lockable
131
+ git add .gitattributes
132
+ git commit -m " add git attributes"
133
+
134
+ echo " [
135
+ {
136
+ \" CommitDate\" :\" $( get_date -10d) \" ,
137
+ \" Files\" :[
138
+ {\" Filename\" :\" bin/file1.dat\" ,\" Data\" :\" file 1 creation\" },
139
+ {\" Filename\" :\" bin/file2.dat\" ,\" Data\" :\" file 2 creation\" }]
140
+ },
141
+ {
142
+ \" CommitDate\" :\" $( get_date -7d) \" ,
143
+ \" Files\" :[
144
+ {\" Filename\" :\" bin/file1.dat\" ,\" Data\" :\" file 1 updated commit 2\" },
145
+ {\" Filename\" :\" file3.big\" ,\" Data\" :\" file 3 creation\" },
146
+ {\" Filename\" :\" file4.big\" ,\" Data\" :\" file 4 creation\" }],
147
+ \" Tags\" :[\" atag\" ]
148
+ },
149
+ {
150
+ \" CommitDate\" :\" $( get_date -5d) \" ,
151
+ \" Files\" :[
152
+ {\" Filename\" :\" bin/file2.dat\" ,\" Data\" :\" file 2 updated commit 3\" }]
153
+ },
154
+ {
155
+ \" CommitDate\" :\" $( get_date -3d) \" ,
156
+ \" NewBranch\" :\" branch2\" ,
157
+ \" Files\" :[
158
+ {\" Filename\" :\" bin/file5.dat\" ,\" Data\" :\" file 5 creation in branch2\" },
159
+ {\" Filename\" :\" file6.big\" ,\" Data\" :\" file 6 creation in branch2\" }]
160
+ },
161
+ {
162
+ \" CommitDate\" :\" $( get_date -1d) \" ,
163
+ \" Files\" :[
164
+ {\" Filename\" :\" bin/file2.dat\" ,\" Data\" :\" file 2 updated in branch2\" },
165
+ {\" Filename\" :\" file3.big\" ,\" Data\" :\" file 3 updated in branch2\" }]
166
+ }
167
+ ]" | GIT_LFS_SET_LOCKABLE_READONLY=0 lfstest-testutils addcommits
168
+
169
+ # skipped setting read-only above to make bulk load simpler (no read-only issues)
170
+
171
+ git push -u origin master branch2
172
+
173
+ # re-clone the repo so we start fresh
174
+ cd ..
175
+ rm -rf " $reponame "
176
+ clone_repo " $reponame " " $reponame "
177
+
178
+ # this will be master
179
+
180
+ [ " $( cat bin/file1.dat) " == " file 1 updated commit 2" ]
181
+ [ " $( cat bin/file2.dat) " == " file 2 updated commit 3" ]
182
+ [ " $( cat file3.big) " == " file 3 creation" ]
183
+ [ " $( cat file4.big) " == " file 4 creation" ]
184
+ [ ! -e bin/file5.dat ]
185
+ [ ! -e file6.big ]
186
+ # without the post-checkout hook, any changed files would now be writeable
187
+ refute_file_writeable bin/file1.dat
188
+ refute_file_writeable bin/file2.dat
189
+ assert_file_writeable file3.big
190
+ assert_file_writeable file4.big
191
+
192
+ # checkout branch
193
+ git checkout branch2
194
+ [ -e bin/file5.dat ]
195
+ [ -e file6.big ]
196
+ refute_file_writeable bin/file1.dat
197
+ refute_file_writeable bin/file2.dat
198
+ refute_file_writeable bin/file5.dat
199
+ assert_file_writeable file3.big
200
+ assert_file_writeable file4.big
201
+ assert_file_writeable file6.big
202
+
203
+ # Confirm that contents of existing files were updated even though were read-only
204
+ [ " $( cat bin/file2.dat) " == " file 2 updated in branch2" ]
205
+ [ " $( cat file3.big) " == " file 3 updated in branch2" ]
206
+ )
207
+ end_test
0 commit comments