Commit dc23839
committed
rebase -i: reword empty commit after fast-forward
When rebasing git 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 when we fast-forward because we know that the
commit cannot have become empty due to the rebase as we are reusing an
existing commit object. It is also safe when we do not fast-forward
because the call to run_git_commit() that created the commit we're
rewording would have failed if the commit had become empty.
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]>1 parent 58b5801 commit dc23839
File tree
3 files changed
+36
-3
lines changed- t
3 files changed
+36
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2510 | 2510 | | |
2511 | 2511 | | |
2512 | 2512 | | |
2513 | | - | |
2514 | | - | |
2515 | | - | |
| 2513 | + | |
| 2514 | + | |
2516 | 2515 | | |
2517 | 2516 | | |
2518 | 2517 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
791 | 791 | | |
792 | 792 | | |
793 | 793 | | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
794 | 808 | | |
795 | 809 | | |
796 | 810 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
610 | 610 | | |
611 | 611 | | |
612 | 612 | | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
613 | 633 | | |
0 commit comments