Skip to content

Commit 88cd8f3

Browse files
committed
Make failing test for the condition we want to fix
1 parent 3f2a526 commit 88cd8f3

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

test/test-pre-push.sh

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ begin_test "pre-push with existing pointer"
173173
)
174174
end_test
175175

176-
begin_test "pre-push with missing pointer"
176+
begin_test "pre-push with missing pointer not on server"
177177
(
178178
set -e
179179

@@ -194,3 +194,44 @@ begin_test "pre-push with missing pointer"
194194
grep "new.dat is an LFS pointer to 7aa7a5359173d05b63cfd682e3c38487f3cb4f7f1d60659fe59fab1505977d4c, which does not exist in .git/lfs/objects" push.log
195195
)
196196
end_test
197+
198+
begin_test "pre-push with missing pointer which is on server"
199+
(
200+
# should permit push if files missing locally but are on server, shouldn't
201+
# require client to have every file (prune)
202+
set -e
203+
204+
reponame="$(basename "$0" ".sh")-missing-but-on-server"
205+
setup_remote_repo "$reponame"
206+
clone_repo "$reponame" missing-but-on-server
207+
208+
contents="common data"
209+
contents_oid=$(printf "$contents" | shasum -a 256 | cut -f 1 -d " ")
210+
git lfs track "*.dat"
211+
printf "$contents" > common1.dat
212+
git add common1.dat
213+
git add .gitattributes
214+
git commit -m "add first file"
215+
216+
# push file to the git lfs server
217+
echo "refs/heads/master master refs/heads/master 0000000000000000000000000000000000000000" |
218+
git lfs pre-push origin "$GITSERVER/$reponame" 2>&1 |
219+
tee push.log
220+
grep "(1 of 1 files)" push.log
221+
222+
# now the file exists
223+
assert_server_object "$reponame" "$contents_oid"
224+
225+
# create another commit referencing same oid, then delete local data & push
226+
printf "$contents" > common2.dat
227+
git add common2.dat
228+
git commit -m "add second file, same content"
229+
rm -rf .git/lfs/objects
230+
echo "refs/heads/master master refs/heads/master 0000000000000000000000000000000000000000" |
231+
git lfs pre-push origin "$GITSERVER/$reponame" 2>&1 |
232+
tee push.log
233+
# make sure there were no errors reported
234+
[ -z "$(grep -i 'Error' push.log)" ]
235+
236+
)
237+
end_test

0 commit comments

Comments
 (0)