Limit `git autofixup` to specified files and/or to staged changes
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
--stagedto only operate on already staged changes (mirroringgit stash --staged), and--keep-indexfor the opposite (mirroringgit stash --keep-index).
On Sun, Feb 25, 2024 at 04:27:08AM -0800, Ivan Shapovalov wrote:
It would be nice if it was possible to limit
git-autofixupto 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
--stagedto only operate on already staged changes (mirroringgit 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-indexfor the opposite (mirroringgit stash --keep-index).
interesting, yeah. Would probably need to temporarily swap the index file but we already do that elsewhere.
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?