There are a variety of workflows that can be effectively used with both Git version control and GitHub. We should have a common and consistent workflow across as much of Carbon as possible. While some specific areas may end up needing specialized flows to suit their needs, these should be the exceptions and can be handled on a case-by-case basis when they arise.
Carbon repositories should all follow a common workflow for managing and landing changes. The document outlines the specifics of the proposed workflow as well as the core motivation.
trunkThis achieves two goals:
Replaces the term master. This term, while only used in isolation in Git,
was used
in immediately preceding and related systems as part of extremely problematic
"master/slave" terminology. That background associates the term with
unacceptable historical and cultural meanings. The intent of those using or
adopting the term isn't relevant to this association. The less overtly
problematic term being isolated from the rest doesn't erase its history, and
doesn't completely avoid painful associations.
It directly anchors and reinforces contributors on the trunk-based workflow.
While Git can effectively bisect through complex history graphs, this is significantly harder than bisecting across linear history. Especially for any part of Carbon involving code, we expect bisection to be a pervasive tool and we can make it simpler and more effective by forcing a linear history.
A linear history also makes it much easier to ask questions about whether a
particular change has landed yet, or when a bug was introduced. For some people,
releases are more simply understood as branching from a specific snapshot of the
linear history. While tools like git log can provide similar functionality, it
is less trivially understood.
Continuous integration is simplified for many of the same reasons as bisection: the set of potential deltas is reduced to a linear sequence. Reverting to green becomes easier to understand, and testing each incremental commit has a single obvious interpretation.
Requiring linear history also incentivises incremental development that is committed early to the main branch. This, in essence, ensures a single source of truth model even with the distributed version control system. Because works-in-progress are required to be rebased, they tend to merge early and often rather than forming long-lived development branches. This helps reduce the total merge resolution and testing costs as a project scales. For more details about the advantages of using a single source of truth, see the full text of the "Version Control and Branch Management" chapter in the SWE book.
One concern with linear history when rebasing a sequence of changes and merging them is that the pull request associated with that sequence might not be obvious from the main branch commit log. However, there is enough information in the repository to establish the relationship, and GitHub's UI surfaces the pull request on each commit in the series.
LLVM allows directly pushing/submitting to their "trunk" with post-commit review. LLVM enforces linear history for day-to-day development. Merge commits are allowed for rare events like contributing a new subproject.
Advantages:
Disadvantages:
Classically, Git and GitHub support merging entire complex graphs of development.
Advantages:
Disadvantages:
Imagine a fork and merge model, but PRs can only have linear history. That is,
branching and merging within a PR, or merging trunk into PR is not allowed. In
this model, the only merge commits are merges of PRs into trunk. PRs
themselves don’t contain merge commits.
Advantages:
Disadvantages: