loose: add a mapping between SHA-1 and SHA-256 for loose objects

As part of the transition plan, we'd like to add a file in the .git
directory that maps loose objects between SHA-1 and SHA-256.  Let's
implement the specification in the transition plan and store this data
on a per-repository basis in struct repository.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
brian m. carlson
2023-10-01 21:40:09 -05:00
committed by Junio C Hamano
parent 15a1ca1abe
commit 23b2c7e95b
7 changed files with 293 additions and 1 deletions

View File

@@ -4,6 +4,7 @@
#include "repository.h"
#include "hash-ll.h"
#include "object.h"
#include "loose.h"
#include "object-file-convert.h"
int repo_oid_to_algop(struct repository *repo, const struct object_id *src,
@@ -21,7 +22,18 @@ int repo_oid_to_algop(struct repository *repo, const struct object_id *src,
oidcpy(dest, src);
return 0;
}
return -1;
if (repo_loose_object_map_oid(repo, src, to, dest)) {
/*
* We may have loaded the object map at repo initialization but
* another process (perhaps upstream of a pipe from us) may have
* written a new object into the map. If the object is missing,
* let's reload the map to see if the object has appeared.
*/
repo_read_loose_object_map(repo);
if (repo_loose_object_map_oid(repo, src, to, dest))
return -1;
}
return 0;
}
int convert_object_file(struct strbuf *outbuf,