Commits


portable: OpenBSD compilation fixes


portable: configure: split out dependencies Rather than assume all dependencies are required for all programs, split them out. This will make packaging easier, as well as splitting the code to use subprojects. Note that due to the use of config.h semantics, in most cases the got_compat.h header file is now at the top of the .c file it is included in, so that it can handle the system header inclusion properly.


add some helper functions to compute hashes This adds a set of functions to abstract over SHA1Init, SHA1Update, SHA1Final, their respective SHA256 variants and how to compare digests. Replace all the SHA1*() usage with the new APIs. It's a preparatory step for sha256 handling. ok stsp@


portable: remove endian.h This is included portably.


portable: rework SHA detection Simply the SHA detection by not predicating on libcrypto, but instead checking individual header files.


portable: remove sha1.h; found portably Remove sha1.h as this is found portably across systems.


rename lib/sha1.c to lib/hash.c It will soon grow functions to deal with sha256 too. stsp@ agrees.


include sha2.h too where sha1.h is included In preparation for wide sha256 support; stsp@ agrees. Change done mechanically with find . -iname \*.[cy] -exec sam {} + X ,x/<sha1\.h>/i/\n#include <sha2.h>


use SHA1_DIGEST_LENGTH instead of sizeof(id) ok stsp


avoid copying reused deltas to delta cache file; copy from pack file instead ok op@


add missing free() of delta buffers in several error paths


change add_delta to take an off_t instead of size_t. add_delta already calls got_delta_open casting the size_t to off_t, and all the add_delta callers pass an off_t anyway; fixes an implicit off_t truncation. ok stsp@


convert got_pack' filesize to off_t; ok stsp@


check size before calling mmap(2) It's only a preparatory step, as checking whether a size_t is less than SIZE_MAX is moot. In a follow-up commit, however, the `filesize' field of the struct got_pack will become off_t and these checks will kick in. This also makes consistent how we guard mmap(2) against empty files. ok and improvements stsp@


add missing `goto done;' on error path; ok stsp@


fix off_t type mismatch off_t is a signed type and depending on the platform, it can be "long" or "long long", so cast to long long for printf().


change got_pack_parse_offset_delta tslen argument to size_t The tslen argument is always in the (1..9) range so `int' is technically fine (even int8_t would be!) but all the callers are passing a size_t, so change the type accordingly. ok stsp@


close parent's end of imsg pipe before waiting for a child process to exit Prevents a dead-lock in 'tog log' where tog wants to exit (e.g. because the user pressed Ctrl-C) while a got-read-pack child process wants to send more commits. Closing the parent's pipe descriptor makes writes to the pipe fail in the child process. The child then unwinds via an ERR_EOF error and exits, instead of forever polling its end of the pipe in order to write more data. ok jamsek


provide a more useful error if the size of a packed object won't fit in 64 bits


do not crash if no delta cache is present while parsing deltas


fix off_t type mismatches off_t is a signed type and depending on the platform, it can be "long" or "long long", so cast to long long for printf(). ok stsp


portable: add back sys/queue.h Now that the handling of including sys/queue.h is better, there's no need to remove those lines from the source. Copy the location of those original sys/queue.h lines from upstream at the same line number, so as to avoid any conflicts in the future.


allow start_pack_privsep_child() to be called from outside lib/object.c


open temporary files needed for delta application in got_repo_open() This prepares for callers of got_repo_open() that cannot afford to open files in /tmp, such as gotwebd. In a follow-up change, we could ask such callers to pass in the required amount of open temporary files. One consequence is that got_repo_open() now requires the "cpath" pledge promise. Add the "cpath" promise to affected callers and remove it once the repository has been opened. ok tracey


avoid get_delta_chain_max_size() in dump_delta_chain_to_mem()