bootstrap: Improve the UX when run from a git worktree

75b9c5b
Opened by jyn at 2024-10-10 09:08:11

It should look something like this behind the scenes:

$ x.py setup --worktree ../rustc2
Setting up a new worktree at `/home/joshua/rustc2`  # runs `git worktree add ../rustc2`
# all the current prompts, but config.toml is written to rustc2 instead of the current directory
# does *not* suggest to set up a git hook

This would make https://rustc-dev-guide.rust-lang.org/building/suggested.html?highlight=worktree#working-on-multiple-branches-at-the-same-time a lot more discoverable.

It should also use the submodule suggestions from https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/script.20to.20quickly.20generate.20complete.20git.20worktree (cc @lzutao), which would prevent cloning llvm more than once.

This would help work around https://github.com/rust-lang/rust/issues/77620.

  1. it would be nice if bootstrap could auto-detect when it's being run from a git worktree and share

    • the git submodule history, so it doesn't have to be refetched from the network https://github.com/rust-lang/rust/issues/77621#issuecomment-1596970050
    • the config.toml from the original worktree https://github.com/rust-lang/rust/issues/77621#issuecomment-1596967245
    <details><summary>original issue description</summary>

    It should look something like this behind the scenes:

    $ x.py setup --worktree ../rustc2
    Setting up a new worktree at `/home/joshua/rustc2`  # runs `git worktree add ../rustc2`
    # all the current prompts, but config.toml is written to rustc2 instead of the current directory
    # does *not* suggest to set up a git hook
    

    This would make https://rustc-dev-guide.rust-lang.org/building/suggested.html?highlight=worktree#working-on-multiple-branches-at-the-same-time a lot more discoverable.

    It should also use the submodule suggestions from https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/script.20to.20quickly.20generate.20complete.20git.20worktree (cc @lzutao), which would prevent cloning llvm more than once.

    This would help work around https://github.com/rust-lang/rust/issues/77620.

    </details>

    jyn at 2023-06-19 11:00:29

  2. This could also suggest to copy over the existing config.toml as one of the profile choices.

    jyn at 2020-10-12 21:29:15

  3. This could also suggest to copy over the existing config.toml as one of the profile choices.

    i think this is good and useful, but rather than making it opt-in with --worktree, we should do it automatically when we detect the current git checkout is in a worktree:

    (bash@pop-os) ~/src/rust2
    ; file $(git worktree list | grep -v ~/src/rust2 | head -n1 | awk '{print $1}')/config.toml
    /home/jyn/src/rust/config.toml: ASCII text, with very long lines (634)
    

    jyn at 2023-06-19 10:49:49

  4. actually

    rather than adding an extra step, we could fall back to the config.toml of the primary worktree if it doesn't exist in the current worktree. it's a little more implicit, but it seems like a more useful behavior, and it will always get overridden if someone's already made a config.toml.

    jyn at 2023-06-19 10:56:54

  5. rather than adding an extra step, we could fall back to the config.toml of the primary worktree if it doesn't exist in the current worktree. it's a little more implicit, but it seems like a more useful behavior, and it will always get overridden if someone's already made a config.toml.

    we could do something similar for checking out submodules so we don't have to re-fetch the history in each worktree

    jyn at 2023-06-19 10:58:39