@@ -571,6 +571,7 @@ static int finish_rebase(struct rebase_options *opts)
571
571
static int move_to_original_branch (struct rebase_options * opts )
572
572
{
573
573
struct strbuf orig_head_reflog = STRBUF_INIT , head_reflog = STRBUF_INIT ;
574
+ struct reset_head_opts ropts = { 0 };
574
575
int ret ;
575
576
576
577
if (!opts -> head_name )
@@ -583,9 +584,11 @@ static int move_to_original_branch(struct rebase_options *opts)
583
584
opts -> head_name , oid_to_hex (& opts -> onto -> object .oid ));
584
585
strbuf_addf (& head_reflog , "rebase finished: returning to %s" ,
585
586
opts -> head_name );
586
- ret = reset_head (the_repository , NULL , opts -> head_name ,
587
- RESET_HEAD_REFS_ONLY ,
588
- orig_head_reflog .buf , head_reflog .buf , NULL );
587
+ ropts .branch = opts -> head_name ;
588
+ ropts .flags = RESET_HEAD_REFS_ONLY ;
589
+ ropts .orig_head_msg = orig_head_reflog .buf ;
590
+ ropts .head_msg = head_reflog .buf ;
591
+ ret = reset_head (the_repository , & ropts );
589
592
590
593
strbuf_release (& orig_head_reflog );
591
594
strbuf_release (& head_reflog );
@@ -669,13 +672,15 @@ static int run_am(struct rebase_options *opts)
669
672
670
673
status = run_command (& format_patch );
671
674
if (status ) {
675
+ struct reset_head_opts ropts = { 0 };
672
676
unlink (rebased_patches );
673
677
free (rebased_patches );
674
678
strvec_clear (& am .args );
675
679
676
- reset_head (the_repository , & opts -> orig_head ,
677
- opts -> head_name , 0 ,
678
- NULL , NULL , DEFAULT_REFLOG_ACTION );
680
+ ropts .oid = & opts -> orig_head ;
681
+ ropts .branch = opts -> head_name ;
682
+ ropts .default_reflog_action = DEFAULT_REFLOG_ACTION ;
683
+ reset_head (the_repository , & ropts );
679
684
error (_ ("\ngit encountered an error while preparing the "
680
685
"patches to replay\n"
681
686
"these revisions:\n"
@@ -814,14 +819,17 @@ static int rebase_config(const char *var, const char *value, void *data)
814
819
static int checkout_up_to_date (struct rebase_options * options )
815
820
{
816
821
struct strbuf buf = STRBUF_INIT ;
822
+ struct reset_head_opts ropts = { 0 };
817
823
int ret = 0 ;
818
824
819
825
strbuf_addf (& buf , "%s: checkout %s" ,
820
826
getenv (GIT_REFLOG_ACTION_ENVIRONMENT ),
821
827
options -> switch_to );
822
- if (reset_head (the_repository , & options -> orig_head ,
823
- options -> head_name , RESET_HEAD_RUN_POST_CHECKOUT_HOOK ,
824
- NULL , buf .buf , NULL ) < 0 )
828
+ ropts .oid = & options -> orig_head ;
829
+ ropts .branch = options -> head_name ;
830
+ ropts .flags = RESET_HEAD_RUN_POST_CHECKOUT_HOOK ;
831
+ ropts .head_msg = buf .buf ;
832
+ if (reset_head (the_repository , & ropts ) < 0 )
825
833
ret = error (_ ("could not switch to %s" ), options -> switch_to );
826
834
strbuf_release (& buf );
827
835
@@ -1033,6 +1041,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1033
1041
int reschedule_failed_exec = -1 ;
1034
1042
int allow_preemptive_ff = 1 ;
1035
1043
int preserve_merges_selected = 0 ;
1044
+ struct reset_head_opts ropts = { 0 };
1036
1045
struct option builtin_rebase_options [] = {
1037
1046
OPT_STRING (0 , "onto" , & options .onto_name ,
1038
1047
N_ ("revision" ),
@@ -1270,9 +1279,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1270
1279
1271
1280
rerere_clear (the_repository , & merge_rr );
1272
1281
string_list_clear (& merge_rr , 1 );
1273
-
1274
- if (reset_head (the_repository , NULL , NULL , RESET_HEAD_HARD ,
1275
- NULL , NULL , NULL ) < 0 )
1282
+ ropts .flags = RESET_HEAD_HARD ;
1283
+ if (reset_head (the_repository , & ropts ) < 0 )
1276
1284
die (_ ("could not discard worktree changes" ));
1277
1285
remove_branch_state (the_repository , 0 );
1278
1286
if (read_basic_state (& options ))
@@ -1289,9 +1297,11 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1289
1297
1290
1298
if (read_basic_state (& options ))
1291
1299
exit (1 );
1292
- if (reset_head (the_repository , & options .orig_head ,
1293
- options .head_name , RESET_HEAD_HARD ,
1294
- NULL , NULL , DEFAULT_REFLOG_ACTION ) < 0 )
1300
+ ropts .oid = & options .orig_head ;
1301
+ ropts .branch = options .head_name ;
1302
+ ropts .flags = RESET_HEAD_HARD ;
1303
+ ropts .default_reflog_action = DEFAULT_REFLOG_ACTION ;
1304
+ if (reset_head (the_repository , & ropts ) < 0 )
1295
1305
die (_ ("could not move back to %s" ),
1296
1306
oid_to_hex (& options .orig_head ));
1297
1307
remove_branch_state (the_repository , 0 );
@@ -1758,10 +1768,12 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1758
1768
1759
1769
strbuf_addf (& msg , "%s: checkout %s" ,
1760
1770
getenv (GIT_REFLOG_ACTION_ENVIRONMENT ), options .onto_name );
1761
- if (reset_head (the_repository , & options .onto -> object .oid , NULL ,
1762
- RESET_HEAD_DETACH | RESET_ORIG_HEAD |
1763
- RESET_HEAD_RUN_POST_CHECKOUT_HOOK ,
1764
- NULL , msg .buf , DEFAULT_REFLOG_ACTION ))
1771
+ ropts .oid = & options .onto -> object .oid ;
1772
+ ropts .flags = RESET_HEAD_DETACH | RESET_ORIG_HEAD |
1773
+ RESET_HEAD_RUN_POST_CHECKOUT_HOOK ;
1774
+ ropts .head_msg = msg .buf ;
1775
+ ropts .default_reflog_action = DEFAULT_REFLOG_ACTION ;
1776
+ if (reset_head (the_repository , & ropts ))
1765
1777
die (_ ("Could not detach HEAD" ));
1766
1778
strbuf_release (& msg );
1767
1779
@@ -1776,8 +1788,11 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1776
1788
strbuf_addf (& msg , "rebase finished: %s onto %s" ,
1777
1789
options .head_name ? options .head_name : "detached HEAD" ,
1778
1790
oid_to_hex (& options .onto -> object .oid ));
1779
- reset_head (the_repository , NULL , options .head_name ,
1780
- RESET_HEAD_REFS_ONLY , NULL , msg .buf , NULL );
1791
+ memset (& ropts , 0 , sizeof (ropts ));
1792
+ ropts .branch = options .head_name ;
1793
+ ropts .flags = RESET_HEAD_REFS_ONLY ;
1794
+ ropts .head_msg = msg .buf ;
1795
+ reset_head (the_repository , & ropts );
1781
1796
strbuf_release (& msg );
1782
1797
ret = finish_rebase (& options );
1783
1798
goto cleanup ;
0 commit comments