change: support version = 4 (noenc) format
Dependencies
- [2]
XRGUHSC4change: fix some formatting issues - [3]
7NQTS36Dbincode: change signature of getstr to receive str destination - [4]
QSQNGA5Kchangestore: load changes on demand - [5]
JAGXXSR7change: initial work on decoding hunks - [6]
YFBKBUKBchange: rename binstat -> bc - [7]
VXQYIOBXchange: avoid crash on different format versions - [8]
7WA2F6RSchange: decode resurrectzombies, addroot, delroot - [9]
5D2IYPL7change: introduce changestore, print deleted lines - [10]
XTKRT6OQformat the codebase - [11]
2U7P5SFQChange struct names "struct foo -> typedef struct Foo" - [12]
VKLGQREYchange: add base32 decode, initial deconstruction of hashed - [13]
ZKAOPMCHchange: Implement decoding of edits, atoms, positions, among others - [14]
NEORNIZEchange: decode and print file moves - [15]
LPGHALLKchange: adjust printing of file adds - [16]
OBKF6SIIchange: decompress the hashed section too - [17]
TGT4VSMEchange: decode FILE_ADD - [18]
Q7TKZCJPAdd initial support for reading the offsets from a (fixed) change - [19]
2YF4J5SJchange: decode and print file undel - [20]
QYRJIOYPchange: separate decoding and printing of hashed struct - [21]
JVU3TTT5all: switch away from typedefing anonymous structs - [22]
NZNIG2ULFix lots of warnings, adjust build flags - [23]
YG4DZB3Aadd representation of hash, decode dependencies - [24]
FMYCPGKDchange: extract hash list decoding into reused function - [25]
LCEKN25Gchange: parse authors - [26]
O7XAUFM6change: decode and print {,un}solve order conflicts - [*]
RIWSVVASchange: decompress the 'contents' with zstd_seekable - [*]
XTVLIC24change: refactor to print_change()
Change contents
- edit in change.c at line 289
static voidchange_decode_encoding_noenc(struct bincode *bc, char **encoding){(void)bc;*encoding = xstrdup("UTF-8");} - edit in change.c at line 304
void (*fn_change_decode_encoding)(struct bincode *, char **);fn_change_decode_encoding = &change_decode_encoding;if (hashed->version == VERSION_NOENC)fn_change_decode_encoding = change_decode_encoding_noenc; - replacement in change.c at line 324
change_decode_encoding(bc, &bhunk->edit.encoding);fn_change_decode_encoding(bc, &bhunk->edit.encoding); - replacement in change.c at line 330
change_decode_encoding(bc, &bhunk->replacement.encoding);fn_change_decode_encoding(bc, &bhunk->replacement.encoding); - replacement in change.c at line 342
change_decode_encoding(bc, &bhunk->fileadd.encoding);fn_change_decode_encoding(bc, &bhunk->fileadd.encoding); - replacement in change.c at line 359
change_decode_encoding(bc, &bhunk->filedel.encoding);fn_change_decode_encoding(bc, &bhunk->filedel.encoding); - replacement in change.c at line 370
change_decode_encoding(bc, &bhunk->fileundel.encoding);fn_change_decode_encoding(bc, &bhunk->fileundel.encoding); - replacement in change.c at line 407
change_decode_encoding(fn_change_decode_encoding( - edit in change.c at line 423
}}voidchange_decode_author(struct bincode *bc, struct author *author){size_t len, i;len = bincode_getu64(bc);author->len = len;author->entries = xmalloc(sizeof(struct authorentry) * len);for (i = 0; i < author->len; i++) {len = bincode_getu64(bc);author->entries[i].key = xmalloc(len + 1);bincode_getstr(bc, author->entries[i].key, len);len = bincode_getu64(bc);author->entries[i].value = xmalloc(len + 1);bincode_getstr(bc, author->entries[i].value, len);}}voidchange_decode_author_noenc(struct bincode *bc, struct author *author){size_t len, i;char *name, *full_name, *email;i = 1;full_name = email = NULL;len = bincode_getu64(bc);name = xmalloc(len + 1);bincode_getstr(bc, name, len);if (bincode_getu8(bc)) {i++;len = bincode_getu64(bc);full_name = xmalloc(len + 1);bincode_getstr(bc, full_name, len);}if (bincode_getu8(bc)) {i++;len = bincode_getu64(bc);email = xmalloc(len + 1);bincode_getstr(bc, email, len);}author->len = i;author->entries = xmalloc(sizeof(struct authorentry) * i);i = 0;author->entries[i].key = xstrdup("name");author->entries[i].value = name;if (full_name) {i++;author->entries[i].key = xstrdup("full_name");author->entries[i].value = full_name; - edit in change.c at line 486
if (email) {i++;author->entries[i].key = xstrdup("email");author->entries[i].value = email;} - edit in change.c at line 508
void (*fn_change_decode_author)(struct bincode *, struct author *); - replacement in change.c at line 566[4.514]→[4.427:479](∅→∅),[4.479]→[4.490:502](∅→∅),[4.502]→[4.5718:5747](∅→∅),[4.5747]→[4.480:522](∅→∅),[4.634]→[4.480:522](∅→∅),[4.522]→[4.3897:3938](∅→∅),[4.3169]→[4.523:626](∅→∅),[4.3938]→[4.523:626](∅→∅),[4.1331]→[4.523:626](∅→∅),[4.626]→[4.43:176](∅→∅)
for (i = 0; i < hashed->header.authors.len; i++) {size_t j;len = bincode_getu64(&bc);hashed->header.authors.map[i].entries =xmalloc(sizeof(struct author) * len);hashed->header.authors.map[i].len = len;for (j = 0; j < hashed->header.authors.map[i].len; j++) {// In VERSION_NOENC, the authors are a struct { name: str, full_name: maybe str, email: maybe str } instead of a more generic mapfn_change_decode_author = change_decode_author;if (hashed->version == VERSION_NOENC)fn_change_decode_author = change_decode_author_noenc; - replacement in change.c at line 570[4.177]→[4.177:265](∅→∅),[4.265]→[4.5748:5778](∅→∅),[4.5778]→[4.627:677](∅→∅),[4.849]→[4.627:677](∅→∅),[4.677]→[3.1075:1189](∅→∅),[3.1189]→[4.5809:5839](∅→∅),[4.5809]→[4.5809:5839](∅→∅),[4.5839]→[4.678:730](∅→∅),[4.964]→[4.678:730](∅→∅),[4.730]→[3.1190:1306](∅→∅),[3.1306]→[4.1172:1176](∅→∅),[4.1617]→[4.1172:1176](∅→∅),[4.5870]→[4.1172:1176](∅→∅),[4.1172]→[4.1172:1176](∅→∅)
// TODO switch on offsets.version to figure// out how to decode the authors herelen = bincode_getu64(&bc);hashed->header.authors.map[i].entries[j].key =xmalloc(len + 1);bincode_getstr(&bc,hashed->header.authors.map[i].entries[j].key,len);len = bincode_getu64(&bc);hashed->header.authors.map[i].entries[j].value =xmalloc(len + 1);bincode_getstr(&bc,hashed->header.authors.map[i].entries[j].value,len);}for (i = 0; i < hashed->header.authors.len; i++) {fn_change_decode_author(&bc, &hashed->header.authors.map[i]); - edit in change.c at line 807
- edit in change.c at line 815[4.979][29.253]
/*** In the VERSION_NOENC file metadata (for file additions), the* filemetadata contains *only* the inodemetadata directly followed by* the basename. The basename is not bincode-encoded, so we assume the* length of the string is the given content length minus 2 (for the* first two bytes used by the inodemetadata).*/static voidread_filemetadata_noenc(struct filemetadata *m, uint8_t *contents, size_t contents_len){size_t len;struct bincode bc = { .avail = contents_len, .buf = contents };m->inodemetadata = bincode_getu16(&bc);len = contents_len - 2;m->basename = xmalloc(len + 1);memcpy(m->basename, &contents[2], len);m->basename[len] = '\0';} - edit in change.c at line 844[4.605][29.316]
void (*fn_read_filemetadata)(struct filemetadata *, uint8_t *, size_t); - edit in change.c at line 846[29.317][29.317]
fn_read_filemetadata = read_filemetadata;if (hashed->version == VERSION_NOENC)fn_read_filemetadata = read_filemetadata_noenc; - replacement in change.c at line 917
read_filemetadata(fn_read_filemetadata( - replacement in change.c at line 944
read_filemetadata(fn_read_filemetadata( - replacement in change.c at line 1074[4.1874]→[4.7277:7348](∅→∅),[4.7348]→[4.335:421](∅→∅),[4.335]→[4.335:421](∅→∅),[4.421]→[4.7349:7374](∅→∅),[4.7374]→[4.445:512](∅→∅),[4.445]→[4.445:512](∅→∅),[4.512]→[4.7375:7400](∅→∅),[4.7400]→[4.536:540](∅→∅),[4.536]→[4.536:540](∅→∅)
if (off->version != VERSION) {if (off->version == VERSION_NOENC) {printf("The NOENC version (%lu) is not yet supported, sorry (but it's planned)\n",off->version);} else {printf("Version %lu is not yet supported, sorry.\n",off->version);}if (off->version != VERSION && off->version != VERSION_NOENC) {printf("Version %lu is not yet supported, sorry.\n",off->version);err = off->version; - replacement in change.c at line 1232
size_t i, x;size_t x;