Limit `git autofixup` to specified files and/or to staged changes
Opened this issue · 2 comments
intelfx commented
It would be nice if it was possible to limit git-autofixup
to changes in specific files, e. g.:
git autofixup <base> -- /path/to/file /path/to/something/else
Alternatively (might be even more useful), accept something like
--staged
to only operate on already staged changes (mirroringgit stash --staged
), and--keep-index
for the opposite (mirroringgit stash --keep-index
).
krobelus commented
On Sun, Feb 25, 2024 at 04:27:08AM -0800, Ivan Shapovalov wrote:
It would be nice if it was possible to limit `git-autofixup` to changes in specific files, e. g.:
```
git autofixup <base> -- /path/to/file /path/to/something/else
```
Good idea. It is probably doable to support arbitrary pathspecs by forwarding them to Git diff.
Alternatively (might be even more useful), accept something like
- `--staged` to only operate on _already staged_ changes (mirroring `git stash --staged`), and
that's already the default in the latest release - if you have anything
staged, stage everything. It is indeed very useful.
- `--keep-index` for the opposite (mirroring `git stash --keep-index`).
interesting, yeah. Would probably need to temporarily swap the index file but we already do that elsewhere.
torbiak commented
Regarding --keep-index
: we could get conflicts when trying to restore the original index after doing git-autofixup for the working tree, right?
If I'm understanding correctly, it'd be roughly equivalent to this:
git checkout -b tmp
git commit -m 'saved index'
git checkout topic
git-autofixup
git checkout tmp
git rebase topic
git reset @^
But what if rebasing the saved index onto the changed topic branch fails?