-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use fixup commits during code review #53566
Comments
This seems overly complicated IMO. If people stick to interactively rebasing against the same base as the initial/last push on a given PR, the GH UI works fine for listing the actual changes compared to the previous revision of the PR. If a rebase against upstream |
I think you're right about deliberately avoiding/isolating rebases. We should probably do that anyway. You might be right about this being overly complicated. It seems simple to me, because I'm used to Gerrit, and this somewhat replicates the Gerrit review flow. (Single-commit diffs, one review cycle at a time.) I created the test PR above so that people could try it and see how it feels. If you ask me to change something, I'll make a fix-up, and you can take a look. |
Process WG: no consensus
|
... as discussed already in #39194 and many others before. This fixup workflow seems very popular on Github, maybe the most popular? It is documented on github and works really well as long as the intention is to squash all commits into a SINGLE final commit. The web UI has the button to do exactly that and "atomically" merge at the same time: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/about-pull-request-merges
Single final commit = no force push and no command line needed, no accidental rebase possible, no fixup->commit mapping ambiguity, no awkward interval between squash and merge where reviewers have to come and approve again and potentially request last minutes changes, etc. #52731 (comment) Fixups spread over multiple commits in the same PR is technically possible but one order of magnitude more complicated and much less charted territory. One "creative" solution that has apparently been explored to review series is to spread each logical change (and final single commit) in a separate per pull request and then somehow link pull requests to one another: isaacs/github#959.
Maybe less of a "finite" resource but submitters will also have a hard time learning new tricks. Even "Github natives" will wonder why and when they should fixup versus amend: depending on the PR "size", number of commits, subsystem preference?
Seconding comments above: promoting a general Just for fun: Rebase Considered Harmful (he's wrong)
Only when they're not too close in time. |
It might work for small PRs, but it'll become absolute madness with large PRs. I can easily imagine over 100 fixup commits in large PR and this is going to be unmanageable.
I think https://sapling-scm.com/docs/addons/reviewstack/ is more similar to Gerrit than the proposed fixup commits.
Even if you separate the pushes, the GitHub compare becomes useless because it seems to work only for the last push. If the author does multiple pushes in between one of the reviewers look at the PR - the diff feature is no longer working for the reviewer. That is, the reviewer won't see the changes since he last reviewed, but at most the changes in last force push. My workaround to GitHub review system is:
Definitely. Git history with a lot of fixup commits is not fun at all to navigate/bisect. |
I'm all for this. Maybe it will help enough that we won't feel like changing anything else. If it doesn't, at least we'll have a clearer idea of how much pain remains. As @galak noted yesterday, fixups would be a new process that people would have to learn.
Wow, that is a sad thread. But maybe we can try some of the third-party hacks that people list in there. |
Process WG:
@alevkoy please reopen if we misunderstood anything |
There is now a Google Summer of Code project idea to add |
Introduction
During code review, when PR authors make changes, they should upload fix-up commits containing those changes instead of changing the existing commits and force-pushing. This will streamline reviewer tasks. Once the review is nominally complete, the reviewer should perform a squash rebase and force-push as usual for merging.
Problem description
Code reviews may go through several rounds of review, in which the author uploads new code to address previous comments, typically by amending their previous commits. Due to limitations of GitHub, it may not be immediately obvious to reviewers which parts of the uploaded code are new to them, so they need to review any files that have changed, usually looking at the entire delta of the PR again. This is particularly burdensome on large PRs with several active reviewers.
Proposed change
Authors should avoid pushing amended commits during code review. Instead, they should push fix-up commits addressing reviewer comments. When reviewers are satisfied, authors should squash in the fix-up commits and force-push prior to final approval and merging.
Detailed RFC
Background
Git's interactive rebase supports
squash
andfixup
operations on commits.squash
combines two or more commits into one and combines their commit messages into one.fixup
combines the commits into one but only retains the first commit message. "Fix-up commits" or "squash commits" are commits that a user intends tofixup
orsquash
later, typically indicating the base commit onto which the new commit will be fixed up or squashed, e.g.Proposed change (Detailed)
git rebase --keep-base
.Dependencies
I think the blast radius of this is pretty minimal. We could try it on a few PRs and see how it goes before making any policy changes.
Concerns and Unresolved Questions
Git has facilities to automate
fixup
andsquash
operations like so:These operations create and rely on commit headlines with the format
fixup: Previous headline
orsquash: Previous headline
.Authors could use this feature to automate some of the steps. However, this would get in the way of using
--autosquash
locally on that PR for their own purposes. I think it should be fine if authors useFIXUP: Previous message
or similar for the fix-up commits they want to upload for review. The reviewer experience should be the same either way.This process is probably overkill for small PRs of a few lines that are trivial to re-review. I think fix-ups should be recommended for large PRs.
Alternatives
Habitually not rebasing
This proposal primarily addresses weaknesses of GitHub's UI for before-after comparison of force pushes. One annoying behavior is that it will show diffs for every file in the repository, not just those changed by the commits. This makes it basically unusable if the author has rebased the PR. Authors could avoid this by only using
git rebase --keep-base
during the review. Reviewers would then be able to use GitHub to see just the relatively small changes that the author made in response to review comments.However, this would retain other weaknesses of the GitHub push comparison UI:
The text was updated successfully, but these errors were encountered: