File tree 3 files changed +41
-21
lines changed
3 files changed +41
-21
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ path = "lib.rs"
16
16
[dependencies ]
17
17
curl-sys = { version = " 0.3" , optional = true }
18
18
libc = " 0.2"
19
- libssh2-sys = { version = " 0.2" , optional = true }
19
+ libssh2-sys = { version = " 0.2.4 " , optional = true }
20
20
libz-sys = " >= 0"
21
21
22
22
[build-dependencies ]
Original file line number Diff line number Diff line change @@ -1334,9 +1334,6 @@ git_enum! {
1334
1334
pub type git_packbuilder_foreach_cb = extern fn ( * const c_void , size_t ,
1335
1335
* mut c_void ) -> c_int ;
1336
1336
1337
- #[ doc( hidden) ]
1338
- pub fn openssl_init ( ) { }
1339
-
1340
1337
extern {
1341
1338
// threads
1342
1339
pub fn git_libgit2_init ( ) -> c_int ;
@@ -2524,7 +2521,37 @@ extern {
2524
2521
pub fn git_packbuilder_free ( pb : * mut git_packbuilder ) ;
2525
2522
}
2526
2523
2527
- #[ test]
2528
- fn smoke ( ) {
2529
- unsafe { git_threads_init ( ) ; }
2524
+ pub fn init ( ) {
2525
+ use std:: sync:: { Once , ONCE_INIT } ;
2526
+
2527
+ static INIT : Once = ONCE_INIT ;
2528
+ INIT . call_once ( || unsafe {
2529
+ openssl_init ( ) ;
2530
+ ssh_init ( ) ;
2531
+ let r = git_libgit2_init ( ) ;
2532
+ assert ! ( r >= 0 ,
2533
+ "couldn't initialize the libgit2 library: {}" , r) ;
2534
+ assert_eq ! ( libc:: atexit( shutdown) , 0 ) ;
2535
+ } ) ;
2536
+ extern fn shutdown ( ) {
2537
+ unsafe { git_libgit2_shutdown ( ) ; }
2538
+ }
2539
+ }
2540
+
2541
+ #[ cfg( all( unix, not( target_os = "macos" ) , not( target_os = "ios" ) , feature = "https" ) ) ]
2542
+ #[ doc( hidden) ]
2543
+ pub fn openssl_init ( ) {
2544
+ openssl_sys:: init ( ) ;
2530
2545
}
2546
+
2547
+ #[ cfg( any( windows, target_os = "macos" , target_os = "ios" , not( feature = "https" ) ) ) ]
2548
+ #[ doc( hidden) ]
2549
+ pub fn openssl_init ( ) { }
2550
+
2551
+ #[ cfg( feature = "ssh" ) ]
2552
+ fn ssh_init ( ) {
2553
+ libssh2:: init ( ) ;
2554
+ }
2555
+
2556
+ #[ cfg( not( feature = "ssh" ) ) ]
2557
+ fn ssh_init ( ) { }
Original file line number Diff line number Diff line change @@ -528,26 +528,19 @@ mod tree;
528
528
mod treebuilder;
529
529
530
530
fn init ( ) {
531
+ raw:: init ( ) ;
532
+
531
533
static INIT : Once = ONCE_INIT ;
532
- INIT . call_once ( || unsafe {
533
- openssl_init ( ) ;
534
- let r = raw:: git_libgit2_init ( ) ;
535
- assert ! ( r >= 0 ,
536
- "couldn't initialize the libgit2 library: {}" , r) ;
537
- assert_eq ! ( libc:: atexit( shutdown) , 0 ) ;
534
+
535
+ INIT . call_once ( || {
536
+ openssl_env_init ( ) ;
538
537
} ) ;
539
- extern fn shutdown ( ) {
540
- unsafe { raw:: git_libgit2_shutdown ( ) ; }
541
- }
542
538
}
543
539
544
540
#[ cfg( all( unix, not( target_os = "macos" ) , not( target_os = "ios" ) , feature = "https" ) ) ]
545
- fn openssl_init ( ) {
546
- extern crate openssl_sys;
541
+ fn openssl_env_init ( ) {
547
542
extern crate openssl_probe;
548
543
549
- openssl_sys:: init ( ) ;
550
-
551
544
// Currently, libgit2 leverages OpenSSL for SSL support when cloning
552
545
// repositories over HTTPS. This means that we're picking up an OpenSSL
553
546
// dependency on non-Windows platforms (where it has its own HTTPS
@@ -663,7 +656,7 @@ fn openssl_init() {
663
656
}
664
657
665
658
#[ cfg( any( windows, target_os = "macos" , target_os = "ios" , not( feature = "https" ) ) ) ]
666
- fn openssl_init ( ) { }
659
+ fn openssl_env_init ( ) { }
667
660
668
661
unsafe fn opt_bytes < ' a , T > ( _anchor : & ' a T ,
669
662
c : * const libc:: c_char ) -> Option < & ' a [ u8 ] > {
You can’t perform that action at this time.
0 commit comments