portable: OpenBSD compilation fixes (ta/configh)
* Move the main incldue/got_compat.h to the top of the files they're included in. * Define SHA256Init and friends to the system equivalents.
When checking for ncurses, don't clobber previous checks for libpanel.
Remove useless headers which don't need to be included any longer.
When looking for base64 functions, check -lresolv and/or -lnetwork, and only build those in compat if required. Some of the detection code was modified from tmux's configure.ac script.
Some code in compat/ has #defines which were not being checked for in configure.ac, which could have lead to compilation failures were those files to be included on systems which needed them. In doing so, we can now remove libmd and libcrypto as these are no longer needed.
Don't use a custom variable when the header checks for these are already available. From Christian "naddy" Weisgerber.
Because musl is less forgiving about header-ordering, explicitly include this before stdio.h -- this won't affect existing files as the include guards elsewhere prevent this.
When building tests, compat needs to be built. Do this prior to running any tests. This ensures tests can be run from a clean tree. Furthermore, add got_compat.h to all test headers. This wasn't necessary before as this was implicitly being included, but now isn't.
Set LIBS to the empty string so that only the specific dependencies are included where needed, rather than relying on autotools to do this for us. This will make splitting out got into different subprojects easier, as well as allow for multi-packing on those systems which support it.
Extend the include guard to the whole file.
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.
Ignore warnings about pointer-signedness. This may well get fixed upstream, but won't hurt to be left here, regardless.
So that the command-line flags to CC don't get drowned out with copious -D flags, move this detection to config.h instead. Note that to reduce the code churn, the existing include/got_compat.h header file has been renamed, and the generated file replaces it, but with the contents of the original header file included. Eventually, we might want to move some od the logic in include/got_compat2.h into AH_VERBATIM() blocks, but for now, this is a good compromise.
The reuse-pack is pinned but may change its cache slot while objects are being deltified. Refresh the pointer to the pinned reuse-pack before writing out the pack file, ensuring that reused deltas will in fact be read from the reuse-pack and not some other pack. Otherwise gotd may send a broken pack file, or hit an ERR_RANGE condition if the pack file which now occupies the pinned-pack's old cache slot is shorter. Which can trigger attempts to read beyond end-of-file which show up in the logs like this: gotd: repo_read /var/git/got.git: sending packfile: value out of range gotd: uid 1002: value out of range gotd: uid 1002: disconnecting
If a file is deleted, then in modified form added again, folding should restore the file with its new contents. ok stsp
The definition for GOT_TEST_PACK went walkies during a previous merge conflict. Add this back.
Now that the use of sed(1) in tests has been replaced with ed(1), the sed wrapper can be retired. There are existing tests which use sed, but they're modifying a stream, rather than using -i, so there's no portability concerns.
"sed -i" is fundamentally unportable. GNU and OpenBSD sed(1) treat the extension for the backup file as an optional argument and use "sed -i" for no backup file. FreeBSD sed(1) treats the extension as an obligatory argument and uses "sed -i ''" for no backup file. There is no single syntax that works for both. ok stsp op
common.sh sets LC_ALL=C which makes this change unnecessary now. Patch from Christian "naddy" Weisgerber.
Drop the forcing of "command" when calling sed(1).