Commit 41d4ac51 by Edward Thomson

index: use raw oid data

The index contains entries with raw oid data, use a byte array for the
raw entry data.
parent 4fc3ce15
...@@ -74,7 +74,7 @@ struct entry_short { ...@@ -74,7 +74,7 @@ struct entry_short {
uint32_t uid; uint32_t uid;
uint32_t gid; uint32_t gid;
uint32_t file_size; uint32_t file_size;
git_oid oid; unsigned char oid[GIT_OID_RAWSZ];
uint16_t flags; uint16_t flags;
char path[1]; /* arbitrary length */ char path[1]; /* arbitrary length */
}; };
...@@ -88,7 +88,7 @@ struct entry_long { ...@@ -88,7 +88,7 @@ struct entry_long {
uint32_t uid; uint32_t uid;
uint32_t gid; uint32_t gid;
uint32_t file_size; uint32_t file_size;
git_oid oid; unsigned char oid[GIT_OID_RAWSZ];
uint16_t flags; uint16_t flags;
uint16_t flags_extended; uint16_t flags_extended;
char path[1]; /* arbitrary length */ char path[1]; /* arbitrary length */
...@@ -2480,9 +2480,11 @@ static int read_entry( ...@@ -2480,9 +2480,11 @@ static int read_entry(
entry.uid = ntohl(source.uid); entry.uid = ntohl(source.uid);
entry.gid = ntohl(source.gid); entry.gid = ntohl(source.gid);
entry.file_size = ntohl(source.file_size); entry.file_size = ntohl(source.file_size);
git_oid_cpy(&entry.id, &source.oid);
entry.flags = ntohs(source.flags); entry.flags = ntohs(source.flags);
if (git_oid_fromraw(&entry.id, source.oid) < 0)
return -1;
if (entry.flags & GIT_INDEX_ENTRY_EXTENDED) { if (entry.flags & GIT_INDEX_ENTRY_EXTENDED) {
uint16_t flags_raw; uint16_t flags_raw;
size_t flags_offset; size_t flags_offset;
...@@ -2803,9 +2805,7 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha ...@@ -2803,9 +2805,7 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
ondisk.uid = htonl(entry->uid); ondisk.uid = htonl(entry->uid);
ondisk.gid = htonl(entry->gid); ondisk.gid = htonl(entry->gid);
ondisk.file_size = htonl((uint32_t)entry->file_size); ondisk.file_size = htonl((uint32_t)entry->file_size);
git_oid_raw_cpy(ondisk.oid, entry->id.id);
git_oid_cpy(&ondisk.oid, &entry->id);
ondisk.flags = htons(entry->flags); ondisk.flags = htons(entry->flags);
if (entry->flags & GIT_INDEX_ENTRY_EXTENDED) { if (entry->flags & GIT_INDEX_ENTRY_EXTENDED) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment