73
unsigned int oldmode, newmode;
74
struct cache_entry *ce = active_cache[i];
75
int changed;
76
+ unsigned dirty_submodule = 0;
77
78
if (DIFF_OPT_TST(&revs->diffopt, QUICK) &&
79
DIFF_OPT_TST(&revs->diffopt, HAS_CHANGES))
174
if (silent_on_removed)
175
continue;
176
diff_addremove(&revs->diffopt, '-', ce->ce_mode,
176
- ce->sha1, ce->name);
177
+ ce->sha1, ce->name, 0);
178
continue;
179
}
180
changed = ce_match_stat(ce, &st, ce_option);
180
- if (S_ISGITLINK(ce->ce_mode) && !changed)
181
- changed = is_submodule_modified(ce->name);
181
+ if (S_ISGITLINK(ce->ce_mode)
182
+ && (!changed || (revs->diffopt.output_format & DIFF_FORMAT_PATCH))
183
+ && is_submodule_modified(ce->name)) {
184
+ changed = 1;
185
+ dirty_submodule = 1;
186
+ }
187
if (!changed) {
188
ce_mark_uptodate(ce);
189
if (!DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
193
newmode = ce_mode_from_stat(ce, st.st_mode);
194
diff_change(&revs->diffopt, oldmode, newmode,
195
ce->sha1, (changed ? null_sha1 : ce->sha1),
191
- ce->name);
196
+ ce->name, 0, dirty_submodule);
197
198
}
199
diffcore_std(&revs->diffopt);
209
static void diff_index_show_file(struct rev_info *revs,
210
const char *prefix,
211
struct cache_entry *ce,
207
- const unsigned char *sha1, unsigned int mode)
212
+ const unsigned char *sha1, unsigned int mode,
213
+ unsigned dirty_submodule)
214
{
215
diff_addremove(&revs->diffopt, prefix[0], mode,
210
- sha1, ce->name);
216
+ sha1, ce->name, dirty_submodule);
217
}
218
219
static int get_stat_data(struct cache_entry *ce,
220
const unsigned char **sha1p,
221
unsigned int *modep,
216
- int cached, int match_missing)
222
+ int cached, int match_missing,
223
+ unsigned *dirty_submodule, int output_format)
224
{
225
const unsigned char *sha1 = ce->sha1;
226
unsigned int mode = ce->ce_mode;
240
return -1;
241
}
242
changed = ce_match_stat(ce, &st, 0);
236
- if (changed
237
- || (S_ISGITLINK(ce->ce_mode) && is_submodule_modified(ce->name))) {
243
+ if (S_ISGITLINK(ce->ce_mode)
244
+ && (!changed || (output_format & DIFF_FORMAT_PATCH))
245
+ && is_submodule_modified(ce->name)) {
246
+ changed = 1;
247
+ *dirty_submodule = 1;
248
+ }
249
+ if (changed) {
250
mode = ce_mode_from_stat(ce, st.st_mode);
251
sha1 = null_sha1;
252
}
263
{
264
const unsigned char *sha1;
265
unsigned int mode;
266
+ unsigned dirty_submodule = 0;
267
268
/*
269
* New file in the index: it might actually be different in
270
* the working copy.
271
*/
259
- if (get_stat_data(new, &sha1, &mode, cached, match_missing) < 0)
272
+ if (get_stat_data(new, &sha1, &mode, cached, match_missing,
273
+ &dirty_submodule, revs->diffopt.output_format) < 0)
274
return;
275
262
- diff_index_show_file(revs, "+", new, sha1, mode);
276
+ diff_index_show_file(revs, "+", new, sha1, mode, dirty_submodule);
277
}
278
279
static int show_modified(struct rev_info *revs,
284
{
285
unsigned int mode, oldmode;
286
const unsigned char *sha1;
287
+ unsigned dirty_submodule = 0;
288
274
- if (get_stat_data(new, &sha1, &mode, cached, match_missing) < 0) {
289
+ if (get_stat_data(new, &sha1, &mode, cached, match_missing,
290
+ &dirty_submodule, revs->diffopt.output_format) < 0) {
291
if (report_missing)
292
diff_index_show_file(revs, "-", old,
277
- old->sha1, old->ce_mode);
293
+ old->sha1, old->ce_mode, 0);
294
return -1;
295
}
296
325
return 0;
326
327
diff_change(&revs->diffopt, oldmode, mode,
312
- old->sha1, sha1, old->name);
328
+ old->sha1, sha1, old->name, 0, dirty_submodule);
329
return 0;
330
}
331
372
* Something removed from the tree?
373
*/
374
if (!idx) {
359
- diff_index_show_file(revs, "-", tree, tree->sha1, tree->ce_mode);
375
+ diff_index_show_file(revs, "-", tree, tree->sha1, tree->ce_mode, 0);
376
return;
377
}
378