Skip to content

Autostash local changes by default, rolling back on conflict - #11

Merged
kova1max merged 1 commit into
mainfrom
feat/autostash
Sep 24, 2026
Merged

kova1max merged 1 commit into
mainfrom
feat/autostash

Conversation

@kova1max

Copy link
Copy Markdown
Owner

When local edits or untracked files are in the way of an update, pullr now stashes them, updates, and re-applies them on top:

+ web (main, 1 new commit, local changes reapplied)
~ docs (main, 2 commits held back because local changes conflict with them)

Unlike git merge --autostash, a conflict never leaves conflict markers behind. If re-applying isn't clean, pullr resets to the starting commit, removes any untracked files the failed apply wrote, and re-applies the stash onto its original base. The repository ends exactly as it was (same commit, same files, same staged and unstaged changes, no stash entry left) and is reported as dirty.

  • Only repositories whose changes actually block the update are stashed; unrelated edits are never touched.
  • Works with --rebase (a diverged branch with local edits is rebased and the edits re-applied).
  • --dry-run shows local changes to autostash.
  • The user's own stash entries are never touched: pullr drops its entry by commit, since git stash drop <sha> isn't supported.
  • --no-autostash restores the previous behaviour; --autostash is accepted for scripts that want to be explicit.

7 new tests, including a check that a conflict leaves no markers, no stash and an identical git status. I also checked that removing the rollback makes those tests fail. 45 pass on bash 5 and 3.2.

When local changes are in the way of an update, stash them (tracked and
untracked), update, and re-apply them with their staged state. If
re-applying is not clean, reset to the starting commit, clear any untracked
files the failed apply wrote, and re-apply the stash onto its original base,
so the repository ends exactly as it was and is reported as dirty. The stash
is dropped only once its changes are back, and is looked up by commit so a
user's own stash entries are never touched. --no-autostash keeps the old
behaviour.
@kova1max kova1max added the enhancement New feature or request label Sep 24, 2026
@kova1max
kova1max merged commit d544bba into main Sep 24, 2026
4 checks passed
@kova1max
kova1max deleted the feat/autostash branch September 24, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant