28
28
* exists for ce that is a submodule -- it is a submodule that is not
29
29
* checked out). Return negative for an error.
30
30
*/
31
- static int check_removed (const struct cache_entry * ce , struct stat * st )
31
+ static int check_removed (const struct index_state * istate , const struct cache_entry * ce , struct stat * st )
32
32
{
33
- if (lstat (ce -> name , st ) < 0 ) {
33
+ assert (is_fsmonitor_refreshed (istate ));
34
+ if (!(ce -> ce_flags & CE_FSMONITOR_VALID ) && lstat (ce -> name , st ) < 0 ) {
34
35
if (!is_missing_file_error (errno ))
35
36
return -1 ;
36
37
return 1 ;
@@ -136,7 +137,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
136
137
memset (& (dpath -> parent [0 ]), 0 ,
137
138
sizeof (struct combine_diff_parent )* 5 );
138
139
139
- changed = check_removed (ce , & st );
140
+ changed = check_removed (istate , ce , & st );
140
141
if (!changed )
141
142
wt_mode = ce_mode_from_stat (ce , st .st_mode );
142
143
else {
@@ -216,7 +217,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
216
217
} else {
217
218
struct stat st ;
218
219
219
- changed = check_removed (ce , & st );
220
+ changed = check_removed (istate , ce , & st );
220
221
if (changed ) {
221
222
if (changed < 0 ) {
222
223
perror (ce -> name );
@@ -278,7 +279,8 @@ static void diff_index_show_file(struct rev_info *revs,
278
279
oid , oid_valid , ce -> name , dirty_submodule );
279
280
}
280
281
281
- static int get_stat_data (const struct cache_entry * ce ,
282
+ static int get_stat_data (const struct index_state * istate ,
283
+ const struct cache_entry * ce ,
282
284
const struct object_id * * oidp ,
283
285
unsigned int * modep ,
284
286
int cached , int match_missing ,
@@ -290,7 +292,7 @@ static int get_stat_data(const struct cache_entry *ce,
290
292
if (!cached && !ce_uptodate (ce )) {
291
293
int changed ;
292
294
struct stat st ;
293
- changed = check_removed (ce , & st );
295
+ changed = check_removed (istate , ce , & st );
294
296
if (changed < 0 )
295
297
return -1 ;
296
298
else if (changed ) {
@@ -321,12 +323,13 @@ static void show_new_file(struct rev_info *revs,
321
323
const struct object_id * oid ;
322
324
unsigned int mode ;
323
325
unsigned dirty_submodule = 0 ;
326
+ struct index_state * istate = revs -> diffopt .repo -> index ;
324
327
325
328
/*
326
329
* New file in the index: it might actually be different in
327
330
* the working tree.
328
331
*/
329
- if (get_stat_data (new_file , & oid , & mode , cached , match_missing ,
332
+ if (get_stat_data (istate , new_file , & oid , & mode , cached , match_missing ,
330
333
& dirty_submodule , & revs -> diffopt ) < 0 )
331
334
return ;
332
335
@@ -342,8 +345,9 @@ static int show_modified(struct rev_info *revs,
342
345
unsigned int mode , oldmode ;
343
346
const struct object_id * oid ;
344
347
unsigned dirty_submodule = 0 ;
348
+ struct index_state * istate = revs -> diffopt .repo -> index ;
345
349
346
- if (get_stat_data (new_entry , & oid , & mode , cached , match_missing ,
350
+ if (get_stat_data (istate , new_entry , & oid , & mode , cached , match_missing ,
347
351
& dirty_submodule , & revs -> diffopt ) < 0 ) {
348
352
if (report_missing )
349
353
diff_index_show_file (revs , "-" , old_entry ,
@@ -574,13 +578,16 @@ int run_diff_index(struct rev_info *revs, unsigned int option)
574
578
struct object_id oid ;
575
579
const char * name ;
576
580
char merge_base_hex [GIT_MAX_HEXSZ + 1 ];
581
+ struct index_state * istate = revs -> diffopt .repo -> index ;
577
582
578
583
if (revs -> pending .nr != 1 )
579
584
BUG ("run_diff_index must be passed exactly one tree" );
580
585
581
586
trace_performance_enter ();
582
587
ent = revs -> pending .objects ;
583
588
589
+ refresh_fsmonitor (istate );
590
+
584
591
if (merge_base ) {
585
592
diff_get_merge_base (revs , & oid );
586
593
name = oid_to_hex_r (merge_base_hex , & oid );
0 commit comments