change: separate decoding and printing of hashed struct

laumann
Sep 26, 2022, 9:54 AM
QYRJIOYPM7SAB3OHMALL67K44U5HPBRQ2AFNWUKATPXM6BUYRKBQC

Dependencies

  • [2] FMYCPGKD change: extract hash list decoding into reused function
  • [3] IS5A7VT6 change: print hashes
  • [4] XTKRT6OQ format the codebase
  • [5] YG4DZB3A add representation of hash, decode dependencies
  • [6] OBKF6SII change: decompress the hashed section too
  • [7] LCEKN25G change: parse authors
  • [8] WMFNGOYT change: reduce printed noise, rework some code
  • [9] VXGUQZIV bincode: rework so functions advance pointer
  • [10] 3FT3XTJM change: support -v/-h flags
  • [11] LVX6U4EK change: decode metadata bytes
  • [12] Q7TKZCJP Add initial support for reading the offsets from a (fixed) change
  • [13] VKLGQREY change: add base32 decode, initial deconstruction of hashed
  • [14] Y26WT3ZF change: decode message, description and timestamp
  • [15] 4RYULBDD bincode: introduce a bincode_state struct
  • [16] KDJUAAAL change: prefix function names with change_
  • [17] RIWSVVAS change: decompress the 'contents' with zstd_seekable

