When looking through all the edges for contents that has been deleted, we may encounter the same vertex referenced by edge->to. This can result in some deleted text being printed multiple times, if we don't take care to deduplicate it.
This change introduces vertexeq() that compares vertices by hash, start and end positions. This is used to keep track of the last vertex we encountered and compare it to the current one we're inspecting.
The new "check2" target in Makefile prints a change that has multiple edits and replacements, and one file addition.
EHVLRMEF6YK5FRIV5V7V6P5RHJPCYKMSW5OVKDXLUEWHEM624FBAC
SADDDVGOIIOYE3PV2YXXD43WEYQZCV6BROSL6VBE2NQB5N4B6Q4QC
5D2IYPL75HEP6JUEILEADSZRRSV72NECT6UQR3PORNDR35I2P5GQC
JVU3TTT5T776LB2UNT5DCISJDWOITRSJPRG3CDTX4NDQEHC5VI3QC
JAGXXSR7DR5FG77VKBF62BW7Q3JMVHCLHF4VB2PSLIZF4RLE553QC
PEUS54XQ5KJQYAVUYBG5MWLEHIOVPMZ3ANVC7HPQP6JUWWPRDW5AC
XJ2PEH74CLJUELZBR47QHGUSKXB4Z5T7EKEF6Y4CYY2VBHZXUTDAC
L3HKOF4WYZZLJJY2Q6YJ65WGAB74GQ2A7ICD23M5NQGBP4BXF6DQC
YG4DZB3AW3Z3LB5CFBZZ4ORJOLZFN3G4CA2YTAMSUOQX3USVNVEAC
Q7TKZCJP2Z75EICZYKCEZDHKGERSOKZGMTSU3UXETBHTF663T66AC
YDQLW2ZOAH7PZ7HHVTSFUO5IWE6O7FDNXVNIN7GG4TJ3P2B2BM4AC
NETL2N53SORFVLRHT2GK6EYIGK64U6E4QTCES6NGQPBYUPIOVEIAC
B3XLVPNC4COLLC3FUE34Y7HIKTMF6CJZUASZOU3YM2YGPZKJZP7QC
#include <stdint.h>
#include <stddef.h>
#include "common.h"
#include "hash.h"
#include "vertex.h"
int
vertexeq(struct vertex *v1, struct vertex *v2)
{
return hasheq(&v1->change, &v2->change) && v1->start == v2->start &&
v1->end == v2->end;
}
// FIXME: need to keep track of current! see
// /home/t/sources/pijul/pijul/libpijul/src/changestore/filesystem.rs (get_contents_ext)
size_t z = edge->to.end - edge->to.start;
/* TODO loop over the edges, extract relevant contents from the changestore */
// keep track of current vertex
if (vto && vertexeq(&edge->to, vto))
continue;
vto = &edge->to;
size_t z = vto->end - vto->start;