NEORNIZEGPZAVZV2J6TTCWPZAQM3N7MH7SMS3NDT4WKTXI34NSUAC
JVU3TTT5T776LB2UNT5DCISJDWOITRSJPRG3CDTX4NDQEHC5VI3QC
TGT4VSMEWWTFYILTXVZWA5WHB2RCZZYNGZJ3UUKZ5OPD6JQD4G5QC
JAGXXSR7DR5FG77VKBF62BW7Q3JMVHCLHF4VB2PSLIZF4RLE553QC
FMYCPGKDAPOUFLQOCXXKZ6TR75HT3TNCG4X3GAJDM4ARWKNWOSWAC
Q7TKZCJP2Z75EICZYKCEZDHKGERSOKZGMTSU3UXETBHTF663T66AC
XTVLIC243WZF52NVTNRA3SV3WLE2ZZ5GTFQOK45IOLMXYQMTLOSAC
/**
* decode a filemetadata struct from the given contents - the input
* (contents) are also bincoded, so we need to deserialize it
*/
static void
read_filemetadata(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 = bincode_getu64(&bc);
m->basename = bincode_getstr(&bc, len);
if (bincode_getu8(&bc)) {
len = bincode_getu64(&bc);
m->encoding = bincode_getstr(&bc, len);
}
}
case FILE_MOVE: {
/* read filemetadata from contents */
struct filemove *f = &hunk->filemove;
struct filemetadata metadata = { 0 };
uint64_t start, end;
start = f->add.newvertex.start;
end = f->add.newvertex.end;
read_filemetadata(
&metadata, &contents[start], end - start
);
printf(" %s -> %s\n", f->path, metadata.basename);
free(metadata.basename);
if (metadata.encoding)
free(metadata.encoding);
break;
}