change: decode FILE_ADD

laumann
Jun 26, 2023, 9:44 AM
TGT4VSMEWWTFYILTXVZWA5WHB2RCZZYNGZJ3UUKZ5OPD6JQD4G5QC

Dependencies

  • [2] N3PUHKQN change: fix scoping issue
  • [3] YDQLW2ZO change: rework printing of patches - print Edit and Newvertex types
  • [4] XTVLIC24 change: refactor to print_change()
  • [5] NZNIG2UL Fix lots of warnings, adjust build flags
  • [6] QLH63JBH change: replace calls to abort() with die()
  • [*] Q7TKZCJP Add initial support for reading the offsets from a (fixed) change
  • [*] JAGXXSR7 change: initial work on decoding hunks
  • [*] FMYCPGKD change: extract hash list decoding into reused function
  • [*] RIWSVVAS change: decompress the 'contents' with zstd_seekable

Change contents

  • edit in change.c at line 323
    [9.4442]
    [10.583]
    break;
    case FILE_ADD:
    change_decode_atom(binstat, &bhunk->fileadd.addname);
    change_decode_atom(binstat, &bhunk->fileadd.addinode);
    if (bincode_getu8(binstat))
    change_decode_atom(
    binstat, &bhunk->fileadd.contents
    );
    slen = bincode_getu64(binstat);
    bhunk->fileadd.path = bincode_getstr(binstat, slen);
    change_decode_encoding(binstat, &bhunk->edit.encoding);
  • edit in change.c at line 482
    [11.2595]
    [11.2595]
    void
    print_edgeflags(uint8_t flags)
    {
    if (flags & EDGE_FLAG_BLOCK)
    printf("B");
    if (flags & EDGE_FLAG_FOLDER)
    printf("F");
    if (flags & EDGE_FLAG_DELETED)
    printf("D");
    }
  • replacement in change.c at line 534
    [3.935][3.935:962]()
    printf("EdgeMap... \n");
    [3.935]
    [3.962]
    printf("edgemap {\n edges: [\n");
    for (i = 0; i < m->edges.len; i++) {
    struct edge *e = &m->edges.entries[i];
    printf(" edge { previous = %u, flag = ",
    e->previous);
    print_edgeflags(e->flag);
    printf(", from = Position { .. }, to = vertex { .. }, introducedby = "
    );
    hashprint(&e->introducedby);
    printf(" }\n");
    }
    printf(" ]\n}\n");
  • edit in change.c at line 621
    [2.138]
    [3.1789]
    case FILE_ADD: {
    struct fileadd *f = &hunk->fileadd;
    printf(" %s (%s)", f->path, f->encoding);
    printf("\n");
    /* FIXME: f->contents is optional, how should we indicate this? */
    print_atom(&f->contents, contents);
    break;
    }