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

Function collect_changed_submodules_cb

submodule.c:831–883  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

829}
830
831static void collect_changed_submodules_cb(struct diff_queue_struct *q,
832 struct diff_options *options UNUSED,
833 void *data)
834{
835 struct collect_changed_submodules_cb_data *me = data;
836 struct string_list *changed = me->changed;
837 const struct object_id *commit_oid = me->commit_oid;
838 int i;
839
840 for (i = 0; i < q->nr; i++) {
841 struct diff_filepair *p = q->queue[i];
842 const struct submodule *submodule;
843 const char *name;
844 struct string_list_item *item;
845 struct changed_submodule_data *cs_data;
846
847 if (!S_ISGITLINK(p->two->mode))
848 continue;
849
850 submodule = submodule_from_path(me->repo,
851 commit_oid, p->two->path);
852 if (submodule)
853 name = submodule->name;
854 else {
855 name = default_name_or_path(p->two->path);
856 /* make sure name does not collide with existing one */
857 if (name)
858 submodule = submodule_from_name(me->repo,
859 commit_oid, name);
860 if (submodule) {
861 warning(_("Submodule in commit %s at path: "
862 "'%s' collides with a submodule named "
863 "the same. Skipping it."),
864 oid_to_hex(commit_oid), p->two->path);
865 name = NULL;
866 }
867 }
868
869 if (!name)
870 continue;
871
872 item = string_list_insert(changed, name);
873 if (item->util)
874 cs_data = item->util;
875 else {
876 item->util = xcalloc(1, sizeof(struct changed_submodule_data));
877 cs_data = item->util;
878 cs_data->super_oid = commit_oid;
879 cs_data->path = xstrdup(p->two->path);
880 }
881 oid_array_append(&cs_data->new_commits, &p->two->oid);
882 }
883}
884
885/*
886 * Collect the paths of submodules in 'changed' which have changed based on

Callers

nothing calls this directly

Calls 9

submodule_from_pathFunction · 0.85
default_name_or_pathFunction · 0.85
submodule_from_nameFunction · 0.85
warningFunction · 0.85
oid_to_hexFunction · 0.85
string_list_insertFunction · 0.85
xcallocFunction · 0.85
xstrdupFunction · 0.85
oid_array_appendFunction · 0.85

Tested by

no test coverage detected