Skip to content

Commit 57a1498

Browse files
phillipwoodgitster
authored andcommitted
rebase --apply: remove duplicated code
Use move_to_original_branch() when reattaching HEAD after a fast-forward rather than open coding a copy of that code. move_to_original_branch() does not call reset_head() if head_name is NULL but there should be no user visible changes even though we currently call reset_head() in that case. The reason for this is that the reset_head() call does not add a message to the reflog because we're not changing the commit that HEAD points to and so lock_ref_for_update() elides the update. When head_name is not NULL then reset_head() behaves like "git symbolic-ref" and so the reflog is updated. Note that the removal of "strbuf_release(&msg)" is safe as there is an identical call just above this hunk which can be seen by viewing the diff with -U6. Signed-off-by: Phillip Wood <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a524c62 commit 57a1498

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

builtin/rebase.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,19 +1811,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
18111811
* If the onto is a proper descendant of the tip of the branch, then
18121812
* we just fast-forwarded.
18131813
*/
1814-
strbuf_reset(&msg);
18151814
if (oideq(&branch_base, &options.orig_head->object.oid)) {
18161815
printf(_("Fast-forwarded %s to %s.\n"),
18171816
branch_name, options.onto_name);
1818-
strbuf_addf(&msg, "rebase finished: %s onto %s",
1819-
options.head_name ? options.head_name : "detached HEAD",
1820-
oid_to_hex(&options.onto->object.oid));
1821-
memset(&ropts, 0, sizeof(ropts));
1822-
ropts.branch = options.head_name;
1823-
ropts.flags = RESET_HEAD_REFS_ONLY;
1824-
ropts.head_msg = msg.buf;
1825-
reset_head(the_repository, &ropts);
1826-
strbuf_release(&msg);
1817+
move_to_original_branch(&options);
18271818
ret = finish_rebase(&options);
18281819
goto cleanup;
18291820
}

0 commit comments

Comments
 (0)