summaryrefslogtreecommitdiff
path: root/transport.c
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2020-06-19 17:56:00 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-06-19 21:04:09 (GMT)
commit6161ce7bbeeb128dd1a176d8355e2ce18168b16a (patch)
treef501691afda185e462ed8be61f945707734f9715 /transport.c
parent371c4079f4d14bd9412fc62478407b319f13e3e1 (diff)
downloadgit-6161ce7bbeeb128dd1a176d8355e2ce18168b16a.zip
git-6161ce7bbeeb128dd1a176d8355e2ce18168b16a.tar.gz
git-6161ce7bbeeb128dd1a176d8355e2ce18168b16a.tar.bz2
bundle: detect hash algorithm when reading refs
Much like with the dumb HTTP transport, there isn't a way to explicitly specify the hash algorithm when dealing with a bundle, so detect the algorithm based on the length of the object IDs in the prerequisites and ref advertisements. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport.c')
-rw-r--r--transport.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/transport.c b/transport.c
index b43d985..38a432b 100644
--- a/transport.c
+++ b/transport.c
@@ -143,6 +143,9 @@ static struct ref *get_refs_from_bundle(struct transport *transport,
data->fd = read_bundle_header(transport->url, &data->header);
if (data->fd < 0)
die(_("could not read bundle '%s'"), transport->url);
+
+ transport->hash_algo = data->header.hash_algo;
+
for (i = 0; i < data->header.references.nr; i++) {
struct ref_list_entry *e = data->header.references.list + i;
struct ref *ref = alloc_ref(e->name);
@@ -157,11 +160,14 @@ static int fetch_refs_from_bundle(struct transport *transport,
int nr_heads, struct ref **to_fetch)
{
struct bundle_transport_data *data = transport->data;
+ int ret;
if (!data->get_refs_from_bundle_called)
get_refs_from_bundle(transport, 0, NULL);
- return unbundle(the_repository, &data->header, data->fd,
- transport->progress ? BUNDLE_VERBOSE : 0);
+ ret = unbundle(the_repository, &data->header, data->fd,
+ transport->progress ? BUNDLE_VERBOSE : 0);
+ transport->hash_algo = data->header.hash_algo;
+ return ret;
}
static int close_bundle(struct transport *transport)