@@ -424,12 +424,19 @@ impl<'index> State<'_, 'index> {
424
424
425
425
self . buf . clear ( ) ;
426
426
self . buf2 . clear ( ) ;
427
+ let file_size_bytes = if cfg ! ( windows) && metadata. is_symlink ( ) {
428
+ // symlinks on Windows seem to have a length of zero, so just pretend
429
+ // they have the correct length to avoid short-cutting, and enforce a full buffer check.
430
+ entry. stat . size as u64
431
+ } else {
432
+ metadata. len ( )
433
+ } ;
427
434
let fetch_data = ReadDataImpl {
428
435
buf : & mut self . buf ,
429
436
path : worktree_path,
430
437
rela_path,
431
438
entry,
432
- file_len : metadata . len ( ) ,
439
+ file_len : file_size_bytes ,
433
440
filter : & mut self . filter ,
434
441
attr_stack : & mut self . attr_stack ,
435
442
options : self . options ,
@@ -440,7 +447,7 @@ impl<'index> State<'_, 'index> {
440
447
odb_reads : self . odb_reads ,
441
448
odb_bytes : self . odb_bytes ,
442
449
} ;
443
- let content_change = diff. compare_blobs ( entry, metadata . len ( ) , fetch_data, & mut self . buf2 ) ?;
450
+ let content_change = diff. compare_blobs ( entry, file_size_bytes , fetch_data, & mut self . buf2 ) ?;
444
451
// This file is racy clean! Set the size to 0 so we keep detecting this as the file is updated.
445
452
if content_change. is_some ( ) || executable_bit_changed {
446
453
let set_entry_stat_size_zero = content_change. is_some ( ) && racy_clean;
@@ -531,7 +538,8 @@ where
531
538
let out = if is_symlink && self . options . fs . symlink {
532
539
// conversion to bstr can never fail because symlinks are only used
533
540
// on unix (by git) so no reason to use the try version here
534
- let symlink_path = gix_path:: into_bstr ( std:: fs:: read_link ( self . path ) ?) ;
541
+ let symlink_path =
542
+ gix_path:: to_unix_separators_on_windows ( gix_path:: into_bstr ( std:: fs:: read_link ( self . path ) ?) ) ;
535
543
self . buf . extend_from_slice ( & symlink_path) ;
536
544
self . worktree_bytes . fetch_add ( self . buf . len ( ) as u64 , Ordering :: Relaxed ) ;
537
545
Stream {
0 commit comments