Skip to content

Turning cargo into a git subtree in rust-lang/rust #15882

@weihanglo

Description

@weihanglo

This is an issue tracking how many issue we encountered because Cargo is not a Git subtree in rust-lang/rust repository. See also the discussion in #t-cargo > Turning cargo into a subtree.

Below is a summary from t-cargo originally posted in #t-cargo > Turning cargo into a subtree @ 💬.


The Cargo team has discussed subtree migration last week. We've got a couple of questions and would like to understand before proceeding:

  • Motiviation of turning into a subtree.
  • Burden of resolving conflicts
  • Issue / PR managements
  • Possibility to revert to submodule

Motivation of turning into a subtree

It seems that it was brought up again because there were some recent pull requests blocked by Cargo's overly-fitted test assertions. Apart from that, are there any other reasons or benefits people wanting Cargo to be a subtree? How painful is it that people need it to happen soon otherwise it toils the development?

From 1.75 (2023-12-28) to 1.83 (as of 2025-01-07), there are around 11 pull requests opened in rust-lang/cargo because test failures in Cargo's test suite really blocked their pull request in rust-lang/rust.

See a list of pull requests

There are other cross-repo efforts like check-cfg and checksum-freshness. However I don't think it is better do it in subtree, as those changes are way larger and may require scrutiny from the Cargo team. See the full list of PRs in the end of this post

We generally doesn't seem it being to much a burden for the current submodule process. To myself I have been actively helping people to unblock Cargo and never feel stressful about it. We would like to understand how other teams' feelings. Maybe it is really frustrating to other? Maybe they just didn't know who to ask for helps?

Burden of resolving conflicts

According to feedback from miri and other repos, conflicts seem rare and easy to deal with. The current Cargo maintainer doing sync (me) is also willing to take resposibility to do subtree maintenance as well. However, team still has concerns of the burden.

I've collected data from other subtree projects of how often they synced back to the original repositories:

The number of subtree-to-repo syncs are not really as many as I expect. Apparently Miri outnumbered others, though those PRs are mostly one-click-mergeable.

However, rust-lang/cargo has weird CI — it needs to pass all stable, beta, and nightly channel. A change in subtreee may accidentally fail on stable or beta. What if we discovered it only after beta cutoff, should we backport the fix of conflits?

Also, if a subtree-to-repo sync happens after beta cutoff, that sync needs to merge into beta branch (rust-1.y.z branch ) in rust-lang/cargo. That means cargo might not be able to reuse scripts from existing subtree, or need more tweaks. The CI infra migration possibly requires more works than the recent rustc-dev-guide one.

Issue / PR managements

These are not really big problems but a compilation of small questions about the project management.

  • Will GitHub magic keywords close issues with the same number for both repos? For example, in cargo a commit message says closes #12345. Will it also close rust-lang/rust#12345 when syncing to subtree?
  • Similarly, the commit hash changes between repos for the same commit. Which one commit should be the de facto one when discussing/linking/sharing? The question can be seen as "which one is the real source." or "don't duplicate source code" which @Josh Triplett has called out one year ago.
  • If a pull request was opened in rust-lang/rust but has nothing to do with compiler, should we merge it then, or request a reopen in rust-lang/cargo? What is the general rule of the current subtrees?
  • Should PR to cargo subtree require approvals from the Cargo team? That requires a more granular bors permission though, and we've seen some objections to that because people may want to get a faster merge for small changes without waiting for specific teams/people.

Possibility to revert to submodule

If it turns out not suitable for Cargo's workflow, is it possible to revert back to Git submodule, and how would it be?

If reverting is easier, it is more likely we could test out and see if it is worth it.


Anyhow, the cargo team is more on weighing the benefit and tradeoff. Dont take these questions as objection :)

See the full list of cross-repo PR in rust-lang/cargo

Note: not all of them really need to happen in subtree.

Summary Notes

Managed by @rustbot—see help for details

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-infrastructureArea: infrastructure around the cargo repo, ci, releases, etc.C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-needs-team-inputStatus: Needs input from team on whether/how to proceed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions