MCPcopy Index your code
hub / github.com/git/git / show_modified

Function show_modified

diff-lib.c:375–434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

373}
374
375static int show_modified(struct rev_info *revs,
376 const struct cache_entry *old_entry,
377 const struct cache_entry *new_entry,
378 int report_missing,
379 int cached, int match_missing)
380{
381 unsigned int mode, oldmode;
382 const struct object_id *oid;
383 unsigned dirty_submodule = 0;
384
385 assert(S_ISSPARSEDIR(old_entry->ce_mode) ==
386 S_ISSPARSEDIR(new_entry->ce_mode));
387
388 /*
389 * If both are sparse directory entries, then expand the
390 * modifications to the file level. If only one was a sparse
391 * directory, then they appear as an add and delete instead of
392 * a modification.
393 */
394 if (S_ISSPARSEDIR(new_entry->ce_mode)) {
395 diff_tree_oid(&old_entry->oid, &new_entry->oid, new_entry->name, &revs->diffopt);
396 return 0;
397 }
398
399 if (get_stat_data(new_entry, &oid, &mode, cached, match_missing,
400 &dirty_submodule, &revs->diffopt) < 0) {
401 if (report_missing)
402 diff_index_show_file(revs, "-", old_entry,
403 &old_entry->oid, 1, old_entry->ce_mode,
404 0);
405 return -1;
406 }
407
408 if (revs->combine_merges && !cached &&
409 (!oideq(oid, &old_entry->oid) || !oideq(&old_entry->oid, &new_entry->oid))) {
410 struct combine_diff_path *p;
411
412 p = combine_diff_path_new(new_entry->name,
413 ce_namelen(new_entry),
414 mode, null_oid(the_hash_algo), 2);
415 p->parent[0].status = DIFF_STATUS_MODIFIED;
416 p->parent[0].mode = new_entry->ce_mode;
417 oidcpy(&p->parent[0].oid, &new_entry->oid);
418 p->parent[1].status = DIFF_STATUS_MODIFIED;
419 p->parent[1].mode = old_entry->ce_mode;
420 oidcpy(&p->parent[1].oid, &old_entry->oid);
421 show_combined_diff(p, 2, revs);
422 free(p);
423 return 0;
424 }
425
426 oldmode = old_entry->ce_mode;
427 if (mode != oldmode || !oideq(oid, &old_entry->oid) || dirty_submodule)
428 diff_change(&revs->diffopt, oldmode, mode,
429 &old_entry->oid, oid, 1, !is_null_oid(oid),
430 old_entry->name, 0, dirty_submodule);
431 else if (revs->diffopt.flags.find_copies_harder)
432 diff_same(&revs->diffopt, mode, oid, old_entry->name);

Callers 1

do_oneway_diffFunction · 0.85

Calls 11

diff_tree_oidFunction · 0.85
get_stat_dataFunction · 0.85
diff_index_show_fileFunction · 0.85
oideqFunction · 0.85
combine_diff_path_newFunction · 0.85
null_oidFunction · 0.85
oidcpyFunction · 0.85
show_combined_diffFunction · 0.85
diff_changeFunction · 0.85
is_null_oidFunction · 0.85
diff_sameFunction · 0.85

Tested by

no test coverage detected