summaryrefslogtreecommitdiff
path: root/src/libgit2/index.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2022-01-22 08:49:06 -0500
committerEdward Thomson <ethomson@edwardthomson.com>2022-04-10 15:56:57 -0400
commit41d4ac51213b935b4478dff54011ae0860818539 (patch)
tree89a4762441e1e68efbda0e3ccbc38f7f1d59cf14 /src/libgit2/index.c
parent4fc3ce1558f13739fdb90c29729fe2276f0abe06 (diff)
downloadlibgit2-41d4ac51213b935b4478dff54011ae0860818539.tar.gz
index: use raw oid data
The index contains entries with raw oid data, use a byte array for the raw entry data.
Diffstat (limited to 'src/libgit2/index.c')
-rw-r--r--src/libgit2/index.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/libgit2/index.c b/src/libgit2/index.c
index aa97c6421..f44c507d3 100644
--- a/src/libgit2/index.c
+++ b/src/libgit2/index.c
@@ -74,7 +74,7 @@ struct entry_short {
uint32_t uid;
uint32_t gid;
uint32_t file_size;
- git_oid oid;
+ unsigned char oid[GIT_OID_RAWSZ];
uint16_t flags;
char path[1]; /* arbitrary length */
};
@@ -88,7 +88,7 @@ struct entry_long {
uint32_t uid;
uint32_t gid;
uint32_t file_size;
- git_oid oid;
+ unsigned char oid[GIT_OID_RAWSZ];
uint16_t flags;
uint16_t flags_extended;
char path[1]; /* arbitrary length */
@@ -2480,9 +2480,11 @@ static int read_entry(
entry.uid = ntohl(source.uid);
entry.gid = ntohl(source.gid);
entry.file_size = ntohl(source.file_size);
- git_oid_cpy(&entry.id, &source.oid);
entry.flags = ntohs(source.flags);
+ if (git_oid_fromraw(&entry.id, source.oid) < 0)
+ return -1;
+
if (entry.flags & GIT_INDEX_ENTRY_EXTENDED) {
uint16_t flags_raw;
size_t flags_offset;
@@ -2803,9 +2805,7 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
ondisk.uid = htonl(entry->uid);
ondisk.gid = htonl(entry->gid);
ondisk.file_size = htonl((uint32_t)entry->file_size);
-
- git_oid_cpy(&ondisk.oid, &entry->id);
-
+ git_oid_raw_cpy(ondisk.oid, entry->id.id);
ondisk.flags = htons(entry->flags);
if (entry->flags & GIT_INDEX_ENTRY_EXTENDED) {