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

Function mark_complete_and_common_ref

fetch-pack.c:791–865  ·  view source on GitHub ↗

* Mark recent commits available locally and reachable from a local ref as * COMPLETE. * * The cutoff time for recency is determined by this heuristic: it is the * earliest commit time of the objects in refs that are commits and that we know * the commit time of. */

Source from the content-addressed store, hash-verified

789 * the commit time of.
790 */
791static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,
792 struct fetch_pack_args *args,
793 struct ref **refs)
794{
795 struct ref *ref;
796 int old_save_commit_buffer = save_commit_buffer;
797 timestamp_t cutoff = 0;
798
799 if (args->refetch)
800 return;
801
802 save_commit_buffer = 0;
803
804 trace2_region_enter("fetch-pack", "parse_remote_refs_and_find_cutoff", NULL);
805 for (ref = *refs; ref; ref = ref->next) {
806 struct commit *commit;
807
808 commit = lookup_commit_in_graph(the_repository, &ref->old_oid);
809 if (!commit) {
810 struct object *o;
811
812 if (!odb_has_object(the_repository->objects, &ref->old_oid, 0))
813 continue;
814 o = parse_object(the_repository, &ref->old_oid);
815 if (!o || o->type != OBJ_COMMIT)
816 continue;
817
818 commit = (struct commit *)o;
819 }
820
821 /*
822 * We already have it -- which may mean that we were
823 * in sync with the other side at some time after
824 * that (it is OK if we guess wrong here).
825 */
826 if (!cutoff || cutoff < commit->date)
827 cutoff = commit->date;
828 }
829 trace2_region_leave("fetch-pack", "parse_remote_refs_and_find_cutoff", NULL);
830
831 /*
832 * This block marks all local refs as COMPLETE, and then recursively marks all
833 * parents of those refs as COMPLETE.
834 */
835 trace2_region_enter("fetch-pack", "mark_complete_local_refs", NULL);
836 if (!args->deepen) {
837 struct refs_for_each_ref_options opts = {
838 .flags = REFS_FOR_EACH_INCLUDE_BROKEN,
839 };
840
841 refs_for_each_ref_ext(get_main_ref_store(the_repository),
842 mark_complete_oid, NULL, &opts);
843 for_each_cached_alternate(NULL, mark_alternate_complete);
844 if (cutoff)
845 mark_recent_complete_commits(args, cutoff);
846 }
847 trace2_region_leave("fetch-pack", "mark_complete_local_refs", NULL);
848

Callers 2

do_fetch_packFunction · 0.85
do_fetch_pack_v2Function · 0.85

Calls 8

lookup_commit_in_graphFunction · 0.85
odb_has_objectFunction · 0.85
parse_objectFunction · 0.85
refs_for_each_ref_extFunction · 0.85
get_main_ref_storeFunction · 0.85
deref_without_lazy_fetchFunction · 0.85

Tested by

no test coverage detected