@@ -285,3 +285,302 @@ begin_test "custom-transfer-standalone-urlmatch"
285285 git lfs fsck
286286)
287287end_test
288+
289+ begin_test " standalone agent without custom group (file transfers allowed)"
290+ (
291+ set -e
292+
293+ reponame=" custom-transfer-standalone-valid-file"
294+ setup_remote_repo " $reponame "
295+
296+ # Clone directly, not through lfstest-gitserver.
297+ clone_repo_url " $REMOTEDIR /$reponame .git" " $reponame "
298+
299+ # When the remote has a file:// URL, we permit the standalone transfer
300+ # agent to be set to the internal "lfs-standalone-file" adapter without
301+ # any "lfs.customtransfer.*" settings.
302+ git config lfs.standaloneTransferAgent lfs-standalone-file
303+
304+ git lfs track " *.bin"
305+
306+ contents=" a"
307+ contents_oid=" $( calc_oid " $contents " ) "
308+ printf " %s" " $contents " > a.bin
309+
310+ git add .gitattributes a.bin
311+ git commit -m " initial commit"
312+
313+ GIT_TRACE=1 git push origin main 2>&1 | tee push.log
314+ [ 0 -eq " ${PIPESTATUS[0]} " ]
315+
316+ assert_remote_object " $reponame " " $contents_oid " " ${# contents} "
317+
318+ rm -rf .git/lfs/objects
319+
320+ GIT_TRACE=1 git lfs pull 2>&1 | tee pull.log
321+ [ 0 -eq " ${PIPESTATUS[0]} " ]
322+
323+ [ 0 -eq " $( grep -c " not a registered custom transfer adapter" pull.log) " ]
324+
325+ assert_local_object " $contents_oid " " ${# contents} "
326+ )
327+ end_test
328+
329+ begin_test " standalone agent without custom group (file transfers disallowed)"
330+ (
331+ set -e
332+
333+ reponame=" custom-transfer-standalone-invalid-file"
334+ setup_remote_repo " $reponame "
335+ clone_repo " $reponame " " $reponame "
336+
337+ git lfs track " *.bin"
338+
339+ contents=" a"
340+ contents_oid=" $( calc_oid " $contents " ) "
341+ printf " %s" " $contents " > a.bin
342+
343+ git add .gitattributes a.bin
344+ git commit -m " initial commit"
345+
346+ git push origin main
347+
348+ # When the remote has an HTTP URL, we expect an error if the standalone
349+ # transfer agent is set to the internal "lfs-standalone-file" adapter.
350+ git config lfs.standaloneTransferAgent lfs-standalone-file
351+
352+ rm -rf .git/lfs/objects
353+
354+ GIT_TRACE=1 git lfs pull 2>&1 | tee pull.log
355+ [ 0 -ne " ${PIPESTATUS[0]} " ]
356+
357+ grep " error initializing custom adapter \" lfs-standalone-file\" " pull.log
358+ grep " error creating handler: no valid file:// URLs found" pull.log
359+ grep " Failed to fetch some objects" pull.log
360+
361+ [ 0 -eq " $( grep -c " not a registered custom transfer adapter" pull.log) " ]
362+
363+ refute_local_object " $contents_oid "
364+ )
365+ end_test
366+
367+ begin_test " standalone agent without custom group ignored (basic transfers)"
368+ (
369+ set -e
370+
371+ reponame=" custom-transfer-standalone-ignored-basic"
372+ setup_remote_repo " $reponame "
373+ clone_repo " $reponame " " $reponame "
374+
375+ # The standalone transfer agent should be ignored if it is set to the
376+ # internal "basic" adapter, regardless of whether that adapter is
377+ # actually used for HTTP requests to the Batch API.
378+ git config lfs.standaloneTransferAgent basic
379+
380+ git lfs track " *.bin"
381+
382+ contents=" a"
383+ contents_oid=" $( calc_oid " $contents " ) "
384+ printf " %s" " $contents " > a.bin
385+
386+ git add .gitattributes a.bin
387+ git commit -m " initial commit"
388+
389+ GIT_TRACE=1 git push origin main 2>&1 | tee push.log
390+ [ 0 -eq " ${PIPESTATUS[0]} " ]
391+
392+ grep " standalone agent \" basic\" is not a registered custom transfer adapter; ignoring" push.log
393+
394+ assert_server_object " $reponame " " $contents_oid "
395+
396+ rm -rf .git/lfs/objects
397+
398+ GIT_TRACE=1 git lfs pull 2>&1 | tee pull.log
399+ [ 0 -eq " ${PIPESTATUS[0]} " ]
400+
401+ grep " standalone agent \" basic\" is not a registered custom transfer adapter; ignoring" pull.log
402+
403+ assert_local_object " $contents_oid " " ${# contents} "
404+
405+ # The standalone transfer agent should still be ignored even when
406+ # a custom transfer adapter is registered with the same name as the
407+ # internal "basic" adapter.
408+ git config lfs.customTransfer.basic.path path-to-nothing
409+
410+ contents=" b"
411+ contents_oid=" $( calc_oid " $contents " ) "
412+ printf " %s" " $contents " > b.bin
413+
414+ git add b.bin
415+ git commit -m " second commit"
416+
417+ GIT_TRACE=1 git push origin main 2>&1 | tee push.log
418+ [ 0 -eq " ${PIPESTATUS[0]} " ]
419+
420+ grep " standalone agent \" basic\" is not a registered custom transfer adapter; ignoring" push.log
421+ grep " custom upload transfer adapter \" basic\" ignored due to conflict with standard adapter" push.log
422+ grep " custom download transfer adapter \" basic\" ignored due to conflict with standard adapter" push.log
423+
424+ assert_server_object " $reponame " " $contents_oid "
425+
426+ rm -rf .git/lfs/objects
427+
428+ GIT_TRACE=1 git lfs pull 2>&1 | tee pull.log
429+ [ 0 -eq " ${PIPESTATUS[0]} " ]
430+
431+ grep " standalone agent \" basic\" is not a registered custom transfer adapter; ignoring" pull.log
432+ grep " custom upload transfer adapter \" basic\" ignored due to conflict with standard adapter" pull.log
433+ grep " custom download transfer adapter \" basic\" ignored due to conflict with standard adapter" pull.log
434+
435+ assert_local_object " $contents_oid " " ${# contents} "
436+ )
437+ end_test
438+
439+ begin_test " standalone agent without custom group ignored (basic transfers not ssh)"
440+ (
441+ set -e
442+
443+ reponame=" custom-transfer-standalone-ignored-basic-ssh"
444+ setup_remote_repo " $reponame "
445+ clone_repo " $reponame " " $reponame "
446+
447+ # The standalone transfer agent should be ignored if it is set to the
448+ # internal "ssh" adapter, regardless of whether the internal "basic"
449+ # adapter will actually be used for HTTP requests to the Batch API.
450+ git config lfs.standaloneTransferAgent ssh
451+
452+ git lfs track " *.bin"
453+
454+ contents=" a"
455+ contents_oid=" $( calc_oid " $contents " ) "
456+ printf " %s" " $contents " > a.bin
457+
458+ git add .gitattributes a.bin
459+ git commit -m " initial commit"
460+
461+ GIT_TRACE=1 git push origin main 2>&1 | tee push.log
462+ [ 0 -eq " ${PIPESTATUS[0]} " ]
463+
464+ grep " standalone agent \" ssh\" is not a registered custom transfer adapter; ignoring" push.log
465+
466+ assert_server_object " $reponame " " $contents_oid "
467+
468+ rm -rf .git/lfs/objects
469+
470+ GIT_TRACE=1 git lfs pull 2>&1 | tee pull.log
471+ [ 0 -eq " ${PIPESTATUS[0]} " ]
472+
473+ grep " standalone agent \" ssh\" is not a registered custom transfer adapter; ignoring" pull.log
474+
475+ assert_local_object " $contents_oid " " ${# contents} "
476+
477+ # The standalone transfer agent should still be ignored even when
478+ # a custom transfer adapter is registered with the same name as the
479+ # internal "ssh" adapter.
480+ git config lfs.customTransfer.ssh.path path-to-nothing
481+
482+ contents=" b"
483+ contents_oid=" $( calc_oid " $contents " ) "
484+ printf " %s" " $contents " > b.bin
485+
486+ git add b.bin
487+ git commit -m " second commit"
488+
489+ GIT_TRACE=1 git push origin main 2>&1 | tee push.log
490+ [ 0 -eq " ${PIPESTATUS[0]} " ]
491+
492+ grep " standalone agent \" ssh\" is not a registered custom transfer adapter; ignoring" push.log
493+ grep " custom upload transfer adapter \" ssh\" ignored due to conflict with standard adapter" push.log
494+ grep " custom download transfer adapter \" ssh\" ignored due to conflict with standard adapter" push.log
495+
496+ assert_server_object " $reponame " " $contents_oid "
497+
498+ rm -rf .git/lfs/objects
499+
500+ GIT_TRACE=1 git lfs pull 2>&1 | tee pull.log
501+ [ 0 -eq " ${PIPESTATUS[0]} " ]
502+
503+ grep " standalone agent \" ssh\" is not a registered custom transfer adapter; ignoring" pull.log
504+ grep " custom upload transfer adapter \" ssh\" ignored due to conflict with standard adapter" pull.log
505+ grep " custom download transfer adapter \" ssh\" ignored due to conflict with standard adapter" pull.log
506+
507+ assert_local_object " $contents_oid " " ${# contents} "
508+ )
509+ end_test
510+
511+ begin_test " standalone agent without custom group ignored (ssh transfers)"
512+ (
513+ set -e
514+
515+ setup_pure_ssh
516+
517+ reponame=" custom-transfer-standalone-ignored-ssh"
518+ setup_remote_repo " $reponame "
519+ clone_repo " $reponame " " $reponame "
520+
521+ sshurl=$( ssh_remote " $reponame " )
522+ git config lfs.url " $sshurl "
523+
524+ # The standalone transfer agent should be ignored if it is set to the
525+ # internal "ssh" adapter, regardless of whether that adapter is
526+ # actually used for SSH requests to the Batch API.
527+ git config lfs.standaloneTransferAgent ssh
528+
529+ git lfs track " *.bin"
530+
531+ contents=" a"
532+ contents_oid=" $( calc_oid " $contents " ) "
533+ printf " %s" " $contents " > a.bin
534+
535+ git add .gitattributes a.bin
536+ git commit -m " initial commit"
537+
538+ GIT_TRACE=1 git push origin main 2>&1 | tee push.log
539+ [ 0 -eq " ${PIPESTATUS[0]} " ]
540+
541+ grep " standalone agent \" ssh\" is not a registered custom transfer adapter; ignoring" push.log
542+
543+ assert_remote_object " $reponame " " $contents_oid " " ${# contents} "
544+
545+ rm -rf .git/lfs/objects
546+
547+ GIT_TRACE=1 git lfs pull 2>&1 | tee pull.log
548+ [ 0 -eq " ${PIPESTATUS[0]} " ]
549+
550+ grep " standalone agent \" ssh\" is not a registered custom transfer adapter; ignoring" pull.log
551+
552+ assert_local_object " $contents_oid " " ${# contents} "
553+
554+ # The standalone transfer agent should still be ignored even when
555+ # a custom transfer adapter is registered with the same name as the
556+ # internal "ssh" adapter.
557+ git config lfs.customTransfer.ssh.path path-to-nothing
558+
559+ contents=" b"
560+ contents_oid=" $( calc_oid " $contents " ) "
561+ printf " %s" " $contents " > b.bin
562+
563+ git add b.bin
564+ git commit -m " second commit"
565+
566+ GIT_TRACE=1 git push origin main 2>&1 | tee push.log
567+ [ 0 -eq " ${PIPESTATUS[0]} " ]
568+
569+ grep " standalone agent \" ssh\" is not a registered custom transfer adapter; ignoring" push.log
570+ grep " custom upload transfer adapter \" ssh\" ignored due to conflict with standard adapter" push.log
571+ grep " custom download transfer adapter \" ssh\" ignored due to conflict with standard adapter" push.log
572+
573+ assert_remote_object " $reponame " " $contents_oid " " ${# contents} "
574+
575+ rm -rf .git/lfs/objects
576+
577+ GIT_TRACE=1 git lfs pull 2>&1 | tee pull.log
578+ [ 0 -eq " ${PIPESTATUS[0]} " ]
579+
580+ grep " standalone agent \" ssh\" is not a registered custom transfer adapter; ignoring" pull.log
581+ grep " custom upload transfer adapter \" ssh\" ignored due to conflict with standard adapter" pull.log
582+ grep " custom download transfer adapter \" ssh\" ignored due to conflict with standard adapter" pull.log
583+
584+ assert_local_object " $contents_oid " " ${# contents} "
585+ )
586+ end_test
0 commit comments