@@ -779,6 +779,7 @@ static void add_var(struct strbuf *buf, const char *name, const char *value)
779
779
static int move_to_original_branch (struct rebase_options * opts )
780
780
{
781
781
struct strbuf orig_head_reflog = STRBUF_INIT , head_reflog = STRBUF_INIT ;
782
+ struct reset_head_opts ropts = { 0 };
782
783
int ret ;
783
784
784
785
if (!opts -> head_name )
@@ -791,9 +792,11 @@ static int move_to_original_branch(struct rebase_options *opts)
791
792
opts -> head_name , oid_to_hex (& opts -> onto -> object .oid ));
792
793
strbuf_addf (& head_reflog , "rebase finished: returning to %s" ,
793
794
opts -> head_name );
794
- ret = reset_head (the_repository , NULL , opts -> head_name ,
795
- RESET_HEAD_REFS_ONLY ,
796
- orig_head_reflog .buf , head_reflog .buf , NULL );
795
+ ropts .branch = opts -> head_name ;
796
+ ropts .flags = RESET_HEAD_REFS_ONLY ;
797
+ ropts .orig_head_msg = orig_head_reflog .buf ;
798
+ ropts .head_msg = head_reflog .buf ;
799
+ ret = reset_head (the_repository , & ropts );
797
800
798
801
strbuf_release (& orig_head_reflog );
799
802
strbuf_release (& head_reflog );
@@ -877,13 +880,15 @@ static int run_am(struct rebase_options *opts)
877
880
878
881
status = run_command (& format_patch );
879
882
if (status ) {
883
+ struct reset_head_opts ropts = { 0 };
880
884
unlink (rebased_patches );
881
885
free (rebased_patches );
882
886
strvec_clear (& am .args );
883
887
884
- reset_head (the_repository , & opts -> orig_head ,
885
- opts -> head_name , 0 ,
886
- NULL , NULL , DEFAULT_REFLOG_ACTION );
888
+ ropts .oid = & opts -> orig_head ;
889
+ ropts .branch = opts -> head_name ;
890
+ ropts .default_reflog_action = DEFAULT_REFLOG_ACTION ;
891
+ reset_head (the_repository , & ropts );
887
892
error (_ ("\ngit encountered an error while preparing the "
888
893
"patches to replay\n"
889
894
"these revisions:\n"
@@ -1103,14 +1108,17 @@ static int rebase_config(const char *var, const char *value, void *data)
1103
1108
static int checkout_up_to_date (struct rebase_options * options )
1104
1109
{
1105
1110
struct strbuf buf = STRBUF_INIT ;
1111
+ struct reset_head_opts ropts = { 0 };
1106
1112
int ret = 0 ;
1107
1113
1108
1114
strbuf_addf (& buf , "%s: checkout %s" ,
1109
1115
getenv (GIT_REFLOG_ACTION_ENVIRONMENT ),
1110
1116
options -> switch_to );
1111
- if (reset_head (the_repository , & options -> orig_head ,
1112
- options -> head_name , RESET_HEAD_RUN_POST_CHECKOUT_HOOK ,
1113
- NULL , buf .buf , NULL ) < 0 )
1117
+ ropts .oid = & options -> orig_head ;
1118
+ ropts .branch = options -> head_name ;
1119
+ ropts .flags = RESET_HEAD_RUN_POST_CHECKOUT_HOOK ;
1120
+ ropts .head_msg = buf .buf ;
1121
+ if (reset_head (the_repository , & ropts ) < 0 )
1114
1122
ret = error (_ ("could not switch to %s" ), options -> switch_to );
1115
1123
strbuf_release (& buf );
1116
1124
@@ -1321,6 +1329,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1321
1329
char * squash_onto_name = NULL ;
1322
1330
int reschedule_failed_exec = -1 ;
1323
1331
int allow_preemptive_ff = 1 ;
1332
+ struct reset_head_opts ropts = { 0 };
1324
1333
struct option builtin_rebase_options [] = {
1325
1334
OPT_STRING (0 , "onto" , & options .onto_name ,
1326
1335
N_ ("revision" ),
@@ -1560,9 +1569,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1560
1569
1561
1570
rerere_clear (the_repository , & merge_rr );
1562
1571
string_list_clear (& merge_rr , 1 );
1563
-
1564
- if (reset_head (the_repository , NULL , NULL , RESET_HEAD_HARD ,
1565
- NULL , NULL , NULL ) < 0 )
1572
+ ropts .flags = RESET_HEAD_HARD ;
1573
+ if (reset_head (the_repository , & ropts ) < 0 )
1566
1574
die (_ ("could not discard worktree changes" ));
1567
1575
remove_branch_state (the_repository , 0 );
1568
1576
if (read_basic_state (& options ))
@@ -1579,9 +1587,11 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1579
1587
1580
1588
if (read_basic_state (& options ))
1581
1589
exit (1 );
1582
- if (reset_head (the_repository , & options .orig_head ,
1583
- options .head_name , RESET_HEAD_HARD ,
1584
- NULL , NULL , DEFAULT_REFLOG_ACTION ) < 0 )
1590
+ ropts .oid = & options .orig_head ;
1591
+ ropts .branch = options .head_name ;
1592
+ ropts .flags = RESET_HEAD_HARD ;
1593
+ ropts .default_reflog_action = DEFAULT_REFLOG_ACTION ;
1594
+ if (reset_head (the_repository , & ropts ) < 0 )
1585
1595
die (_ ("could not move back to %s" ),
1586
1596
oid_to_hex (& options .orig_head ));
1587
1597
remove_branch_state (the_repository , 0 );
@@ -2068,10 +2078,12 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
2068
2078
2069
2079
strbuf_addf (& msg , "%s: checkout %s" ,
2070
2080
getenv (GIT_REFLOG_ACTION_ENVIRONMENT ), options .onto_name );
2071
- if (reset_head (the_repository , & options .onto -> object .oid , NULL ,
2072
- RESET_HEAD_DETACH | RESET_ORIG_HEAD |
2073
- RESET_HEAD_RUN_POST_CHECKOUT_HOOK ,
2074
- NULL , msg .buf , DEFAULT_REFLOG_ACTION ))
2081
+ ropts .oid = & options .onto -> object .oid ;
2082
+ ropts .flags = RESET_HEAD_DETACH | RESET_ORIG_HEAD |
2083
+ RESET_HEAD_RUN_POST_CHECKOUT_HOOK ;
2084
+ ropts .head_msg = msg .buf ;
2085
+ ropts .default_reflog_action = DEFAULT_REFLOG_ACTION ;
2086
+ if (reset_head (the_repository , & ropts ))
2075
2087
die (_ ("Could not detach HEAD" ));
2076
2088
strbuf_release (& msg );
2077
2089
@@ -2086,8 +2098,11 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
2086
2098
strbuf_addf (& msg , "rebase finished: %s onto %s" ,
2087
2099
options .head_name ? options .head_name : "detached HEAD" ,
2088
2100
oid_to_hex (& options .onto -> object .oid ));
2089
- reset_head (the_repository , NULL , options .head_name ,
2090
- RESET_HEAD_REFS_ONLY , NULL , msg .buf , NULL );
2101
+ memset (& ropts , 0 , sizeof (ropts ));
2102
+ ropts .branch = options .head_name ;
2103
+ ropts .flags = RESET_HEAD_REFS_ONLY ;
2104
+ ropts .head_msg = msg .buf ;
2105
+ reset_head (the_repository , & ropts );
2091
2106
strbuf_release (& msg );
2092
2107
ret = finish_rebase (& options );
2093
2108
goto cleanup ;
0 commit comments