-#define USE_THE_REPOSITORY_VARIABLE
-
#include "git-compat-util.h"
#include "config.h"
#include "commit.h"
die("bad %s argument: %s", opt->long_name, arg);
}
-static void feed_object(const struct object_id *oid, FILE *fh, int negative)
+static void feed_object(struct repository *r,
+ const struct object_id *oid, FILE *fh, int negative)
{
if (negative &&
- !repo_has_object_file_with_flags(the_repository, oid,
+ !repo_has_object_file_with_flags(r, oid,
OBJECT_INFO_SKIP_FETCH_OBJECT |
OBJECT_INFO_QUICK))
return;
/*
* Make a pack stream and spit it out into file descriptor fd
*/
-static int pack_objects(int fd, struct ref *refs, struct oid_array *advertised,
+static int pack_objects(struct repository *r,
+ int fd, struct ref *refs, struct oid_array *advertised,
struct oid_array *negotiated,
struct send_pack_args *args)
{
FILE *po_in;
int rc;
- trace2_region_enter("send_pack", "pack_objects", the_repository);
+ trace2_region_enter("send_pack", "pack_objects", r);
strvec_push(&po.args, "pack-objects");
strvec_push(&po.args, "--all-progress-implied");
strvec_push(&po.args, "--revs");
strvec_push(&po.args, "-q");
if (args->progress)
strvec_push(&po.args, "--progress");
- if (is_repository_shallow(the_repository))
+ if (is_repository_shallow(r))
strvec_push(&po.args, "--shallow");
if (args->disable_bitmaps)
strvec_push(&po.args, "--no-use-bitmap-index");
*/
po_in = xfdopen(po.in, "w");
for (size_t i = 0; i < advertised->nr; i++)
- feed_object(&advertised->oid[i], po_in, 1);
+ feed_object(r, &advertised->oid[i], po_in, 1);
for (size_t i = 0; i < negotiated->nr; i++)
- feed_object(&negotiated->oid[i], po_in, 1);
+ feed_object(r, &negotiated->oid[i], po_in, 1);
while (refs) {
if (!is_null_oid(&refs->old_oid))
- feed_object(&refs->old_oid, po_in, 1);
+ feed_object(r, &refs->old_oid, po_in, 1);
if (!is_null_oid(&refs->new_oid))
- feed_object(&refs->new_oid, po_in, 0);
+ feed_object(r, &refs->new_oid, po_in, 0);
refs = refs->next;
}
*/
if (rc > 128 && rc != 141)
error("pack-objects died of signal %d", rc - 128);
- trace2_region_leave("send_pack", "pack_objects", the_repository);
+ trace2_region_leave("send_pack", "pack_objects", r);
return -1;
}
- trace2_region_leave("send_pack", "pack_objects", the_repository);
+ trace2_region_leave("send_pack", "pack_objects", r);
return 0;
}
return 0;
}
-static int receive_status(struct packet_reader *reader, struct ref *refs)
+static int receive_status(struct repository *r,
+ struct packet_reader *reader, struct ref *refs)
{
struct ref *hint;
int ret;
int new_report = 0;
int once = 0;
- trace2_region_enter("send_pack", "receive_status", the_repository);
+ trace2_region_enter("send_pack", "receive_status", r);
hint = NULL;
ret = receive_unpack_status(reader);
while (1) {
if (!strcmp(key, "refname"))
report->ref_name = xstrdup_or_null(val);
else if (!strcmp(key, "old-oid") && val &&
- !parse_oid_hex(val, &old_oid, &val))
+ !parse_oid_hex_algop(val, &old_oid, &val, r->hash_algo))
report->old_oid = oiddup(&old_oid);
else if (!strcmp(key, "new-oid") && val &&
- !parse_oid_hex(val, &new_oid, &val))
+ !parse_oid_hex_algop(val, &new_oid, &val, r->hash_algo))
report->new_oid = oiddup(&new_oid);
else if (!strcmp(key, "forced-update"))
report->forced_update = 1;
new_report = 1;
}
}
- trace2_region_leave("send_pack", "receive_status", the_repository);
+ trace2_region_leave("send_pack", "receive_status", r);
return ret;
}
return 0;
}
-static void advertise_shallow_grafts_buf(struct strbuf *sb)
+static void advertise_shallow_grafts_buf(struct repository *r, struct strbuf *sb)
{
- if (!is_repository_shallow(the_repository))
+ if (!is_repository_shallow(r))
return;
for_each_commit_graft(advertise_shallow_grafts_cb, sb);
}
}
}
-static void get_commons_through_negotiation(const char *url,
+static void get_commons_through_negotiation(struct repository *r,
+ const char *url,
const struct ref *remote_refs,
struct oid_array *commons)
{
struct child_process child = CHILD_PROCESS_INIT;
const struct ref *ref;
- int len = the_hash_algo->hexsz + 1; /* hash + NL */
+ int len = r->hash_algo->hexsz + 1; /* hash + NL */
int nr_negotiation_tip = 0;
child.git_cmd = 1;
break;
if (read_len != len)
die("invalid length read %d", read_len);
- if (parse_oid_hex(hex_hash, &oid, &end) || *end != '\n')
+ if (parse_oid_hex_algop(hex_hash, &oid, &end, r->hash_algo) || *end != '\n')
die("invalid hash");
oid_array_append(commons, &oid);
} while (1);
}
}
-int send_pack(struct send_pack_args *args,
+int send_pack(struct repository *r,
+ struct send_pack_args *args,
int fd[], struct child_process *conn,
struct ref *remote_refs,
struct oid_array *extra_have)
goto out;
}
- git_config_get_bool("push.negotiate", &push_negotiate);
+ repo_config_get_bool(r, "push.negotiate", &push_negotiate);
if (push_negotiate) {
- trace2_region_enter("send_pack", "push_negotiate", the_repository);
- get_commons_through_negotiation(args->url, remote_refs, &commons);
- trace2_region_leave("send_pack", "push_negotiate", the_repository);
+ trace2_region_enter("send_pack", "push_negotiate", r);
+ get_commons_through_negotiation(r, args->url, remote_refs, &commons);
+ trace2_region_leave("send_pack", "push_negotiate", r);
}
- if (!git_config_get_bool("push.usebitmaps", &use_bitmaps))
+ if (!repo_config_get_bool(r, "push.usebitmaps", &use_bitmaps))
args->disable_bitmaps = !use_bitmaps;
- git_config_get_bool("transfer.advertisesid", &advertise_sid);
+ repo_config_get_bool(r, "transfer.advertisesid", &advertise_sid);
/* Does the other end support the reporting? */
if (server_supports("report-status-v2"))
if (server_supports("push-options"))
push_options_supported = 1;
- if (!server_supports_hash(the_hash_algo->name, &object_format_supported))
+ if (!server_supports_hash(r->hash_algo->name, &object_format_supported))
die(_("the receiving end does not support this repository's hash algorithm"));
if (args->push_cert != SEND_PACK_PUSH_CERT_NEVER) {
if (use_push_options)
strbuf_addstr(&cap_buf, " push-options");
if (object_format_supported)
- strbuf_addf(&cap_buf, " object-format=%s", the_hash_algo->name);
+ strbuf_addf(&cap_buf, " object-format=%s", r->hash_algo->name);
if (agent_supported)
strbuf_addf(&cap_buf, " agent=%s", git_user_agent_sanitized());
if (advertise_sid)
}
if (!args->dry_run)
- advertise_shallow_grafts_buf(&req_buf);
+ advertise_shallow_grafts_buf(r, &req_buf);
/*
* Finally, tell the other end!
}
if (args->stateless_rpc) {
- if (!args->dry_run && (cmds_sent || is_repository_shallow(the_repository))) {
+ if (!args->dry_run && (cmds_sent || is_repository_shallow(r))) {
packet_buf_flush(&req_buf);
send_sideband(out, -1, req_buf.buf, req_buf.len, LARGE_PACKET_MAX);
}
PACKET_READ_DIE_ON_ERR_PACKET);
if (need_pack_data && cmds_sent) {
- if (pack_objects(out, remote_refs, extra_have, &commons, args) < 0) {
+ if (pack_objects(r, out, remote_refs, extra_have, &commons, args) < 0) {
if (args->stateless_rpc)
close(out);
if (git_connection_is_socket(conn))
* we get one).
*/
if (status_report)
- receive_status(&reader, remote_refs);
+ receive_status(r, &reader, remote_refs);
if (use_sideband) {
close(demux.out);
packet_flush(out);
if (status_report && cmds_sent)
- ret = receive_status(&reader, remote_refs);
+ ret = receive_status(r, &reader, remote_refs);
else
ret = 0;
if (args->stateless_rpc)