aboutsummaryrefslogtreecommitdiffstats
path: root/object-file-convert.c
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2023-10-01 21:40:09 -0500
committerJunio C Hamano <gitster@pobox.com>2023-10-02 14:57:38 -0700
commit23b2c7e95b6f8f3045665835d2dc5028701eff18 (patch)
treeffc99ac1e4307004da2e31947e6806de3259319a /object-file-convert.c
parent15a1ca1abe8dafa9bf3bf924b4e3c6b851717ee2 (diff)
downloadgit-23b2c7e95b6f8f3045665835d2dc5028701eff18.tar.gz
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>
Diffstat (limited to 'object-file-convert.c')
-rw-r--r--object-file-convert.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/object-file-convert.c b/object-file-convert.c
index 4777aba836..1ec945eaa1 100644
--- a/object-file-convert.c
+++ b/object-file-convert.c
@@ -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,