MCPcopy Create free account
hub / github.com/git/git / status_submodule

Function status_submodule

builtin/submodule--helper.c:745–843  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

743}
744
745static void status_submodule(const char *path, const struct object_id *ce_oid,
746 unsigned int ce_flags, const char *prefix,
747 const char *super_prefix, unsigned int flags)
748{
749 char *displaypath;
750 struct strvec diff_files_args = STRVEC_INIT;
751 struct rev_info rev = REV_INFO_INIT;
752 struct strbuf buf = STRBUF_INIT;
753 const char *git_dir;
754
755 if (validate_submodule_path(path) < 0)
756 die(NULL);
757
758 if (!submodule_from_path(the_repository, null_oid(the_hash_algo), path))
759 die(_("no submodule mapping found in .gitmodules for path '%s'"),
760 path);
761
762 displaypath = get_submodule_displaypath(path, prefix, super_prefix);
763
764 if ((CE_STAGEMASK & ce_flags) >> CE_STAGESHIFT) {
765 print_status(flags, 'U', path, null_oid(the_hash_algo), displaypath);
766 goto cleanup;
767 }
768
769 strbuf_addf(&buf, "%s/.git", path);
770 git_dir = read_gitfile(buf.buf);
771 if (!git_dir)
772 git_dir = buf.buf;
773
774 if (!is_submodule_active(the_repository, path) ||
775 !is_git_directory(git_dir)) {
776 print_status(flags, '-', path, ce_oid, displaypath);
777 strbuf_release(&buf);
778 goto cleanup;
779 }
780 strbuf_release(&buf);
781
782 strvec_pushl(&diff_files_args, "diff-files",
783 "--ignore-submodules=dirty", "--quiet", "--",
784 path, NULL);
785
786 repo_config(the_repository, git_diff_basic_config, NULL);
787
788 repo_init_revisions(the_repository, &rev, NULL);
789 rev.abbrev = 0;
790 setup_revisions_from_strvec(&diff_files_args, &rev, NULL);
791 run_diff_files(&rev, 0);
792
793 if (!diff_result_code(&rev)) {
794 print_status(flags, ' ', path, ce_oid,
795 displaypath);
796 } else if (!(flags & OPT_CACHED)) {
797 struct object_id oid;
798 struct ref_store *refs = repo_get_submodule_ref_store(the_repository,
799 path);
800
801 if (!refs) {
802 print_status(flags, '-', path, ce_oid, displaypath);

Callers 1

status_submodule_cbFunction · 0.85

Calls 15

validate_submodule_pathFunction · 0.85
submodule_from_pathFunction · 0.85
null_oidFunction · 0.85
print_statusFunction · 0.85
strbuf_addfFunction · 0.85
is_submodule_activeFunction · 0.85
is_git_directoryFunction · 0.85
strbuf_releaseFunction · 0.85
strvec_pushlFunction · 0.85
repo_init_revisionsFunction · 0.85

Tested by

no test coverage detected