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

Function update_local_ref

builtin/fetch.c:940–1109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

938}
939
940static int update_local_ref(struct ref *ref,
941 struct ref_transaction *transaction,
942 const struct ref *remote_ref,
943 const struct fetch_config *config,
944 struct ref_update_display_info_array *display_array)
945{
946 struct commit *current = NULL, *updated;
947 int fast_forward = 0;
948
949 if (!odb_has_object(the_repository->objects, &ref->new_oid,
950 ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
951 die(_("object %s not found"), oid_to_hex(&ref->new_oid));
952
953 if (oideq(&ref->old_oid, &ref->new_oid)) {
954 if (verbosity > 0)
955 ref_update_display_info_append(display_array, '=', '=',
956 _("[up to date]"), NULL,
957 NULL, ref->name,
958 remote_ref->name, &ref->old_oid,
959 &ref->new_oid);
960 return 0;
961 }
962
963 if (!update_head_ok &&
964 !is_null_oid(&ref->old_oid) &&
965 branch_checked_out(ref->name)) {
966 struct ref_update_display_info *info;
967 /*
968 * If this is the head, and it's not okay to update
969 * the head, and the old value of the head isn't empty...
970 */
971 info = ref_update_display_info_append(display_array, '!', '!',
972 _("[rejected]"), NULL,
973 _("can't fetch into checked-out branch"),
974 ref->name, remote_ref->name,
975 &ref->old_oid, &ref->new_oid);
976 ref_update_display_info_set_failed(info);
977 return 1;
978 }
979
980 if (!is_null_oid(&ref->old_oid) &&
981 starts_with(ref->name, "refs/tags/")) {
982 struct ref_update_display_info *info;
983
984 if (force || ref->force) {
985 int r;
986
987 r = s_update_ref("updating tag", ref, transaction, 0);
988
989 info = ref_update_display_info_append(display_array, 't', '!',
990 _("[tag update]"), NULL,
991 _("unable to update local ref"),
992 ref->name, remote_ref->name,
993 &ref->old_oid, &ref->new_oid);
994 if (r)
995 ref_update_display_info_set_failed(info);
996
997 return r;

Callers 1

store_updated_refsFunction · 0.85

Calls 15

odb_has_objectFunction · 0.85
oid_to_hexFunction · 0.85
oideqFunction · 0.85
is_null_oidFunction · 0.85
branch_checked_outFunction · 0.85
starts_withFunction · 0.85
s_update_refFunction · 0.85
getnanotimeFunction · 0.85
repo_in_merge_basesFunction · 0.85

Tested by

no test coverage detected