static void reject_updates_to_hidden(struct command *commands) { struct strbuf refname_full = STRBUF_INIT; size_t prefix_len; struct command *cmd; strbuf_addstr(&refname_full, get_git_namespace()); prefix_len = refname_full.len; for (cmd = commands; cmd; cmd = cmd->next) { if (cmd->error_string) continue; strbuf_setlen(&refname_full, prefix_len); strbuf_addstr(&refname_full, cmd->ref_name); if (!ref_is_hidden(cmd->ref_name, refname_full.buf)) continue; if (is_null_sha1(cmd->new_sha1)) cmd->error_string = "deny deleting a hidden ref"; else cmd->error_string = "deny updating a hidden ref"; } strbuf_release(&refname_full); }
static void show_ref(const char *path, const unsigned char *sha1) { if (ref_is_hidden(path)) return; if (sent_capabilities) { packet_write(1, "%s %s\n", sha1_to_hex(sha1), path); } else { struct strbuf cap = STRBUF_INIT; strbuf_addstr(&cap, "report-status delete-refs side-band-64k quiet"); if (advertise_atomic_push) strbuf_addstr(&cap, " atomic"); if (prefer_ofs_delta) strbuf_addstr(&cap, " ofs-delta"); if (push_cert_nonce) strbuf_addf(&cap, " push-cert=%s", push_cert_nonce); strbuf_addf(&cap, " agent=%s", git_user_agent_sanitized()); packet_write(1, "%s %s%c%s\n", sha1_to_hex(sha1), path, 0, cap.buf); strbuf_release(&cap); sent_capabilities = 1; } }
/* return non-zero if the ref is hidden, otherwise 0 */ static int mark_our_ref(const char *refname, const char *refname_full, const struct object_id *oid) { struct object *o = lookup_unknown_object(oid->hash); if (ref_is_hidden(refname, refname_full)) { o->flags |= HIDDEN_REF; return 1; } o->flags |= OUR_REF; return 0; }
/* return non-zero if the ref is hidden, otherwise 0 */ static int mark_our_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data) { struct object *o = lookup_unknown_object(sha1); if (ref_is_hidden(refname)) { o->flags |= HIDDEN_REF; return 1; } if (!o) die("git upload-pack: cannot find object %s:", sha1_to_hex(sha1)); o->flags |= OUR_REF; return 0; }
static void reject_updates_to_hidden(struct command *commands) { struct command *cmd; for (cmd = commands; cmd; cmd = cmd->next) { if (cmd->error_string || !ref_is_hidden(cmd->ref_name)) continue; if (is_null_sha1(cmd->new_sha1)) cmd->error_string = "deny deleting a hidden ref"; else cmd->error_string = "deny updating a hidden ref"; } }
static void show_ref(const char *path, const unsigned char *sha1) { if (ref_is_hidden(path)) return; if (sent_capabilities) packet_write(1, "%s %s\n", sha1_to_hex(sha1), path); else packet_write(1, "%s %s%c%s%s agent=%s\n", sha1_to_hex(sha1), path, 0, " report-status delete-refs side-band-64k quiet", prefer_ofs_delta ? " ofs-delta" : "", git_user_agent_sanitized()); sent_capabilities = 1; }
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; }