Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Follow up to #3867
Tasks
store commit data directly (as object)- not possible withgit2
, besides, it's safe to assume newline-separation between headers and message.assure test index restoreassure test vbranch-commit restoreassure test vbranch-tree restoreassure test integration restorereview everything else of oplog.rs and assure important parts have basic tests at leastNotes for the Reviewer
set_head()
is used unconditionally. The prepare-snapshot code is still flexible and treats it as optional.Open questions
Can the usage of oplog be more abstract?
Right now it's hand-rolled prepare-commit steps everywhere, could that be more 'automatic'?
TBD❗️
General Thoughts
On
core.git
core::git::*
and all its wrapped types I was wondering if this is going to be a god-sent or a burden. Time will tell.git
wrapped types don't seem to be used much/consistently withinops
, which makes it a potential burden.git2
while it's there as long as repositories aren't kept around but opened mostly when needed. This is what I have seen. I have also seen a simple API wrapper for configuration handling (get/set) and though that such improvements could be done with so that we'd havegit2::Repository::open()?.config().easy().use_easy_api()
- this is just a general idea. Right now I can't tell, but I will keep an eye out for that.git2
usage withgit
except for in the API (wheregit::Oid
is used instead ofgit2::Oid
) until I know what's the right choice here.On worktree-handling
Due to variable naming, it's not always clear what
Project::path
is. It's a worktree-directory, and whenever it's used likeproject.path.join(".git/gitbutler")
it's a problem that will prevent GB from dealing with ALL the repository configurations out there as.git
doesn't have to be a directory, nor does it have to be there at all. The only way to handle this correctly is to open a repo withgix::open()
and then use thegit_dir()
andworktree_dir()
methods respectively to get the actual directories. These do have to be treated separately, but it's definitely a good idea start from a working-tree directory as it matches with the single-worktree paradigm of GB.When the is a
repo
already, definitely use itspath()
(which is itsgit_dir
), instead of doingwd.join(".git/gitbutler/...")
.Avoid
sha
in variable namesAs everything should be strongly typed, as opposed to stringly typed, by the type it's already clear that it's a hash. What's not usually clear is what the hash points to. If I read
target_sha
I don't know much, especially becausetarget
is GB lingo fortrunk to merge with
. Instead, I'd call ittarget_commit
, which tells me something important that's not obvious from the type otherwise.Don't predict the compiler
Sometimes code feels like it tries to anticipate what the compiler would say, even though the most direct (or intuitive) way of doing things would actually work. It's usually easiest to try first, and then make it work if needed. Sometimes, it just works.
Don't repeat module-names in test-functions
That way, they read well both on the command-line and in IDEs.
From there, it's also easier to find more descriptive names.