import io, pathlib, subprocess, sys, tarfile
fixture = pathlib.Path(sys.argv[1]).resolve()
fixture.mkdir(parents=True, exist_ok=True)
for archive, size in [('mixed.tar', 40 * 1024 * 1024), ('control.tar', 1)]:
    with tarfile.open(fixture / archive, 'w', format=tarfile.USTAR_FORMAT) as tar:
        for name, payload in [('before.txt', b'before'), ('large.txt', b'a' * size), ('empty.txt', b''), ('after.txt', b'after')]:
            header = tarfile.TarInfo(name)
            header.size = len(payload)
            tar.addfile(header, io.BytesIO(payload))
subprocess.run(['git', 'init', '--quiet', str(fixture)], check=True)
subprocess.run(['git', '-C', str(fixture), 'add', 'mixed.tar', 'control.tar'], check=True)
subprocess.run(['git', '-C', str(fixture), '-c', 'user.name=Evidence', '-c', 'user.email=evidence@example.invalid', 'commit', '-qm', 'Synthetic archive fixtures'], check=True)
