File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -219,9 +219,17 @@ impl<'cfg> PathSource<'cfg> {
219
219
// the untracked files are often part of a build and may become relevant
220
220
// as part of a future commit.
221
221
let index_files = index. iter ( ) . map ( |entry| {
222
- use libgit2_sys:: GIT_FILEMODE_COMMIT ;
223
- let is_dir = entry. mode == GIT_FILEMODE_COMMIT as u32 ;
224
- ( join ( root, & entry. path ) , Some ( is_dir) )
222
+ use libgit2_sys:: { GIT_FILEMODE_COMMIT , GIT_FILEMODE_LINK } ;
223
+ // ``is_dir`` is an optimization to avoid calling
224
+ // ``fs::metadata`` on every file.
225
+ let is_dir = if entry. mode == GIT_FILEMODE_LINK as u32 {
226
+ // Let the code below figure out if this symbolic link points
227
+ // to a directory or not.
228
+ None
229
+ } else {
230
+ Some ( entry. mode == GIT_FILEMODE_COMMIT as u32 )
231
+ } ;
232
+ ( join ( root, & entry. path ) , is_dir)
225
233
} ) ;
226
234
let mut opts = git2:: StatusOptions :: new ( ) ;
227
235
opts. include_untracked ( true ) ;
Original file line number Diff line number Diff line change @@ -506,10 +506,14 @@ fn package_git_submodule() {
506
506
507
507
#[ cargo_test]
508
508
fn package_symlink_to_submodule ( ) {
509
+ #[ cfg( unix) ]
510
+ use std:: os:: unix:: fs:: symlink as symlink;
511
+ #[ cfg( windows) ]
512
+ use std:: os:: unix:: fs:: symlink_dir as symlink;
513
+
509
514
let project = git:: new ( "foo" , |project| {
510
515
project
511
516
. file ( "src/lib.rs" , "pub fn foo() {}" )
512
- . symlink ( "submodule" , "submodule-link" )
513
517
} ) . unwrap ( ) ;
514
518
515
519
let library = git:: new ( "submodule" , |library| {
@@ -519,6 +523,8 @@ fn package_symlink_to_submodule() {
519
523
let repository = git2:: Repository :: open ( & project. root ( ) ) . unwrap ( ) ;
520
524
let url = path2url ( library. root ( ) ) . to_string ( ) ;
521
525
git:: add_submodule ( & repository, & url, Path :: new ( "submodule" ) ) ;
526
+ t ! ( symlink( & project. root( ) . join( "submodule" ) , & project. root( ) . join( "submodule-link" ) ) ) ;
527
+ git:: add ( & repository) ;
522
528
git:: commit ( & repository) ;
523
529
524
530
let repository = git2:: Repository :: open ( & project. root ( ) . join ( "submodule" ) ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments