lib


Log

Author Commit Date CI Message
Stefan Sperling f9d37699 2022-06-28T20:33:41 move got_opentempfd() out of lib/diff.c again ok tracey
Tracey Emery 1b484788 2022-06-28T18:34:57 move got_opentempfd out of blame_open ok stsp@ jrick@
Stefan Sperling 7a13e6e5 2022-06-28T18:19:03 pass the correct file to fdopen(); ok tracey
Tracey Emery ce7556f2 2022-06-28T18:04:05 fix missed dup in open_blob per stsp@
Tracey Emery eb81bc23 2022-06-28T13:27:12 move got_opentempfd out of open_blob. ok stsp@
Stefan Sperling 61af9b21 2022-06-28T11:31:11 implement support for commit coloring in got-read-pack for speed ok op, tracey
Omar Polo db0dfdd7 2022-06-27T18:47:02 got patch: handle git-style diffs for the 3-way merge too tweak and ok stsp@
Omar Polo 497a5915 2022-06-27T18:47:02 handle blob ids without corresponding blob ids ok stsp@
Omar Polo 58e31a80 2022-06-27T18:47:02 build with -Wwrite-strings Throwing this into the mix for a while, we can always get rid of it again if it becomes annoying. No objections from stsp@
Stefan Sperling 3d589bee 2022-06-25T14:54:41 allow start_pack_privsep_child() to be called from outside lib/object.c
Stefan Sperling 8469d821 2022-06-25T09:25:07 always show commit or tree IDs in diff header, in order to help 'got patch' The idea is that got patch can simply look for a line such as: commit - abcde1234567... to find the merge base commit ID to show in diff3 conflict markers. got log -p now displays commit IDs in its diff header, instead ofl tree or blob IDs. ok op@
Omar Polo 336075a4 2022-06-25T09:22:02 build with -Wmissing-prototypes ok stsp@
Omar Polo 9802c41c 2022-06-21T16:52:34 got patch: use status G for merged files (and document it) Suggested by stsp@. This makes possible to tell if 'got patch' used a merge-base from the repository for the 3-way merge or did a simple search/replace operation. While here update the tests to look for the 'G' status and the manpage, which was also missing the documentation for the 'C' status in got patch. ok stsp@
Omar Polo dbc68eed 2022-06-21T16:52:34 got patch: ignore blobs not found since diffs are often enclosed in other formats (e.g. emails) we might parse something and think it's a blob id when it's not. This should already happens, but apply_patch is looking for the wrong error due to a leftover from previous attempts. Reported by stsp@ while here tweak the test_patch_merge_unknown_blob to also try with a dummy commit id, as now got-read-patch requires it in order to consider a blob id. ok stsp@
Omar Polo d8b5af43 2022-06-19T11:51:33 use the commitid in the patch diff3 conflict header suggested by and ok stsp@
Omar Polo 55e9459f 2022-06-19T11:51:32 got patch: use diff3 to merge the changes Parse the "blob -" metadata in diffs produced by 'got diff' and use the original file for patching. Then, use the diff3 with the current version of the file to merge the differences. This solves many failures automagically or at least turns them into a conflict. ok/improvements stsp@
Omar Polo 05737d49 2022-06-19T11:51:32 patch_file: fill tmp with the patched file even in nop mode future work with diff3 merge will need the fully patched file even in the nop mode ok stsp@
Omar Polo 827bcd6c 2022-06-19T11:51:32 patch_file: move file ownership to parent ok stsp@
Stefan Sperling 80f51a9e 2022-06-18T16:32:12 fix unexpected imsg error after incomplete enumeration in got-read-pack reported by jrick and op@ ok op@
Omar Polo 031611fc 2022-06-18T16:17:45 memset all stack-allocated structs used to send messages; ok stsp@
Omar Polo 1a69d37f 2022-06-18T16:17:45 zero the whole struct got_imsg_object before sending it otherwise some fields may be unitialized and fail the validation done on the receiving side. ok stsp@
Tracey Emery 20282b02 2022-06-16T14:45:29 fix build with -DGOT_NO_OBJ_CACHE ok stsp
Omar Polo 1b1b91ab 2022-06-15T21:21:27 style: remove double semicolon
Stefan Sperling 5a950d09 2022-06-15T14:27:20 using a local packfd variable in open_worktree() is sufficient
Stefan Sperling d188eb19 2022-06-15T14:26:34 remove pointless assignment at the end of got_repo_pack_fds_close()
Stefan Sperling bb711527 2022-06-15T14:25:37 don't look for close() errors if opentemp() failed in got_repo_pack_fds_open()
Tracey Emery 0ae84acc 2022-06-15T13:52:20 move got_opentempfd out of got_repo_open. ok stsp@ thanks for all the help massaging this diff
Stefan Sperling 06c44edc 2022-06-15T13:10:50 check for errors from fclose() in patch_file()
Omar Polo 11ce22a1 2022-06-15T12:50:10 plug memory and fd leak in got patch
Stefan Sperling afd31498 2022-06-14T22:35:34 fix a harmless off-by-one from previous commit
Stefan Sperling a5e587e0 2022-06-14T22:32:11 fix a bug in got_privsep_send_object_idlist() exposed by recent changes The old code did not work correctly if only a single object Id was to be sent to got-read-pack. Make got-read-pack error out if the list of commits for object enumeration is empty to catch this problem if it occurs again. Found by the send_basic test, which was failing with GOT_TEST_PACK=1 ok tracey
Stefan Sperling db9b9b1c 2022-06-14T20:26:15 let got-read-pack be explicit about whether it could enumerate all objects This allows the main process to avoid looping over all object IDs again in case the pack file used for enumeration is complete. ok op@
Omar Polo b4b1b9c0 2022-06-14T13:16:15 remove trailing whitespaces
Omar Polo 0fca100c 2022-06-14T13:16:15 compute object size, not pointer size in this case they're luckily the same; got_imsg_object_idlist and got_imsg_reused_delta only have one size_t long field. ok stsp@
Omar Polo c98b0f0b 2022-06-14T13:16:15 strictier validation for data received from libexec helpers use correct error code and ok stsp@
Omar Polo 3e6054c4 2022-06-14T13:16:14 drop unused variable
Omar Polo bf31a716 2022-06-14T13:16:14 use strndup instead of malloc+memcpy Simplifies the reading of the author/committer string and makes also the code shorter. ok stsp@
Omar Polo 71fee5a3 2022-06-14T13:16:14 don't check datalen when calling recv_imsg_error recv_imsg_error already checks the size of the message, and it does so more precisely than the removed code. ok stsp@
Omar Polo 35095610 2022-06-14T10:35:07 got patch: use ints for line offsets instead of longs ints have the advantage that their size is more likely to be the same across the various architecture supported by OpenBSD, thus introducing less possible differences. INT_MAX is still (at least) a few order of magnitudes higher than the patches we dealt with (even abnormal ones.) suggested by stsp@
Omar Polo 5b7126c5 2022-06-14T08:31:16 actually guarding against negative line offsets previous commit looked at some pretty zeroes returned from calloc instead of the actual numbers received.
Omar Polo 2399b53d 2022-06-14T08:26:27 style; set datalen only once
Omar Polo 71393b5c 2022-06-14T08:10:55 got patch: guard against invalid (negative) line offsets under normal circumstances got-read-patch can't send negative line offsets; that's not an excuse not to guard the main process from those as well. This makes sure we bail out early instead of trying to apply the diff.
Omar Polo 0e07a2a1 2022-06-13T20:57:43 free patch on error
Omar Polo 99b94ad7 2022-06-13T20:30:09 got patch: ensure new and old paths are NUL-terminated
Stefan Sperling eb7b30a1 2022-06-13T17:13:59 fix error handling in find_pack_for_enumeration(); pointed out by op@
Stefan Sperling 0ab4c957 2022-06-13T17:13:59 Bring back object enumeration inside got-read-pack as a fast path. The problem that was found in the earlier version has been fixed. ok op@
Stefan Sperling a558dd1b 2022-06-08T10:56:53 reuse a temporary file across commits during got log -p -S suggested by + ok op@
Stefan Sperling e44d9391 2022-06-07T19:20:01 revert object enumeration in got-read-pack for now; needs more work This implementation marked commits and trees as enumerated before all trees which they depend on were enumerated. This behaviour leads to incomplete pack files when a tree is only partially packed and got-read-pack hits a missing tree entry as a result. The algorithm must be reworked such that packed leave nodes are marked enumerated first, then bubble-up. Found by op@
Stefan Sperling 9f4f302a 2022-06-07T16:04:15 free id and path in load_packed_tree_ids() on error, else they would leak pointed out by op@
Stefan Sperling f0972833 2022-06-07T16:00:56 fix wrong line wrap; pointed out by op@
Stefan Sperling 876f8c1a 2022-06-07T15:59:48 imsg_add() already frees wbuf on error; pointed out by op@
Stefan Sperling cee6a7ea 2022-06-07T15:56:46 implement object enumeration support in got-read-pack ok op@
Omar Polo 9fdde394 2022-06-04T14:13:46 got stage: implicitly unstage when staging the reverse of the staged diff otherwise we end up with a staged empty edit for that file. ok stsp@
Stefan Sperling 4264b841 2022-06-04T14:02:21 check the maximum cached delta size against the correct constant
Stefan Sperling dac5c75e 2022-06-04T13:58:48 convert delta cache to a hash table This approach uses more memory but is much faster. To offset the additional memory usage somewhat the cache now stores very small deltas only. However, overall memory usage goes up. Hopefully we will find a way to reduce this later. ok op@
Stefan Sperling 6a881297 2022-06-02T12:32:00 properly swap cached struct pack array elements in got_repo_cache_pack() Avoids clobbering open files for delta base/accumulation, leaking file descriptors, and triggering errors from close(2) during got_repo_close() as we try to close the same file descriptor more than once.
Stefan Sperling b72706c3 2022-06-01T05:08:20 move creation of tempfiles outside of lib/diff.c ok tracey
Stefan Sperling cfcf1cbc 2022-05-31T18:49:16 reduce GOT_PACK_CACHE_SIZE to 32, otherwise it uses too many open files found by tracey
Stefan Sperling 13242195 2022-05-31T18:34:45 ensure that all open basefd/accumfd get closed in got_repo_close() found by tracey
Stefan Sperling 57160834 2022-05-31T11:00:09 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
Stefan Sperling f18c433a 2022-05-31T08:44:55 avoid get_delta_chain_max_size() in dump_delta_chain_to_mem()
Stefan Sperling 6395114c 2022-05-31T08:44:55 avoid get_delta_chain_max_size() in dump_delta_chain_to_file()
Stefan Sperling ce2bf7b7 2022-05-29T17:51:33 fix a bug in findwixt() which caused pack files with missing parent commits The 'nskip' variable is supposed to reflect commits which are waiting on the queue and have the 'skip' color. Only increment 'nskip' when adding such commits to the queue. Problem observed with got send -T and a tag pointing to a deleted branch. Test to reproduce the bug written by op@.
Omar Polo d6a28ffe 2022-05-20T21:21:42 use random seeds for murmurhash2 change the three hardcoded seeds to fresh ones generated on demand via arc4random. Suggested/fixed by and ok stsp@
Omar Polo 17cfdba6 2022-05-20T21:19:30 include header
Stefan Sperling 411cbec1 2022-05-20T09:31:25 shrink struct got_pack_meta a bit by removing the have_reused_delta flag This flag can be expressed as m->reused_delta_offset != 0 because all deltas in valid pack files will be written at a non-zero offset. We allocate a huge number of these structs during packing, so every little bit helps.
Stefan Sperling adb4bbb2 2022-05-20T08:40:46 reduce the amount of memory used for caching deltas during deltification With files sorted properly for deltification we produce better deltas but end up consuming more memory and risk running into OpenBSD ulimits during packing. To compensate, reduce the threshold for the amount of delta data we store in memory, spooling more deltas into the cache file. ok op@
Stefan Sperling f8174ca5 2022-05-20T08:40:46 store a path hash instead of a verbatim path in pack meta data This reduces memory use by gotadmin pack. The goal is to sort files which share a path next to each other for deltification. A hash of the path is good enough for this purpose and consumes less memory than a verbatim copy of the path. Git does something similar. ok op@
Stefan Sperling 3e6ceea0 2022-05-20T08:40:46 fix paths stored in pack meta data, improving file deltification The old code was broken and stored an empty path or filenames, instead of a repository-relative path. Which means we didn't sort files for deltification as was intended. Fixing this provides much better deltas in large pack files written by gotadmin pack -a. In my test case, pack size changed from 2GB to 1.5GB. ok op@
Stefan Sperling 17259bfa 2022-05-19T09:26:13 plug a small memleak on error in got_pack_create()
Stefan Sperling e1f5d7cf 2022-05-19T07:36:33 avoid malloc/free for duplicate check in got_pathlists_insert() ok op@
Stefan Sperling c9b75c7b 2022-05-19T07:31:57 revert "Skip poll(2) if an imsgbuf has a non-empty read buffer" imsg_read() will call recvmsg() on the file descriptor regardless of the read buffer's state, so we should ensure that data is ready. The read buffer is used by imsg_get(), not imsg_read(). We already call imsg_get() before imsg_read(), and call the latter only if imsg_get() returns zero.
Stefan Sperling 2ab71455 2022-05-19T07:18:46 Skip poll(2) if an imsgbuf has a non-empty read buffer.
Stefan Sperling 1453347d 2022-05-19T07:14:21 imsg_add() frees its msg argument on error; avoid double-free in error paths
Stefan Sperling 33fd69c2 2022-05-19T06:50:59 batch up tree entries in imsg instead of sending one imsg per tree entry This speeds up loading of trees significantly. ok op@
Stefan Sperling 9985f404 2022-05-19T06:40:09 parse tree entries into an array instead of a pathlist Avoids some extra malloc/free in a performance-critical path. ok op@
Stefan Sperling 3483a4da 2022-05-18T07:45:08 prevent an out-of-bounds access in got_privsep_recv_tree()
Stefan Sperling baef4d75 2022-05-18T07:44:49 plug memory leak in an error path of got_privsep_recv_tree()
Stefan Sperling 13fcf1bf 2022-05-18T07:44:30 make got_privsep_recv_tree() reject trees with less than zero entries
Stefan Sperling 7429ae85 2022-05-18T07:43:45 rework logic in got_privsep_recv_tree() to avoid an ugly 'goto' no functional change
Omar Polo 4bcdc895 2022-05-17T17:35:17 refactor got_patch / got_worktree_patch_complete let got_patch own fileindex_path and call got_worktree_patch_complete only if got_wokrtree_patch_prepare hasn't failed. suggested by stsp@
Omar Polo f2dd7807 2022-05-17T13:28:02 got patch: avoid open/sync/close the fileindex over and over again Instead of flushing the fileindex after every patch in the patchfile just reuse the same fileindex and sync it only at the end of the patch operation. This speeds up 'got patch' on large repositories by quite a lot.
Christian Weisgerber e45f7eba 2022-05-14T18:55:37 got patch: switch from fseek() to fseeko(), use unary minus while here ok op
Omar Polo be33dff7 2022-05-13T15:28:04 got patch: fail when reading empty hunks
Stefan Sperling e93fb944 2022-05-10T11:34:16 map delta cache file into memory if possible while writing a pack file with a fix from + ok op@
Stefan Sperling dc3fe1bf 2022-05-10T11:24:12 fix load_object_ids() such that packing tags works if zero commits are packed reported by jrick and op
Stefan Sperling fae7e038 2022-05-07T11:50:56 run the search for deltas to reuse in got-read-pack This significantly speeds up the deltification step of packing by avoiding imsg traffic. gotadmin no longer requests individual raw deltas from got-read-pack to check whether it can reuse them. Instead, got-read-pack obtains a list of objects we want to pack, and hands back the list of all deltas in its pack file which can be reused. Messages are now batched such that imsg buffers are filled as much as possible. Another advantage is that deltas we are not going to reuse will no longer be written to the delta cache file, saving disk space. Before this patch, any raw delta candidate was written to the delta cache file by got-read-pack, and the decision whether to reuse the delta happened afterwards in the gotadmin process. Code for reading individual raw deltas is now unused and could be removed at some point. ok op@
Stefan Sperling 2f8438b0 2022-05-04T15:39:15 avoid 'remove unused' loop by storing excluded objects in a separate set ok op@
Stefan Sperling f5e78e05 2022-05-04T15:39:15 avoid loop over the ID set which removes objects IDs with reused deltas ok op@
Stefan Sperling 2d9e6abf 2022-05-04T13:43:24 store deltas in compressed form while packing, both in memory and cache file This reduces memory and disk space consumption during packing. with tweaks + memleak on error fix from op@ ok op@
Stefan Sperling 611e8e31 2022-05-01T11:47:21 avoid subtraction of values larger than int in qsort(3) comparison callbacks tweak + ok tb@
Omar Polo bad961bf 2022-04-23T10:39:47 got patch: allow to reverse a patch add a flag to got_patch to reverse a patch before applying and the -R flag for `got patch'. ok stsp@
Omar Polo b2832778 2022-04-23T10:39:47 got-read-patch: preserve all \ lines as a cheap optimization got-read-patch was sending only the "\ No newline at end of file" lines that follows an addition (a "+" line). To be able to reverse patches in the future got_patch needs to know about all of these lines instead. No functional changes intended. ok stsp@
Omar Polo ed3bff83 2022-04-23T07:56:18 got patch: resolve paths from the current working directory this allow to apply patches from subdirectories of the work tree root. Prodded by naddy@, ok stsp@.
Omar Polo a05fb460 2022-04-23T07:54:56 don't pass relative paths to get_file_status
Omar Polo 41a37a44 2022-04-23T07:49:42 fix wrong path in error message
Stefan Sperling d7b5a0e8 2022-04-20T14:00:12 inline struct got_object_id in struct got_object_qid Saves us from doing a malloc/free call for every item on the list. ok op@
Stefan Sperling cbc287dc 2022-04-19T20:08:41 reimplement object-ID set data structure on top of a hash table Siphash suggested by jrick as a better alternative to murmurhash for this use case. with small fixes from and ok op@
Stefan Sperling 70f8f24d 2022-04-14T15:05:19 speed up initial stage of packing by adding a "skip" commit color The skip color marks boundary commits and their ancestors. Boundary commits are reachable both via references which we want to exclude from the pack, and via references which we want to include in the pack. We continue processing commit history up to the point we are left with only skip commits on the queue. This can speed up findtwixt() significantly and avoids wrong results produced by the old algorithm which made no distinction between "drop" and "skip". This idea was first implemented by Michael Forney for git9: https://git.9front.org/plan9front/plan9front/2e47badb88312c5c045a8042dc2ef80148e5ab47/commit.html Michael's log message for git9 is reproduced below: git/query: refactor graph painting algorithm (findtwixt, lca) We now keep track of 3 sets during traversal: - keep: commits we've reached from head commits - drop: commits we've reached from tail commits - skip: ancestors of commits in both 'keep' and 'drop' Commits in 'keep' and/or 'drop' may be added later to the 'skip' set if we discover later that they are part of a common subgraph of the head and tail commits. From these sets we can calculate the commits we are interested in: lca commits are those in 'keep' and 'drop', but not in 'skip'. findtwixt commits are those in 'keep', but not in 'drop' or 'skip'. The "LCA" commit returned is a common ancestor such that there are no other common ancestors that can reach that commit. Although there can be multiple commits that meet this criteria, where one is technically lower on the commit-graph than the other, these cases only happen in complex merge arrangements and any choice is likely a decent merge base. Repainting is now done in paint() directly. When we find a boundary commit, we switch our paint color to 'skip'. 'skip' painting does not stop when it hits another color; we continue until we are left with only 'skip' commits on the queue. This fixes several mishandled cases in the current algorithm: 1. If we hit the common subgraph from tail commits first (if the tail commit was newer than the head commit), we ended up traversing the entire commit graph. This is because we couldn't distinguish between 'drop' commits that were part of the common subgraph, and those that were still looking for it. 2. If we traversed through an initial part of the common subgraph from head commits before reaching it from tail commits, these commits were returned from findtwixt even though they were also reachable from tail commits. 3. In the same case as 2, we might end up choosing an incorrect commit as the LCA, which is an ancestor of the real LCA.
Stefan Sperling a7472cb3 2022-04-14T15:00:59 check return value of RB_INSERT; ok + memleak fix by op@