git-fixup
git-fixup copied to clipboard
Respect pre-commit hooks
This is a great tool that I had waiting to have for last couple of years. Thanks!
What I currently see is the following:
- I make a change with a formatting error
- I do
git add -p
to stage it - I do
git fixup
to fix it up -
git fixup
tries to create a commit, but that fails due to my pre-commit hooks -
git fixup
still calls interactive rebase, which now shows an editor with the rebase instructions; but there is no fixup commit here - I save the interactive rebase editor, the no-op rebase happens, and I'm back. I now go and commit the formatting corrections.
It would be great if git-fixup would stop at 4. if the pre-commit hooks fail, and doesn't run the interactive rebase anyways.
Yeah, that makes perfect sense to me and should be pretty easy to fix.
A pull request is much appreciated, or I'll try to have a look sometime this weekend
I don't see the behavior described
> git fixup 72b2e92867ffac015b0e16805c35b14a3a4fbc8a --rebase
Dummy always reject pre-commit
e71d3a7cb4a0ac43f96d55de5ba5c219311d0137
error: cannot rebase: Your index contains uncommitted changes.
error: Please commit or stash them.
Trying to call rebase after failing to commit is probably still a bug though. Could you share some more details of your setup? git versions, anything special going in the pre-commit?
Hey, thanks for looking into it. I use pre-commit which checks/formats files. My flow is like
echo "extra lines" > existing.file
git add existing.file
git fixup
# pre-commit checks run. They format the file and fail with exit code 1. Now `existing.file` is both in the index (with my manual changes) and there are additional unstaged changes in the work tree from the formatting.
I think I don't get the error from the rebase because I use the git config rebase.autoStash = true
I have that config setting too but I still see git rebase refusing to run with staged changes. Anyway the fix should be pretty easy, could you hive the version in #70 a go?