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

Function cmd_diff

builtin/diff.c:399–651  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

397}
398
399int cmd_diff(int argc,
400 const char **argv,
401 const char *prefix,
402 struct repository *repo UNUSED)
403{
404 int i;
405 struct rev_info rev;
406 struct object_array ent = OBJECT_ARRAY_INIT;
407 int first_non_parent = -1;
408 int blobs = 0, paths = 0;
409 struct object_array_entry *blob[2];
410 int nongit = 0, no_index = 0;
411 int result;
412 struct symdiff sdiff;
413
414 /*
415 * We could get N tree-ish in the rev.pending_objects list.
416 * Also there could be M blobs there, and P pathspecs. --cached may
417 * also be present.
418 *
419 * N=0, M=0:
420 * cache vs files (diff-files)
421 *
422 * N=0, M=0, --cached:
423 * HEAD vs cache (diff-index --cached)
424 *
425 * N=0, M=2:
426 * compare two random blobs. P must be zero.
427 *
428 * N=0, M=1, P=1:
429 * compare a blob with a working tree file.
430 *
431 * N=1, M=0:
432 * tree vs files (diff-index)
433 *
434 * N=1, M=0, --cached:
435 * tree vs cache (diff-index --cached)
436 *
437 * N=2, M=0:
438 * tree vs tree (diff-tree)
439 *
440 * N=0, M=0, P=2:
441 * compare two filesystem entities (aka --no-index).
442 *
443 * Other cases are errors.
444 */
445
446 /* Were we asked to do --no-index explicitly? */
447 for (i = 1; i < argc; i++) {
448 if (!strcmp(argv[i], "--")) {
449 i++;
450 break;
451 }
452 if (!strcmp(argv[i], "--no-index"))
453 no_index = DIFF_NO_INDEX_EXPLICIT;
454 if (argv[i][0] != '-')
455 break;
456 }

Callers

nothing calls this directly

Calls 15

prepare_repo_settingsFunction · 0.85
path_inside_repoFunction · 0.85
repo_set_hash_algoFunction · 0.85
init_diff_ui_defaultsFunction · 0.85
chdirFunction · 0.85
repo_init_revisionsFunction · 0.85
init_diffstat_widthsFunction · 0.85
diff_no_indexFunction · 0.85
setup_revisionsFunction · 0.85
diff_setup_doneFunction · 0.85
setup_diff_pagerFunction · 0.85

Tested by

no test coverage detected