replacement in vertex.h at line 7
− typedef uint64_t change_position;
+ typedef uint64_t changepos;
edit in vertex.h at line 21
+ Hash change;
+ changepos pos;
edit in vertex.h at line 24
+
+ typedef struct {
+ size_t len;
+ Position first; /* Reserve space for the first Position, most changes appear to have just one */
+ Position *entries;
+ } Positionlist;
replacement in vertex.h at line 36
[2.47]→[3.555:621](∅→∅),
[3.555]→[3.555:621](∅→∅) − void *change;
− change_position start, end; /* line identifier */
+ Hash change;
+ changepos start, end; /* line identifier */
edit in hunk.h at line 6
+ unsigned int line; /* This is defined as usize, but it's probably better as a u64 */
replacement in hunk.h at line 30
[2.210]→[3.1015:1031](∅→∅),
[3.1015]→[3.1015:1031](∅→∅) + Atom change;
+ Local local;
+ str encoding;
replacement in hunk.h at line 47
[2.371]→[3.1263:1272](∅→∅),
[3.1263]→[3.1263:1272](∅→∅) edit in hunk.h at line 50
+ typedef struct {
+ size_t len;
+ Basehunk *entries;
+ } Hunklist;
+
edit in hunk.h at line 56
+ void hunk_hunklistinit(Hunklist *, size_t);
edit in hunk.c at line 5
+ #include "scaffold.h"
+ #include "hash.h"
+ #include "vertex.h"
+ #include "atom.h"
edit in hunk.c at line 44
+ }
+
+ void
+ hunk_hunklistinit(Hunklist *hunklist, size_t len)
+ {
+ hunklist->len = len;
+ hunklist->entries = xmalloc(sizeof(Basehunk) * len);
edit in hash.h at line 19
+ void hashprintln(Hash *);
edit in hash.c at line 11
+ hashprintln(Hash *hash)
+ {
+ hashprint(hash);
+ printf("\n");
+ }
+
+ void
replacement in hash.c at line 29
[2.692]→[3.132:159](∅→∅),
[3.132]→[3.132:159](∅→∅) − printf("%s\n", b32hash);
edit in change.h at line 73
+ uint8_t *metadata;
+ Hunklist hunks;
edit in change.c at line 15
+ #include "vertex.h"
+ #include "atom.h"
+ #include "hunk.h"
edit in change.c at line 21
[3.2152]→[3.2152:2208](∅→∅) − #include "atom.h"
− #include "vertex.h"
− #include "hunk.h"
replacement in change.c at line 22
replacement in change.c at line 155
replacement in change.c at line 169
− memcpy(target->entries[i].bytes, binstat->buf,
− BLAKE3_BYTES);
− binstat->buf += BLAKE3_BYTES;
− binstat->avail -= BLAKE3_BYTES;
+ bincode_getbytes(
+ binstat, target->entries[i].bytes, BLAKE3_BYTES
+ );
replacement in change.c at line 182
[3.2252]→[3.2252:2257](∅→∅),
[3.2257]→[2.2619:2660](∅→∅) − void
− change_decode_position(Bincode *binstat)
+ static void
+ change_decode_position(Bincode *binstat, Position *pos)
edit in change.c at line 185
[3.2313]→[2.2661:2722](∅→∅),
[2.2722]→[3.2380:2381](∅→∅),
[3.2380]→[3.2380:2381](∅→∅) − uint64_t changepos; /* FIXME this should be its own type */
−
replacement in change.c at line 186
[3.2412]→[2.2723:2736](∅→∅),
[2.2736]→[3.2432:2509](∅→∅),
[3.2432]→[3.2432:2509](∅→∅) − Hash hash;
− hash.variant = (uint8_t)bincode_getu32(binstat);
− switch (hash.variant) {
+ pos->change.variant = (uint8_t)bincode_getu32(binstat);
+ switch (pos->change.variant) {
+ case HASH_BLAKE3:
+ bincode_getbytes(
+ binstat, (uint8_t *)&pos->change.bytes,
+ BLAKE3_BYTES
+ );
+ break;
edit in change.c at line 196
+ default:
+ abort();
+ }
+ }
+ pos->pos = bincode_getu64(binstat);
+ }
+
+ static void
+ change_decode_vertex(Bincode *binstat, Vertex *v)
+ {
+ Hash *hash;
+
+ hash = &v->change;
+
+ uint8_t ishash = bincode_getu8(binstat);
+ if (ishash) {
+ hash->variant = (uint8_t)bincode_getu32(binstat);
+ switch (hash->variant) {
replacement in change.c at line 216
[3.2578]→[3.2578:2627](∅→∅) − binstat, (uint8_t *)hash.bytes, BLAKE3_BYTES
+ binstat, (uint8_t *)hash->bytes, BLAKE3_BYTES
edit in change.c at line 219
+ case HASH_NONE:
+ break;
replacement in change.c at line 224
[3.2670]→[2.2737:2757](∅→∅) + }
+ v->start = bincode_getu64(binstat);
+ v->end = bincode_getu64(binstat);
+ if (ishash) {
+ printf("V(Some(");
+ hashprint(hash);
+ printf(")[%lu:%lu])\n", v->start, v->end);
+ } else {
+ printf("V(None)\n");
edit in change.c at line 234
[3.2694]→[2.2758:2841](∅→∅) − changepos = bincode_getu64(binstat);
− printf("ChangePosition(%lu)\n", changepos);
replacement in change.c at line 236
[3.2792]→[3.2792:2797](∅→∅),
[3.2797]→[2.2842:2882](∅→∅) − void
− change_decode_newedge(Bincode *binstat)
+ static void
+ change_decode_introducedby(Bincode *binstat, Hash *hash)
replacement in change.c at line 239
[3.2852]→[3.2852:2877](∅→∅) − uint8_t previous, flag;
replacement in change.c at line 241
[3.2878]→[3.2878:3053](∅→∅) − dump_buf("newedge", binstat->buf, binstat->avail);
− previous = bincode_getu8(binstat);
− flag = bincode_getu8(binstat);
− printf("previous = %u, flag = %u\n", previous, flag);
+ ishash = bincode_getu8(binstat);
+ if (ishash) {
+ hash->variant = (uint8_t)bincode_getu32(binstat);
+ switch (hash->variant) {
+ case HASH_BLAKE3:
+ bincode_getbytes(
+ binstat, (uint8_t *)hash->bytes, BLAKE3_BYTES
+ );
+ break;
+ case HASH_NONE:
+ break;
+ default:
+ abort();
+ }
+ printf("introduced_by: ");
+ if (ishash) {
+ printf("Some(");
+ hashprint(hash);
+ printf(")\n");
+ } else {
+ printf("None\n");
+ }
+ }
+ }
+ static void
+ change_decode_newedge(Bincode *binstat, Edge *edge)
+ {
+ edge->previous = bincode_getu8(binstat);
+ edge->flag = bincode_getu8(binstat);
+ printf("previous = %u, flag = %u\n", edge->previous, edge->flag);
replacement in change.c at line 272
[3.3113]→[3.3113:3192](∅→∅) − /* from: Position<Change = Option<Hash>> */
− change_decode_position(binstat);
+
+ change_decode_position(binstat, &edge->from);
+
+ change_decode_vertex(binstat, &edge->to);
+
+ change_decode_introducedby(binstat, &edge->introducedby);
+ }
+
+ static void
+ change_decode_positionlist(Bincode *binstat, Positionlist *poslist)
+ {
+ size_t len;
+ int i;
replacement in change.c at line 286
[3.3193]→[3.3193:3261](∅→∅) − /* to: V(Some(HASH)[range?]) */
− /* introduced_by: Option<Hash> */
+ poslist->len = len = bincode_getu64(binstat);
+ if (len > 1)
+ poslist->entries = xmalloc(sizeof(Position) * (len - 1));
+ if (len > 0) {
+ change_decode_position(binstat, &poslist->first);
+ for (i = 0; i < len - 1; i++)
+ change_decode_position(binstat, &poslist->entries[i]);
+ }
replacement in change.c at line 296
[3.3264]→[3.3264:3269](∅→∅),
[3.3269]→[2.2883:2920](∅→∅) − void
− change_decode_atom(Bincode *binstat)
+ static void
+ change_decode_newvertex(Bincode *binstat, Newvertex *newvertex)
replacement in change.c at line 299
[3.3321]→[3.3321:3342](∅→∅) + /* Fields: upcontext: Vec<Position>, downcontext: Vec<Position>, flag, start, end: ChangePosition, inode: Position */
+
+ printf("Decoding Newvertex\n");
+ change_decode_positionlist(binstat, &newvertex->upcontext);
+ change_decode_positionlist(binstat, &newvertex->downcontext);
+
+ newvertex->flag = bincode_getu8(binstat);
+ newvertex->start = bincode_getu64(binstat);
+ newvertex->end = bincode_getu64(binstat);
+
+ change_decode_position(binstat, &newvertex->inode);
+ }
+
+ static void
+ change_decode_atom(Bincode *binstat, Atom *atom)
+ {
replacement in change.c at line 318
[3.3387]→[3.3387:3439](∅→∅) − case 0: /* NewVertex<Option<Hash>> */
− /* TODO */
+ case 0:
+ atom->atomtype = NEW_VERTEX;
+ change_decode_newvertex(binstat, &atom->newvertex);
replacement in change.c at line 324
[3.3481]→[3.3481:3674](∅→∅) − edges_len = bincode_getu64(binstat);
− printf("EdgeMap (%lu elements)\n", edges_len);
− for (i = 0; i < edges_len; i++) {
− change_decode_newedge(binstat);
− break; /* FIXME remove this */
+ atom->atomtype = EDGE_MAP;
+ atom->edgemap.edges.len = bincode_getu64(binstat);
+ atom->edgemap.edges.entries =
+ xmalloc(sizeof(Edge) * atom->edgemap.edges.len);
+ printf("EdgeMap (%lu elements)\n", atom->edgemap.edges.len);
+ for (i = 0; i < atom->edgemap.edges.len; i++) {
+ change_decode_newedge(
+ binstat, &atom->edgemap.edges.entries[i]
+ );
edit in change.c at line 334
+ /* inode */
+ change_decode_position(binstat, &atom->edgemap.inode);
edit in change.c at line 337
[3.3679]→[3.3679:3721](∅→∅) − /* A Position<Change = Option<Hash>> */
edit in change.c at line 340
+ }
+ }
+
+ static void
+ change_decode_local(Bincode *binstat, Local *local)
+ {
+ uint64_t len;
+
+ len = bincode_getu64(binstat);
+ local->path = bincode_getstr(binstat, len);
+ local->line = bincode_getu64(binstat);
+ }
+
+ static void
+ change_decode_encoding(Bincode *binstat, char **encoding)
+ {
+ /* This is an optional field - basically just an Option<String> */
+ if (bincode_getu8(binstat)) {
+ uint64_t len = bincode_getu64(binstat);
+ *encoding = bincode_getstr(binstat, len);
replacement in change.c at line 366
[3.3797]→[3.3797:3802](∅→∅),
[3.3802]→[2.2921:2959](∅→∅) − void
− change_decode_hunks(Bincode *binstat)
+ static void
+ change_decode_hunks(Bincode *binstat, Hashed *hashed)
edit in change.c at line 373
+ hunk_hunklistinit(&hashed->hunks, len);
+
replacement in change.c at line 376
[3.3940]→[2.2960:3012](∅→∅),
[2.3012]→[3.3998:4062](∅→∅),
[3.3998]→[3.3998:4062](∅→∅) − basehunktype hunk_type = bincode_getu32(binstat);
− printf("%d. %s\n", i + 1, hunk_basehunk_type_str(hunk_type));
+ Basehunk *bhunk = &hashed->hunks.entries[i];
+ bhunk->hunktype = bincode_getu32(binstat);
+ /* printf("%d. %s\n", i + 1, hunk_basehunk_type_str(bhunk->hunktype)); */
replacement in change.c at line 380
[3.4063]→[3.4063:4086](∅→∅) + switch (bhunk->hunktype) {
replacement in change.c at line 382
[3.4099]→[3.4099:4304](∅→∅) − printf("Edit. change: Atom, local: Local, encoding: Option<Encoding>\n"
− );
− change_decode_atom(binstat); /* the change field */
− /* change_decode_local */
− /* change_decode_encoding (maybe) */
+ /* An edit is a (1) Atom (2) Local (3) Option<Encoding> */
+ change_decode_atom(
+ binstat, &bhunk->edit.change
+ ); /* the change field */
+ change_decode_local(binstat, &bhunk->edit.local);
+ change_decode_encoding(binstat, &bhunk->edit.encoding);
+ printf("%d. Edit in %s:%d\n", i + 1,
+ bhunk->edit.local.path, bhunk->edit.local.line);
replacement in change.c at line 398
[3.4491]→[3.4491:4531](∅→∅) − hunk_basehunk_type_str(hunk_type));
+ hunk_basehunk_type_str(bhunk->hunktype));
edit in change.c at line 401
[3.620]→[3.4532:4599](∅→∅) − break; /* FIXME: Remove once full Hunk parsing is implemented */
replacement in change.c at line 407
[3.1079]→[3.1079:1083](∅→∅) edit in change.c at line 449
− /* dump_buf("hashed", buf, hashed_len); */
replacement in change.c at line 501
[3.76]→[3.4600:4675](∅→∅),
[3.4675]→[3.128:179](∅→∅),
[3.128]→[3.128:179](∅→∅) − uint8_t *bytes = xmalloc(len);
− bincode_getbytes(&binstat, bytes, len);
− dump_buf("metadata", bytes, len);
− free(bytes);
+ hashed->metadata = xmalloc(len);
+ bincode_getbytes(&binstat, hashed->metadata, len);
edit in change.c at line 505
− dump_buf("buf", binstat.buf, binstat.avail);
replacement in change.c at line 506
[3.278]→[3.4676:4708](∅→∅) − change_decode_hunks(&binstat);
+ change_decode_hunks(&binstat, hashed);
replacement in change.c at line 606
[3.2072]→[2.3345:3391](∅→∅) − hashprint(&hashed.dependencies.entries[i]);
+ hashprintln(&hashed.dependencies.entries[i]);
replacement in change.c at line 610
[3.2185]→[2.3440:3484](∅→∅) − hashprint(&hashed.extraknown.entries[i]);
+ hashprintln(&hashed.extraknown.entries[i]);
replacement in atom.h at line 16
[2.4340]→[2.4340:4401](∅→∅) − Hash upcontext; /* FIXME Option<Hash> */
− Hash downcontext;
+ uint8_t previous;
+ uint8_t flag;
+ Position from;
+ Vertex to;
+ Hash introducedby; /* FIXME Should be Option */
+ } Edge;
+
+ typedef struct {
+ size_t len;
+ Edge *entries;
+ } Edgelist;
+
+ typedef struct {
+ Positionlist upcontext;
+ Positionlist downcontext;
replacement in atom.h at line 34
[3.5446]→[3.5446:5530](∅→∅) − /* FIXME inode: Position<Option<Hash>> = struct { change: Option<Hash>, pos: } */
edit in atom.h at line 38
+ Edgelist edges;
+ Position inode;