Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

worktree checkout for clone and gix integration #555

Merged
merged 153 commits into from
Nov 2, 2022
Merged

worktree checkout for clone and gix integration #555

merged 153 commits into from
Nov 2, 2022

Conversation

Byron
Copy link
Member

@Byron Byron commented Oct 10, 2022

Even though early, add support for the existing worktree checkout functionality to the git-repository::clone implementation, and make it available with gix clone

Tasks

  • fetch_and_checkout() for git_repository::clone::Prepare to support main worktree checkouts at first
    • handle object-format server option
    • setup HEAD, roughly
    • checkout options from config
    • basic files-only worktree checkout (ignoring filters)
    • .keep for pack until refs are updated (fix for git-fetch)
    • respect checkout.workers, but prefer parallelism (deviation)
    • validate URL is written to config as is or as absolute path in case it's a path
    • reflog entries are similar to git
    • also write remote HEAD to refs/remotes/origin/HEAD, pointing to the remote tracking branch
    • pack all non-symbolic refs
    • support remotes with unborn branches
    • setup tracking branch information (for now, just hard-code it)
    • does git always adopt the remote branch that HEAD there points to? yes
    • clone an empty repo (unborn)
  • gix clone as sibling to gix fetch
  • make sure non-bare clone won't write into non-empty directory either (it happily writes into a bare repo)
  • print conflicts after gix clone

See how fast one can clone the complete linux kernel (using a RAM drive) with gitoxide in comparison to git

Next

  • use new high-speed item-by-item parallelization mechanism - can this work?

Out of scope

  • correct handling of setting up tracking branches (see checkout.defaultRemote, checkout.guess, submodule.recurse)

Prior work

Byron added 30 commits October 11, 2022 07:42
It works similarly to `PrepareFetch` and allows future upgrades and
improvements thanks to being a builder essentially, while yielding a
lot of control to the caller who decides everything about retries
and whether or not to retain anything on disk even if the operation
wasn't successful (with the default of removing leftovers).
This differentiation can one day allow to also checkout linked worktrees
from a bare repository, which otherwise couldn't have a worktree post
clone.
…self`. (#450)

This generally makes returned values longer, and as long as one would
expect.
It's only available after connecting to the server.
Fetch, however, should check for it as well and abort, whereas here
we dont't want to abort.
Entirely unsupported formats will error when fetching refs, and when
cloning we get a chance to configure the repo before proceeding.
…xes. (#450)

The current implementation might cause refspecs to end up ignored as
they don't have a prefix, and in protocol V2 it would then fail
to add a ref-spec filter which causes them to be missed.

With `expand_prefix()`, we assure that there are all possible prefixes
that can contain partial names, similar to what git does.
Previously specs could get filtered out server-side as a matching prefix
was entirely missing.
… and `expanded_prefix()`. (#450)

Previously, the expanded prefix would be a list of possibilities, even
though it's such a common case that we really want to avoid spamming the
remote about it when asking for HEAD during clone for instance.
This applies to bare and non-bare fetches equally, and provides the
foundation for actually checking out something as we can just rely on
what's in HEAD.
Byron added 27 commits November 1, 2022 11:19
When configuring for packed-refs updates, previously one needed to
provide a function to find objects that could not borrow data due
to implicit 'static requirement. This has been lifted to allow
it to access references to data on the stack.
…e::Name`. (#450)

That way it's made clear the remote can also be a URL, while rejecting
illformed UTF8. The latter isn't valid for remote names anyway as these
only support a very limited character set.

Note that this error currently is degenerated, making it appear if the
remote name doesn't exists if illformed UTF-8 is found in what appears
to be a symbolic ref.
…#450)

We can also parse it, adding yet another variant to `fetch::Refs`.
workaround for https://bugs.launchpad.net/ubuntu/+source/git/+bug/1993586
where git refuses to run submodule updates as they can be used as attack
vector.
That way the caller has to be aware of the possibility of an unborn
branch (probably the only unborn branch) on the remote.
…stination) (#450)

That's exactly what git does, so it's probably the right thing to do if
in doubt.
Previously we assumed this could only happen for `HEAD`, but in fact
dangling symrefs are possible and they might end up in the server
response that way.
Don't use `static` unless it's really needed
However, it's not yet refreshed in the repository we create, so
that needs fixing.

Implementing `repo.config()` would be too much effort for now, so
let's continue forcing it in another way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant