Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ rows labeled **Agent default** bind AI agents only. Agents set
| Creating a **COMP:** commit | [git-commits.md](./Documentation/AI/git-commits.md), [compiler-cautions.md](./Documentation/AI/compiler-cautions.md) |
| Commit or PR attribution | [attribution.md](./Documentation/AI/attribution.md) |
| Changing downstream-visible API, behavior, or requirements | [migration-records.md](./Documentation/AI/migration-records.md) |
| Backporting a fix, or any change to a `release` or `release-X.X` branch | [release-branches.md](./Documentation/AI/release-branches.md) |
| Opening or updating a pull request | [pull-requests.md](./Documentation/AI/pull-requests.md), [attribution.md](./Documentation/AI/attribution.md) |
| Updating a vendored ThirdParty dependency or its fork (eigen, DCMTK, VNL/vxl) | [ThirdPartyForkConventions.md](./Documentation/Maintenance/ThirdPartyForkConventions.md), [updating_third_party.md](./Documentation/docs/contributing/updating_third_party.md) |

Expand Down
77 changes: 77 additions & 0 deletions Documentation/AI/release-branches.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Release Branches and Backports

ITK keeps every maintenance branch connected to `main` by merging forward.
The human procedure is in
[contributing/index.md](../docs/contributing/index.md#merge-a-bug-fix-for-a-patch-release)
and [Release.md](../Maintenance/Release.md#integrate-bug-fixes-in-the-release-branch);
this page states the rules and the checks. Tiers follow
[rule-tiers.md](./rule-tiers.md).

## Branches

| Branch | Holds |
|---|---|
| `main` | Development |
| `release` | The newest release and its next patch release |
| `release-X.X` | One older series, e.g. `release-5.4` for ITK 5 |

## Where a fix starts

| The fix is for | Branch from, and open the PR against |
|---|---|
| New development | `main` |
| The next patch of the newest release | `release` |
| An older series | that `release-X.X` |
| A fix already merged on `main` | `release` or `release-X.X`; cherry-pick the `main` commit onto the topic |

A cherry-picked fix appears twice in history after the merge forward. That is
expected.

## Merge forward

Every change on a maintenance branch reaches `main` by merge, never by
cherry-pick alone:

```
release-X.X → release → main (each step git merge --no-ff)
```

- Each step is its own pull request, so each conflict resolution is reviewed
on its own.
- A conflict where `main` already holds the fix in a newer form resolves to
`main`'s version. After resolving, `git diff upstream/main HEAD` shows only
what the maintenance branch adds (release notes, a version-specific
change); anything else is a resolution error.
Comment on lines +41 to +44

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 First merge targets wrong branch

During release-X.X → release, main is not the destination and can contain newer development that must stay out of release. Comparing that result with upstream/main also shows legitimate development differences, not just resolution errors. The contributing guide repeats this guidance.

Use release's form and compare against upstream/release for the first step. Reserve the current guidance for release → main.

- List every conflict and its resolution in the merge PR body.
- Never rebase or force-push `release` or `release-X.X`.

After a patch release is tagged, merge forward so the tag is an ancestor of
`main`. Merging sooner keeps each merge small: conflicts accumulate while a
maintenance branch goes unmerged.

## Checking conformance

Each command prints nothing when the branches conform:

```bash
git fetch upstream --tags
git log --oneline --no-merges upstream/release..upstream/release-5.4
git log --oneline --no-merges upstream/main..upstream/release
git log --oneline --no-merges upstream/main..upstream/release-5.4
Comment on lines +58 to +60

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Checks hide missing merges

--no-merges hides commits these checks need to catch. If a topic reaches both branches through separate merges, the maintenance branch can still have an unmerged merge commit while these commands print nothing. A fix made while resolving that merge can also be missed.

Remove --no-merges, or check each maintenance branch tip with git merge-base --is-ancestor and print failures.

Suggested change
git log --oneline --no-merges upstream/release..upstream/release-5.4
git log --oneline --no-merges upstream/main..upstream/release
git log --oneline --no-merges upstream/main..upstream/release-5.4
git log --oneline upstream/release..upstream/release-5.4
git log --oneline upstream/main..upstream/release
git log --oneline upstream/main..upstream/release-5.4

for t in $(git ls-remote --tags --refs upstream 'v5.4*' 'v6*' | sed 's#.*refs/tags/##'); do
git merge-base --is-ancestor "$t" upstream/main || echo "$t"
done
```

Use upstream's tags, as above; a stale local tag gives a false report.
Comment on lines +61 to +66

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Tag check uses local targets

The loop checks local tags despite the warning below it. git ls-remote supplies upstream names, but the command discards their object IDs and resolves "$t" locally. If a local tag differs, git fetch --tags refuses to replace it. The block then continues and checks the stale tag, which can report the wrong ancestry result.

Fetch upstream tags into a separate namespace and check those refs, or stop on fetch failure and explain how to resolve a tag mismatch.


## Agent defaults

**Agent default:**

- Do not open a merge-forward PR unless a maintainer asks for that step;
release managers run them around patch releases.
- A backport is not finished when its PR merges. Report in the PR body
which merge-forward steps it still needs, using the commands above.
- Resolve a merge-forward conflict by taking the maintenance side only when
`main` lacks the change; state the reason for each conflict.
7 changes: 7 additions & 0 deletions Documentation/Maintenance/Release.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,13 @@ git merge --ff-only release
git push upstream $major_minor
```

After a patch release of an older series, merge `release-X.X` into `release`
and `release` into `main`, one pull request each. Then confirm the branches
are connected with the checks in
[release-branches.md](../AI/release-branches.md#checking-conformance): each
prints nothing when every maintenance commit and release tag has reached
`main`.

### Remote modules

Add any new remote modules to nightly builds. Some builds may be difficult to add
Expand Down
11 changes: 11 additions & 0 deletions Documentation/docs/contributing/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ where `X.X` is the maintenance version targeted by the fix (e.g., `5.4`).
- If the patch applies to an **older maintenance series** (e.g., ITK 5),
fork the topic off `release-5.4` (or the corresponding `release-X.X`
branch). Open the pull request against that same `release-X.X` branch.
- If the fix is **already merged on `main`**, fork the topic off the
maintenance branch as above and cherry-pick the `main` commit onto it.
The commit appears twice in the history after the merges below.

2. Merge the topic into the `release-X.X` branch:

Expand Down Expand Up @@ -422,6 +425,14 @@ connected in the Git history (the directed acyclic graph that records branch
ancestry). Keeping the branches connected also avoids future merge conflicts
between the maintenance and development lines.

Steps 3 and 4 may be done later by a release manager, but no later than
after the next patch release is tagged, so the tag becomes an ancestor of
`main`. When a merge conflicts because `main` already holds the fix in a newer
form, keep `main`'s version, and list each conflict and its resolution in the
pull request. The rules and the commands that check the branches are
connected are in
[Documentation/AI/release-branches.md](https://github.com/InsightSoftwareConsortium/ITK/blob/main/Documentation/AI/release-branches.md).

(delete-a-topic)=
Delete a Topic
--------------
Expand Down
Loading