Change contents

  • replacement in change.c at line 191
    [4.1059][4.1059:1083]()
    uint8_t *expected_hash
    [4.1059]
    [4.1083]
    uint8_t *expected_hash, struct hashed *hashed
  • edit in change.c at line 195
    [4.632][4.872:895](),[4.1172][4.872:895]()
    struct hashed hashed;
  • replacement in change.c at line 230
    [4.81][4.81:119]()
    dump_buf("hashed", buf, hashed_len);
    [4.81]
    [4.696]
    /* dump_buf("hashed", buf, hashed_len); */
  • replacement in change.c at line 232
    [4.697][4.120:164](),[4.60][4.734:778](),[4.164][4.734:778](),[4.734][4.734:778]()
    hashed.version = bincode_getu64(&binstat);
    printf("version = %lu\n", hashed.version);
    [4.697]
    [4.802]
    hashed->version = bincode_getu64(&binstat);
  • edit in change.c at line 235
    [4.198]
    [4.853]
    hashed->header.message = bincode_getstr(&binstat, len);
  • edit in change.c at line 237
    [4.854][4.199:255](),[4.139][4.914:967](),[4.255][4.914:967](),[4.914][4.914:967]()
    hashed.header.message = bincode_getstr(&binstat, len);
    printf("message = '%s'\n", hashed.header.message);
  • replacement in change.c at line 244
    [4.322][4.322:383](),[4.223][4.1262:1367](),[4.383][4.1262:1367](),[4.1262][4.1262:1367]()
    hashed.header.description = bincode_getstr(&binstat, len);
    printf("description = '%s'\n", hashed.header.description);
    } else
    printf("description = (none)\n");
    [4.322]
    [4.1367]
    hashed->header.description = bincode_getstr(&binstat, len);
    }
  • replacement in change.c at line 252
    [4.1248][4.418:476](),[4.1520][4.418:476](),[4.304][4.1583:1639](),[4.476][4.1583:1639](),[4.1583][4.1583:1639]()
    hashed.header.timestamp = bincode_getstr(&binstat, len);
    printf("timestamp = '%s'\n", hashed.header.timestamp);
    [4.1248]
    [4.354]
    hashed->header.timestamp = bincode_getstr(&binstat, len);
  • replacement in change.c at line 255
    [4.412][4.412:513]()
    hashed.header.authors.len = len;
    hashed.header.authors.map = xmalloc(sizeof(struct author) * len);
    [4.412]
    [4.513]
    hashed->header.authors.len = len;
    hashed->header.authors.map = xmalloc(sizeof(struct author) * len);
  • replacement in change.c at line 258
    [4.514][4.514:591]()
    printf("[[authors]]\n");
    for (i = 0; i < hashed.header.authors.len; i++) {
    [4.514]
    [4.591]
    for (i = 0; i < hashed->header.authors.len; i++) {
  • replacement in change.c at line 261
    [4.634][4.1249:1290]()
    hashed.header.authors.map[i].entries =
    [4.634]
    [4.1290]
    hashed->header.authors.map[i].entries =
  • replacement in change.c at line 263
    [4.1331][4.713:814](),[4.713][4.713:814]()
    hashed.header.authors.map[i].len = len;
    for (j = 0; j < hashed.header.authors.map[i].len; j++) {
    [4.1331]
    [4.814]
    hashed->header.authors.map[i].len = len;
    for (j = 0; j < hashed->header.authors.map[i].len; j++) {
  • replacement in change.c at line 266
    [4.849][4.1332:1381]()
    hashed.header.authors.map[i].entries[j].key =
    [4.849]
    [4.1381]
    hashed->header.authors.map[i].entries[j].key =
  • replacement in change.c at line 269
    [4.964][4.1417:1468]()
    hashed.header.authors.map[i].entries[j].value =
    [4.964]
    [4.1468]
    hashed->header.authors.map[i].entries[j].value =
  • edit in change.c at line 271
    [4.1503][4.1046:1071](),[4.1046][4.1046:1071](),[4.1071][4.1504:1617]()
    printf("%s = '%s'\n",
    hashed.header.authors.map[i].entries[j].key,
    hashed.header.authors.map[i].entries[j].value);
  • edit in change.c at line 274
    [4.842][2.627:656]()
    printf("# Dependencies\n");
  • replacement in change.c at line 275
    [4.881][2.657:714]()
    change_decode_hashlist(&binstat, &hashed.dependencies);
    [4.881]
    [4.1176]
    change_decode_hashlist(&binstat, &hashed->dependencies);
  • replacement in change.c at line 278
    [4.1575][2.715:771](),[2.771][4.0:1](),[4.2219][4.0:1](),[4.1][3.0:226]()
    change_decode_hashlist(&binstat, &hashed.extra_known);
    for (i = 0; i < hashed.dependencies.len; i++) {
    printf(" ");
    hash_print(&hashed.dependencies.entries[i]);
    }
    for (i = 0; i < hashed.extra_known.len; i++) {
    printf("+");
    hash_print(&hashed.extra_known.entries[i]);
    }
    [4.1575]
    [3.226]
    change_decode_hashlist(&binstat, &hashed->extra_known);
  • replacement in change.c at line 288
    [4.183][3.228:280]()
    /* dump_buf("buf", binstat.buf, binstat.avail); */
    [4.183]
    [4.229]
    dump_buf("buf", binstat.buf, binstat.avail);
  • edit in change.c at line 328
    [4.2126]
    [4.2254]
    struct hashed hashed;
  • replacement in change.c at line 353
    [4.2211][4.2211:2227]()
    contents_hash
    [4.2211]
    [4.2227]
    contents_hash, &hashed
  • edit in change.c at line 358
    [4.2584]
    [4.2584]
    }
    printf("--------------------------------------------------------------------------------\n"
    );
    printf("version = %lu\n", off.version);
    printf("hashed_len = %lu\n", off.hashed_len);
    printf("unhashed_off = %lu\n", off.unhashed_off);
    printf("unhashed_len = %lu\n", off.unhashed_len);
    printf("contents_off = %lu\n", off.contents_off);
    printf("contents_len = %lu\n", off.contents_len);
    printf("total = %lu\n", off.total);
    printf("--------------------------------------------------------------------------------\n"
    );
    printf("message = %s\n", hashed.header.message);
    if (hashed.header.description)
    printf("description = '%s'\n", hashed.header.description);
    printf("timestamp = '%s'\n\n", hashed.header.timestamp);
    printf("[[authors]]\n");
    for (i = 0; i < hashed.header.authors.len; i++) {
    int j;
    for (j = 0; j < hashed.header.authors.map[i].len; j++) {
    printf("%s = '%s'\n",
    hashed.header.authors.map[i].entries[j].key,
    hashed.header.authors.map[i].entries[j].value);
    }
  • edit in change.c at line 386
    [4.2587]
    [4.2621]
    printf("\n");
  • edit in change.c at line 388
    [4.2622]
    [4.2622]
    printf("# Dependencies\n");
    for (i = 0; i < hashed.dependencies.len; i++) {
    printf(" ");
    hash_print(&hashed.dependencies.entries[i]);
    }
    for (i = 0; i < hashed.extra_known.len; i++) {
    printf("+");
    hash_print(&hashed.extra_known.entries[i]);
    }
    printf("\n");
  • edit in change.c at line 412
    [4.256][4.2907:2908](),[4.2907][4.2907:2908](),[4.2908][4.2587:2966](),[4.2587][4.2587:2966]()
    printf("version : %lu\n", off.version);
    printf("hashed_len : %lu\n", off.hashed_len);
    printf("unhashed_off : %lu\n", off.unhashed_off);
    printf("unhashed_len : %lu\n", off.unhashed_len);
    printf("contents_off : %lu\n", off.contents_off);
    printf("contents_len : %lu\n", off.contents_len);
    printf("total : %lu\n", off.total);