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

Function show_submodule_header

submodule.c:538–612  ·  view source on GitHub ↗

* Helper function to display the submodule header line prior to the full * summary output. * * If it can locate the submodule git directory it will create a repository * handle for the submodule and lookup both the left and right commits and * put them into the left and right pointers. */

Source from the content-addressed store, hash-verified

536 * put them into the left and right pointers.
537 */
538static void show_submodule_header(struct diff_options *o,
539 const char *path,
540 struct object_id *one, struct object_id *two,
541 unsigned dirty_submodule,
542 struct repository *sub,
543 struct commit **left, struct commit **right,
544 struct commit_list **merge_bases)
545{
546 const char *message = NULL;
547 struct strbuf sb = STRBUF_INIT;
548 int fast_forward = 0, fast_backward = 0;
549
550 if (dirty_submodule & DIRTY_SUBMODULE_UNTRACKED)
551 diff_emit_submodule_untracked(o, path);
552
553 if (dirty_submodule & DIRTY_SUBMODULE_MODIFIED)
554 diff_emit_submodule_modified(o, path);
555
556 if (is_null_oid(one))
557 message = "(new submodule)";
558 else if (is_null_oid(two))
559 message = "(submodule deleted)";
560
561 if (!sub) {
562 if (!message)
563 message = "(commits not present)";
564 goto output_header;
565 }
566
567 /*
568 * Attempt to lookup the commit references, and determine if this is
569 * a fast forward or fast backwards update.
570 */
571 *left = lookup_commit_reference(sub, one);
572 *right = lookup_commit_reference(sub, two);
573
574 /*
575 * Warn about missing commits in the submodule project, but only if
576 * they aren't null.
577 */
578 if ((!is_null_oid(one) && !*left) ||
579 (!is_null_oid(two) && !*right))
580 message = "(commits not present)";
581
582 *merge_bases = NULL;
583 if (repo_get_merge_bases(sub, *left, *right, merge_bases) < 0) {
584 message = "(corrupt repository)";
585 goto output_header;
586 }
587
588 if (*merge_bases) {
589 if ((*merge_bases)->item == *left)
590 fast_forward = 1;
591 else if ((*merge_bases)->item == *right)
592 fast_backward = 1;
593 }
594
595 if (oideq(one, two)) {

Callers 2

Calls 11

is_null_oidFunction · 0.85
lookup_commit_referenceFunction · 0.85
repo_get_merge_basesFunction · 0.85
oideqFunction · 0.85
strbuf_releaseFunction · 0.85
strbuf_addfFunction · 0.85
strbuf_add_unique_abbrevFunction · 0.85
strbuf_addstrFunction · 0.85

Tested by

no test coverage detected