@@ -97,7 +97,6 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
97
97
diff_unmerged_stage = 2 ;
98
98
entries = active_nr ;
99
99
for (i = 0 ; i < entries ; i ++ ) {
100
- struct stat st ;
101
100
unsigned int oldmode , newmode ;
102
101
struct cache_entry * ce = active_cache [i ];
103
102
int changed ;
@@ -115,6 +114,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
115
114
unsigned int wt_mode = 0 ;
116
115
int num_compare_stages = 0 ;
117
116
size_t path_len ;
117
+ struct stat st ;
118
118
119
119
path_len = ce_namelen (ce );
120
120
@@ -195,26 +195,35 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
195
195
continue ;
196
196
197
197
/* If CE_VALID is set, don't look at workdir for file removal */
198
- changed = (ce -> ce_flags & CE_VALID ) ? 0 : check_removed (ce , & st );
199
- if (changed ) {
200
- if (changed < 0 ) {
201
- perror (ce -> name );
198
+ if (ce -> ce_flags & CE_VALID ) {
199
+ changed = 0 ;
200
+ newmode = ce -> ce_mode ;
201
+ } else {
202
+ struct stat st ;
203
+
204
+ changed = check_removed (ce , & st );
205
+ if (changed ) {
206
+ if (changed < 0 ) {
207
+ perror (ce -> name );
208
+ continue ;
209
+ }
210
+ diff_addremove (& revs -> diffopt , '-' , ce -> ce_mode ,
211
+ ce -> sha1 , !is_null_sha1 (ce -> sha1 ),
212
+ ce -> name , 0 );
202
213
continue ;
203
214
}
204
- diff_addremove ( & revs -> diffopt , '-' , ce -> ce_mode ,
205
- ce -> sha1 , ! is_null_sha1 ( ce -> sha1 ) ,
206
- ce -> name , 0 );
207
- continue ;
215
+
216
+ changed = match_stat_with_submodule ( & revs -> diffopt , ce , & st ,
217
+ ce_option , & dirty_submodule );
218
+ newmode = ce_mode_from_stat ( ce , st . st_mode ) ;
208
219
}
209
- changed = match_stat_with_submodule (& revs -> diffopt , ce , & st ,
210
- ce_option , & dirty_submodule );
220
+
211
221
if (!changed && !dirty_submodule ) {
212
222
ce_mark_uptodate (ce );
213
223
if (!DIFF_OPT_TST (& revs -> diffopt , FIND_COPIES_HARDER ))
214
224
continue ;
215
225
}
216
226
oldmode = ce -> ce_mode ;
217
- newmode = ce_mode_from_stat (ce , st .st_mode );
218
227
diff_change (& revs -> diffopt , oldmode , newmode ,
219
228
ce -> sha1 , (changed ? null_sha1 : ce -> sha1 ),
220
229
!is_null_sha1 (ce -> sha1 ), (changed ? 0 : !is_null_sha1 (ce -> sha1 )),
0 commit comments