-
Notifications
You must be signed in to change notification settings - Fork 141
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
rebase -i: reword empty commit after fast-forward #1860
base: master
Are you sure you want to change the base?
rebase -i: reword empty commit after fast-forward #1860
Conversation
dc23839
to
06de47a
Compare
/submit |
Submitted as [email protected] To fetch this version into
To fetch this version to local tag
|
On the Git mailing list, Junio C Hamano wrote (reply to this): "Phillip Wood via GitGitGadget" <[email protected]> writes:
> @@ -2510,9 +2510,8 @@ static int do_pick_commit(struct repository *r,
> *check_todo = !!(flags & EDIT_MSG);
> if (!res && reword) {
> fast_forward_edit:
> - res = run_git_commit(NULL, opts, EDIT_MSG |
> - VERIFY_MSG | AMEND_MSG |
> - (flags & ALLOW_EMPTY));
> + flags = EDIT_MSG | VERIFY_MSG | AMEND_MSG | ALLOW_EMPTY;
> + res = run_git_commit(NULL, opts, flags);
> *check_todo = 1;
> }
> }
I am perfectly OK with the idea of run_git_commit() with the fixed
set of flags bits, ignoring everything the preceding code did to
incrementally compute it before the control reaches this point. In
the fast-forward-edit scenario in which the control reaches this
point, the flag bits like CREATE_ROOT_COMMIT the earlier steps may
have added to "flags".
But the way "flags" variable is used elsewhere in this function is
"we check how this 'pick' step needs to work, and compute bits to
pass when we eventually call run_git_commit() or do_commit(),
incrementally", so making an unconditional assignment to it looked
a bit surprising. At least the unconditional assignment deserves
a bit of comment explaining why other bits do not matter and these
bits are what we want to use here.
Thanks. |
This patch series was integrated into seen via git@4826972. |
This branch is now known as |
This patch series was integrated into seen via git@e854fdd. |
06de47a
to
f7675fc
Compare
This patch series was integrated into seen via git@7a7f5d0. |
There was a status update in the "New Topics" section about the branch "git rebase -i" failed to allow rewording an empty commit that has been fast-forwarded. Expecting a reroll. cf. <[email protected]> source: <[email protected]> |
This patch series was integrated into seen via git@d13b7aa. |
There was a status update in the "Cooking" section about the branch "git rebase -i" failed to allow rewording an empty commit that has been fast-forwarded. Expecting a reroll. cf. <[email protected]> source: <[email protected]> |
When rebase rewords a commit it picks the commit and then runs "git commit --amend" to reword it. When the commit is picked the sequencer tries to reuse existing commits by fast-forwarding if the parents are unchanged. Rewording an empty commit that has been fast-forwarded fails because "git commit --amend" is called without "--allow-empty". This happens because when a commit is fast-forwarded the logic that checks whether we should pass "--allow-empty" is skipped. Fix this by always passing "--allow-empty" when rewording a commit. This is safe because we are amending a commit that has already been picked so if it had become empty when it was picked we'd have already returned an error. As "git commit" will happily create empty merge commits without "--allow-empty" we do not need to pass that flag when rewording merge commits. Signed-off-by: Phillip Wood <[email protected]>
f7675fc
to
826edd3
Compare
/submit |
Submitted as [email protected] To fetch this version into
To fetch this version to local tag
|
On the Git mailing list, Junio C Hamano wrote (reply to this): "Phillip Wood via GitGitGadget" <[email protected]> writes:
> As "git commit" will happily create empty merge commits without
> "--allow-empty" we do not need to pass that flag when rewording merge
> commits.
Thanks, will queue. Let's mark it for 'next'. |
This patch series was integrated into seen via git@d40271f. |
This patch series was integrated into seen via git@cd33264. |
Thanks to Junio for his comments on V1. I've added a comment explaining why we use a fixed set of commits flags as he suggested.
Cc: Junio C Hamano [email protected]