change: extract hash list decoding into reused function
Dependencies
- [2]
XTKRT6OQformat the codebase - [3]
OBKF6SIIchange: decompress the hashed section too - [4]
VXGUQZIVbincode: rework so functions advance pointer - [5]
LVX6U4EKchange: decode metadata bytes - [6]
YG4DZB3Aadd representation of hash, decode dependencies - [7]
LCEKN25Gchange: parse authors - [8]
4RYULBDDbincode: introduce a bincode_state struct - [9]
Y26WT3ZFchange: decode message, description and timestamp - [*]
Q7TKZCJPAdd initial support for reading the offsets from a (fixed) change
Change contents
- edit in change.c at line 155
voidchange_decode_hashlist(struct bincode_state *binstat, struct hash_list *target){size_t len;int i;len = bincode_getu64(binstat);target->len = len;target->entries = xmalloc(sizeof(struct hash) * len); - edit in change.c at line 166
for (i = 0; i < target->len; i++) {target->entries[i].variant = bincode_getu32(binstat);switch (target->entries[i].variant) {case HASH_BLAKE3:memcpy(target->entries[i].bytes, binstat->buf,BLAKE3_BYTES);binstat->buf += BLAKE3_BYTES;binstat->avail -= BLAKE3_BYTES;break;case HASH_NONE:/* Do nothing, no bytes to consume */break;default:abort();}}} - edit in change.c at line 284
printf("# Dependencies\n"); - replacement in change.c at line 286
len = bincode_getu64(&binstat);hashed.dependencies.len = len;hashed.dependencies.entries = xmalloc(sizeof(struct hash) * len);change_decode_hashlist(&binstat, &hashed.dependencies); - edit in change.c at line 288[3.1177]→[3.1014:1094](∅→∅),[3.1094]→[2.1618:1690](∅→∅),[2.1690]→[3.1163:1235](∅→∅),[3.1163]→[3.1163:1235](∅→∅),[3.1235]→[2.1691:1777](∅→∅),[2.1777]→[3.1311:1530](∅→∅),[3.1311]→[3.1311:1530](∅→∅),[3.1530]→[3.1177:1180](∅→∅),[3.1177]→[3.1177:1180](∅→∅),[3.1227]→[3.1639:1640](∅→∅),[3.1639]→[3.1639:1640](∅→∅)
printf("[[dependencies]]\n");for (i = 0; i < hashed.dependencies.len; i++) {hashed.dependencies.entries[i].variant =bincode_getu32(&binstat);switch (hashed.dependencies.entries[i].variant) {case HASH_BLAKE3:memcpy(hashed.dependencies.entries[i].bytes,binstat.buf, BLAKE3_BYTES);binstat.buf += BLAKE3_BYTES;binstat.avail -= BLAKE3_BYTES;break;case HASH_NONE:/* Do nothing, no bytes to consume */break;default:abort();}hash_print(&hashed.dependencies.entries[i]);} - replacement in change.c at line 289[3.1575]→[3.1575:1705](∅→∅),[3.1705]→[3.1640:1641](∅→∅),[3.1640]→[3.1640:1641](∅→∅),[3.1641]→[3.1706:1784](∅→∅),[3.1784]→[2.1778:1849](∅→∅),[2.1849]→[3.1852:1923](∅→∅),[3.1852]→[3.1852:1923](∅→∅),[3.1923]→[2.1850:1935](∅→∅),[2.1935]→[3.1998:2219](∅→∅),[3.1998]→[3.1998:2219](∅→∅)
len = bincode_getu64(&binstat);hashed.extra_known.len = len;hashed.extra_known.entries = xmalloc(sizeof(struct hash) * len);printf("[[extra_known]]\n");for (i = 0; i < hashed.extra_known.len; i++) {hashed.extra_known.entries[i].variant =bincode_getu32(&binstat);switch (hashed.extra_known.entries[i].variant) {case HASH_BLAKE3:memcpy(hashed.extra_known.entries[i].bytes, binstat.buf,BLAKE3_BYTES);binstat.buf += BLAKE3_BYTES;binstat.avail -= BLAKE3_BYTES;break;case HASH_NONE:/* Do nothing, no bytes to consume */break;default:abort();}hash_print(&hashed.extra_known.entries[i]);}change_decode_hashlist(&binstat, &hashed.extra_known);