Skip to content

Replace submodules with subtrees #70651

Closed

Description

@oli-obk

cc @rust-lang/clippy @RalfJung

cc @rust-lang/compiler @rust-lang/infra we gate on clippy soon, so if you break clippy you need to fix it immediately in the same PR. This is trivial now though, since we are basically in a monorepo state, so you just edit stuff in src/tools/clippy/ until everything works again.

Synchronizations of the remote repo and the local subtree is explained in CONTRIBUTING.md

The first port (clippy) is being done in #70655

Activity

  1. added
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    T-infraRelevant to the infrastructure team, which will review and decide on the PR/issue.
    on Apr 1, 2020
  2. RalfJung commented on Apr 1, 2020

    @RalfJung
    Member

    Cc @rust-lang/miri because we have that now :D

  3. eddyb commented on Apr 1, 2020

    @eddyb
    Contributor

    Hmm, I was led to believe that git subrepo was nesting git repositories, in a way which git natively handles. But it turns out it's just a monorepo sync tool, same as manually making large commits. I don't think losing commit history is acceptable.

    At a glance, git subtree looks like it might do the right thing, i.e. keep the repository nesting of a submodule, but I haven't tried it yet to see how it actually behaves in practice.
    EDIT: ah, no, git subtree just seems to create synthetic commit histories. Still, could be better than a single sync mega-commit.
    EDIT2: somehow it still managed to preserve commit history?! Compare:
    https://github.com/rust-lang/rust-clippy/commits/master
    https://github.com/rust-lang/rust/commits/c211cea3e99e04c2980a853b6637de22881b72eb

  4. changed the title [-]Replace submodules with subrepos[/-] [+]Replace submodules with subtrees[/+] on Apr 1, 2020
  5. oli-obk commented on Apr 1, 2020

    @oli-obk
    ContributorAuthor

    I moved to git subtree.

  6. eddyb commented on Apr 1, 2020

    @eddyb
    Contributor

    In case it gets lost on the PR, I said: #70655 (comment)

    Whoa, clippy commit hashes were kept intact, this makes me really happy!11

  7. RalfJung commented on Apr 1, 2020

    @RalfJung
    Member

    I moved to git subtree.

    Would be good to get the pro's and con's of that decision documented somewhere. git submodule advertises itself as a better alternative to git subtree; why is subtree still the better choice for us?

    (Also I have no idea in which thread to post now, there's at least this issue and 2 PRs. It's very confusing.^^)

  8. oli-obk commented on Apr 1, 2020

    @oli-obk
    ContributorAuthor

    I don't know why git subrepo is better than git subtree other than what the documentation of git subrepo states at https://github.com/ingydotnet/git-subrepo#benefits

    Fixes known rebase failures with git-subtree.

    git subtree is better than git subrepo because it preserves all commits in history instead of squishing them in the name of the person who synchronizes it.

  9. eddyb commented on Apr 1, 2020

    @eddyb
    Contributor

    git subtree is upstream, which is nice, and it also supports preserving the commits better.
    I believe the "rebase failures" that git subrepo talks about are actually an anti-pattern: rebasing a merge commit, it's not meant to work at all (the rebase will include both branches and lose the merge commit - this can already happens if you accidentally rebase the wrong thing in rust-lang/rust).

    git subrepo seems to want to just throw all the changes into single large commits so you "don't have to deal with it", whereas git subtree is more history-preserving-oriented, which I prefer.

  10. RalfJung commented on Apr 1, 2020

    @RalfJung
    Member

    git subtree is better than git subrepo because it preserves all commits in history instead of squishing them in the name of the person who synchronizes it.

    Is this true in both directions (subtree pull/push)?

    Does git subtree also have the problem that a "subtree push" needs a commit on the rustc side?

  11. oli-obk commented on Apr 1, 2020

    @oli-obk
    ContributorAuthor

    no, git subtree push does not need a commit on the rustc side.

    The only downside of git subtree is that you need to specify the folder name and target repo on every synchronization (because there's no synchronization metadata file)

  12. Manishearth commented on Apr 1, 2020

    @Manishearth
    Member

    I would prefer the history preserving option. I was under the impression that subrepo had a no squash mode but that could be subtree.

  13. RalfJung commented on Apr 1, 2020

    @RalfJung
  14. 36 remaining items

  15. bjorn3 commented on Oct 31, 2020

    @bjorn3
    Member

    The crate metadata doesn't refer to the repo, so posting it here for others trying to find it: https://github.com/mominul/gitree

  16. RalfJung commented on Mar 26, 2021

    @RalfJung
    Member

    Using subtrees can lead to spuriously re-closing issues that were re-opened. This just happened to #82080:

    the original commit did a lot of things, among them fixing clippy. The commit description contained "Fixes #82080". Each commit that affects clippy is synced to clippy (creating a new commit ID since all the non-clippy changes are removed from it), and then that is synced back (with the same commit ID as what it got in clippy). So now we got a fresh commit that still has "Fixes #82080" in its description.

    I am not sure what to do about this, but we have a notable risk here of losing track of issues by accidentally closing them.

    Can we make it so that the commit that is synthesized for clippy doesn't just have its non-clippy changes removed, but also has its commit message "sanitized" to ensure that it will not cause any automatic actions by GitHub?

  17. bjorn3 commented on Mar 26, 2021

    @bjorn3
    Member

    Can we make it so that the commit that is synthesized for clippy doesn't just have its non-clippy changes removed, but also has its commit message "sanitized" to ensure that it will not cause any automatic actions by GitHub?

    I think git subtree would then consider it a different commit and try to pull the original conmit every time you sync.

  18. flip1995 commented on Mar 26, 2021

    @flip1995
    Member

    There's the option in subtree to squash-sync the commits to rustc. But that way we would lose the Clippy history in rustc.

    If we want to keep the history of Clippy and keep using subtree, we just have to live with this, I guess...

  19. RalfJung commented on Mar 26, 2021

    @RalfJung
    Member

    I think git subtree would then consider it a different commit and try to pull the original conmit every time you sync.

    Why that, doesn't it have some kind of bookeeping to match up the commits? Relying on commit messages seems rather fragile?

  20. bjorn3 commented on Mar 26, 2021

    @bjorn3
    Member

    I assumed it required the commit to be identical where possible. Based on a cursory reading of the source it seems to only require the tree to be the same: https://github.com/gitgitgadget/git/blob/fe2e4819b869725f870cd3ce99f1f8150fe17dc1/contrib/subtree/git-subtree.sh#L598

  21. flip1995 commented on Mar 26, 2021

    @flip1995
    Member

    Copying comments from #82080:

    @jplatte wrote:

    This sounds like a general problem with the subtree approach...

    IMHO this is more of a problem with GitHub issue / PR references in commit messages. It also happens when merging repos, no matter if you use subtree or sth. else, as long as you keep the history you can have super old commits that suddenly affect (or just reference) new and entirely irrelevant issues. My approach has been to always keep these references out of commits, and only have them in PR descriptions and comments.

    @flip1995 wrote:

    The problem is, that bors includes the PR body in the commit message. Maybe bors could sanitize the PR body and remove keywords that results in closing issues. This doesn't fix the problem, when normal commit messages have a <keyword> #issue in them, but I think the main problem are bors commits copying PR bodies.

  22. RalfJung commented on Mar 26, 2021

    @RalfJung
    Member

    The problem is, that bors includes the PR body in the commit message.

    Good point. Not doing that for the "active" messages could also help. (It'd also cut down on notifications, if bors removed @mentions as well.)

  23. Manishearth commented on Mar 27, 2021

    @Manishearth
    Member

    I feel like that's a pretty rare occurrence and unfortunately the tooling doesn't support doing such a transform currently. We could tweak the bors thing though

  24. RalfJung commented on Mar 27, 2021

    @RalfJung
    Member

    Well, it's also something that has a high chance of flying below the radar when it happens. All we know is it happened at least once.

  25. added a commit that references this issue on May 15, 2021
  26. tmandry commented on Jan 11, 2022

    @tmandry
    Member

    FYI there's been some discussion of experimenting with miri on Fuchsia, and transitioning miri to an always-green subtree is one of the primary blockers.

  27. oli-obk commented on Jul 3, 2023

    @oli-obk
    ContributorAuthor

    Clippy is now using subtree, miri is using https://github.com/josh-project/josh/ (a Rust thing that is better and more powerful in various ways than subtree)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-metaArea: Issues & PRs about the rust-lang/rust repository itselfC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-infraRelevant to the infrastructure team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions