static int send_ref(const char *refname, const struct object_id *oid, int flag, void *cb_data) { static const char *capabilities = "multi_ack thin-pack side-band" " side-band-64k ofs-delta shallow no-progress" " include-tag multi_ack_detailed"; const char *refname_nons = strip_namespace(refname); struct object_id peeled; if (mark_our_ref(refname_nons, refname, oid)) return 0; if (capabilities) { struct strbuf symref_info = STRBUF_INIT; format_symref_info(&symref_info, cb_data); packet_write(1, "%s %s%c%s%s%s%s%s agent=%s\n", oid_to_hex(oid), refname_nons, 0, capabilities, (allow_unadvertised_object_request & ALLOW_TIP_SHA1) ? " allow-tip-sha1-in-want" : "", (allow_unadvertised_object_request & ALLOW_REACHABLE_SHA1) ? " allow-reachable-sha1-in-want" : "", stateless_rpc ? " no-done" : "", symref_info.buf, git_user_agent_sanitized()); strbuf_release(&symref_info); } else { packet_write(1, "%s %s\n", oid_to_hex(oid), refname_nons); } capabilities = NULL; if (!peel_ref(refname, peeled.hash)) packet_write(1, "%s %s^{}\n", oid_to_hex(&peeled), refname_nons); return 0; }
static int send_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data) { static const char *capabilities = "multi_ack thin-pack side-band" " side-band-64k ofs-delta shallow no-progress" " include-tag multi_ack_detailed"; const char *refname_nons = strip_namespace(refname); unsigned char peeled[20]; if (mark_our_ref(refname, sha1, flag, NULL)) return 0; if (capabilities) { struct strbuf symref_info = STRBUF_INIT; format_symref_info(&symref_info, cb_data); packet_write(1, "%s %s%c%s%s%s%s agent=%s\n", sha1_to_hex(sha1), refname_nons, 0, capabilities, allow_tip_sha1_in_want ? " allow-tip-sha1-in-want" : "", stateless_rpc ? " no-done" : "", symref_info.buf, git_user_agent_sanitized()); strbuf_release(&symref_info); } else { packet_write(1, "%s %s\n", sha1_to_hex(sha1), refname_nons); } capabilities = NULL; if (!peel_ref(refname, peeled)) packet_write(1, "%s %s^{}\n", sha1_to_hex(peeled), refname_nons); return 0; }
static int send_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data) { static const char *capabilities = "multi_ack thin-pack side-band" " side-band-64k ofs-delta shallow no-progress" " include-tag multi_ack_detailed"; struct object *o = parse_object(sha1); const char *refname_nons = strip_namespace(refname); if (!o) die("git upload-pack: cannot find object %s:", sha1_to_hex(sha1)); if (capabilities) packet_write(1, "%s %s%c%s%s\n", sha1_to_hex(sha1), refname_nons, 0, capabilities, stateless_rpc ? " no-done" : ""); else packet_write(1, "%s %s\n", sha1_to_hex(sha1), refname_nons); capabilities = NULL; if (!(o->flags & OUR_REF)) { o->flags |= OUR_REF; nr_our_refs++; } if (o->type == OBJ_TAG) { o = deref_tag(o, refname, 0); if (o) packet_write(1, "%s %s^{}\n", sha1_to_hex(o->sha1), refname_nons); } return 0; }
static int check_ref(const char *refname_full, const struct object_id *oid, int flag, void *cb_data) { const char *refname = strip_namespace(refname_full); mark_our_ref(refname, refname_full, oid); return 0; }
static void check_aliased_update(struct command *cmd, struct string_list *list) { struct strbuf buf = STRBUF_INIT; const char *dst_name; struct string_list_item *item; struct command *dst_cmd; unsigned char sha1[GIT_SHA1_RAWSZ]; char cmd_oldh[GIT_SHA1_HEXSZ + 1], cmd_newh[GIT_SHA1_HEXSZ + 1], dst_oldh[GIT_SHA1_HEXSZ + 1], dst_newh[GIT_SHA1_HEXSZ + 1]; int flag; strbuf_addf(&buf, "%s%s", get_git_namespace(), cmd->ref_name); dst_name = resolve_ref_unsafe(buf.buf, 0, sha1, &flag); strbuf_release(&buf); if (!(flag & REF_ISSYMREF)) return; if (!dst_name) { rp_error("refusing update to broken symref '%s'", cmd->ref_name); cmd->skip_update = 1; cmd->error_string = "broken symref"; return; } dst_name = strip_namespace(dst_name); if ((item = string_list_lookup(list, dst_name)) == NULL) return; cmd->skip_update = 1; dst_cmd = (struct command *) item->util; if (!hashcmp(cmd->old_sha1, dst_cmd->old_sha1) && !hashcmp(cmd->new_sha1, dst_cmd->new_sha1)) return; dst_cmd->skip_update = 1; find_unique_abbrev_r(cmd_oldh, cmd->old_sha1, DEFAULT_ABBREV); find_unique_abbrev_r(cmd_newh, cmd->new_sha1, DEFAULT_ABBREV); find_unique_abbrev_r(dst_oldh, dst_cmd->old_sha1, DEFAULT_ABBREV); find_unique_abbrev_r(dst_newh, dst_cmd->new_sha1, DEFAULT_ABBREV); rp_error("refusing inconsistent update between symref '%s' (%s..%s) and" " its target '%s' (%s..%s)", cmd->ref_name, cmd_oldh, cmd_newh, dst_cmd->ref_name, dst_oldh, dst_newh); cmd->error_string = dst_cmd->error_string = "inconsistent aliased update"; }
static int show_ref_cb(const char *path, const unsigned char *sha1, int flag, void *cb_data) { path = strip_namespace(path); /* * Advertise refs outside our current namespace as ".have" * refs, so that the client can use them to minimize data * transfer but will otherwise ignore them. This happens to * cover ".have" that are thrown in by add_one_alternate_ref() * to mark histories that are complete in our alternates as * well. */ if (!path) path = ".have"; return show_ref(path, sha1, flag, cb_data); }
static int show_head_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data) { struct strbuf *buf = cb_data; if (flag & REF_ISSYMREF) { unsigned char unused[20]; const char *target = resolve_ref_unsafe(refname, unused, 1, NULL); const char *target_nons = strip_namespace(target); strbuf_addf(buf, "ref: %s\n", target_nons); } else { strbuf_addf(buf, "%s\n", sha1_to_hex(sha1)); } return 0; }
static int show_head_ref(const char *refname, const struct object_id *oid, int flag, void *cb_data) { struct strbuf *buf = cb_data; if (flag & REF_ISSYMREF) { const char *target = resolve_ref_unsafe(refname, RESOLVE_REF_READING, NULL, NULL); if (target) strbuf_addf(buf, "ref: %s\n", strip_namespace(target)); } else { strbuf_addf(buf, "%s\n", oid_to_hex(oid)); } return 0; }
static int show_text_ref(const char *name, const unsigned char *sha1, int flag, void *cb_data) { const char *name_nons = strip_namespace(name); struct strbuf *buf = cb_data; struct object *o = parse_object(sha1); if (!o) return 0; strbuf_addf(buf, "%s\t%s\n", sha1_to_hex(sha1), name_nons); if (o->type == OBJ_TAG) { o = deref_tag(o, name, 0); if (!o) return 0; strbuf_addf(buf, "%s\t%s^{}\n", sha1_to_hex(o->sha1), name_nons); } return 0; }
static int show_text_ref(const char *name, const struct object_id *oid, int flag, void *cb_data) { const char *name_nons = strip_namespace(name); struct strbuf *buf = cb_data; struct object *o = parse_object(oid->hash); if (!o) return 0; strbuf_addf(buf, "%s\t%s\n", oid_to_hex(oid), name_nons); if (o->type == OBJ_TAG) { o = deref_tag(o, name, 0); if (!o) return 0; strbuf_addf(buf, "%s\t%s^{}\n", oid_to_hex(&o->oid), name_nons); } return 0; }
static int show_ref_cb(const char *path_full, const struct object_id *oid, int flag, void *unused) { const char *path = strip_namespace(path_full); if (ref_is_hidden(path, path_full)) return 0; /* * Advertise refs outside our current namespace as ".have" * refs, so that the client can use them to minimize data * transfer but will otherwise ignore them. This happens to * cover ".have" that are thrown in by add_one_alternate_ref() * to mark histories that are complete in our alternates as * well. */ if (!path) path = ".have"; show_ref(path, oid->hash); return 0; }