Skip to content

feat: pull, clone --force and commit apply the patches on the new upstream - #214

Open
thorsten-klein wants to merge 1 commit into
feat/209-patches-verifyfrom
feat/210-pull-with-patches
Open

thorsten-klein wants to merge 1 commit into
feat/209-patches-verifyfrom
feat/210-pull-with-patches

Conversation

@thorsten-klein

@thorsten-klein thorsten-klein commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Fixes #210

Based on #213. Part 3 of 5.

What

Once the folder has a patch, the patches take over:

  • pull checks that the patches hold all local changes, then takes upstream and runs one git am -3 with all patches. It writes the patches again and commits them with the pull.
  • On a conflict, the pull stops and names the patch. git am --continue, then git nested commit. Split patches stay split.
  • A patch that upstream already has is dropped.
  • clone --force applies the patches from HEAD on top of upstream.
  • commit writes the patches from the nested branch. A branch that is not a line becomes one patch.
  • push --commit empties the folder.
  • git nested patches drop <subdir> <patch>... removes patches and their changes from the subdir, writes the other patches again without gaps, and commits. It stops if a later patch needs a dropped one.
  • The nested branch of every command leaves the folder out.

Until the folder has a patch, every command works as before.

Not yet: pull --no-squash, squash: false and pull --ignore. They are refused with a message.

Tests

Pull on a new upstream, a refused pull, a dropped patch, CRLF, a conflict and resume, split patches with a squash merge, a merge that becomes one patch, push --commit, reclone, patches drop, a folder outside the subdir, and nested repos inside.

@codecov

codecov Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (9d08374) to head (21d9c8c).
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@                    Coverage Diff                     @@
##           feat/209-patches-verify      #214    +/-   ##
==========================================================
  Coverage                   100.00%   100.00%            
==========================================================
  Files                           49        49            
  Lines                         2540      2660   +120     
==========================================================
+ Hits                          2540      2660   +120     
Files with missing lines Coverage Δ
src/git_nested/checks.py 100.00% <100.00%> (ø)
src/git_nested/cli/parser.py 100.00% <ø> (ø)
src/git_nested/cli/spec.py 100.00% <ø> (ø)
src/git_nested/commands/clone.py 100.00% <100.00%> (ø)
src/git_nested/commands/commit.py 100.00% <100.00%> (ø)
src/git_nested/commands/patchset.py 100.00% <100.00%> (ø)
src/git_nested/commands/pull.py 100.00% <100.00%> (ø)
src/git_nested/commands/push.py 100.00% <100.00%> (ø)
src/git_nested/content.py 100.00% <100.00%> (ø)
src/git_nested/history.py 100.00% <100.00%> (ø)
... and 3 more

@thorsten-klein
thorsten-klein force-pushed the feat/210-pull-with-patches branch from 0579a3c to 5306168 Compare November 13, 2026 19:27
@thorsten-klein
thorsten-klein force-pushed the feat/209-patches-verify branch 2 times, most recently from 0371c8e to f7193d3 Compare November 13, 2026 19:37
@thorsten-klein
thorsten-klein force-pushed the feat/210-pull-with-patches branch from 5306168 to 1d0ee21 Compare November 13, 2026 19:37
@thorsten-klein
thorsten-klein force-pushed the feat/209-patches-verify branch from f7193d3 to 9d08374 Compare November 13, 2026 20:02
@thorsten-klein
thorsten-klein force-pushed the feat/210-pull-with-patches branch from 1d0ee21 to 21d9c8c Compare November 13, 2026 20:02
@sonarqubecloud

Copy link
Copy Markdown

thorsten-klein added a commit that referenced this pull request Nov 13, 2026
… repo as patch files (#212)

Fixes #198

First of five stacked PRs for the patches. Each builds on the one
before: #212 → #213 → #214 → #215 → #216.

## What

- New field `patches: <path>` in `.gitnested`: the folder with the local
changes as patch files, relative to the subdir. Without it, the patches
are off.
- New command `git nested patches create [<subdir>]`:
  - applies the patches on the upstream commit with `git am`,
  - writes what HEAD has on top as one more patch, with a TODO title,
- writes all patches again in one form: no commit id, no signature,
named after the title.
- The folder is never pushed. `diff` and `status` do not count it.
- Nested repos inside the subdir are left out. They can have their own
folder.
- `verify --patches` applies patches with `git am` now, so a plain diff
given as a patch is refused. `--diffs` still uses `git apply`.
- New module `patchbuild.py`: the temporary worktree, `git am`, and
writing the patches. `verify` uses it too.

## Docs

New page `doc/cli/patches.md` and guide `doc/guides/patches.md`. Updated
the `.gitnested` reference, `config`, `verify`, the man page and the
call diagrams.

## Tests

New `tests/e2e/test_patches.py`. The full suite passes with 100%
coverage.
@thorsten-klein
thorsten-klein force-pushed the feat/209-patches-verify branch from 9d08374 to 32bf985 Compare November 13, 2026 20:45
@thorsten-klein
thorsten-klein force-pushed the feat/210-pull-with-patches branch from 21d9c8c to 861646f Compare November 13, 2026 20:48

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant