@@ -224,11 +224,6 @@ struct replay_ctx {
224
224
* current chain.
225
225
*/
226
226
struct strbuf current_fixups ;
227
- /*
228
- * Stores the reflog message that will be used when creating a
229
- * commit. Points to a static buffer and should not be free()'d.
230
- */
231
- const char * reflog_message ;
232
227
/*
233
228
* The number of completed fixup and squash commands in the
234
229
* current chain.
@@ -1133,10 +1128,10 @@ static int run_command_silent_on_success(struct child_process *cmd)
1133
1128
* author metadata.
1134
1129
*/
1135
1130
static int run_git_commit (const char * defmsg ,
1131
+ const char * reflog_action ,
1136
1132
struct replay_opts * opts ,
1137
1133
unsigned int flags )
1138
1134
{
1139
- struct replay_ctx * ctx = opts -> ctx ;
1140
1135
struct child_process cmd = CHILD_PROCESS_INIT ;
1141
1136
1142
1137
if ((flags & CLEANUP_MSG ) && (flags & VERBATIM_MSG ))
@@ -1154,7 +1149,7 @@ static int run_git_commit(const char *defmsg,
1154
1149
gpg_opt , gpg_opt );
1155
1150
}
1156
1151
1157
- strvec_pushf (& cmd .env , GIT_REFLOG_ACTION "=%s" , ctx -> reflog_message );
1152
+ strvec_pushf (& cmd .env , GIT_REFLOG_ACTION "=%s" , reflog_action );
1158
1153
1159
1154
if (opts -> committer_date_is_author_date )
1160
1155
strvec_pushf (& cmd .env , "GIT_COMMITTER_DATE=%s" ,
@@ -1538,10 +1533,10 @@ static int parse_head(struct repository *r, struct commit **head)
1538
1533
*/
1539
1534
static int try_to_commit (struct repository * r ,
1540
1535
struct strbuf * msg , const char * author ,
1536
+ const char * reflog_action ,
1541
1537
struct replay_opts * opts , unsigned int flags ,
1542
1538
struct object_id * oid )
1543
1539
{
1544
- struct replay_ctx * ctx = opts -> ctx ;
1545
1540
struct object_id tree ;
1546
1541
struct commit * current_head = NULL ;
1547
1542
struct commit_list * parents = NULL ;
@@ -1703,7 +1698,7 @@ static int try_to_commit(struct repository *r,
1703
1698
goto out ;
1704
1699
}
1705
1700
1706
- if (update_head_with_reflog (current_head , oid , ctx -> reflog_message ,
1701
+ if (update_head_with_reflog (current_head , oid , reflog_action ,
1707
1702
msg , & err )) {
1708
1703
res = error ("%s" , err .buf );
1709
1704
goto out ;
@@ -1734,6 +1729,7 @@ static int write_rebase_head(struct object_id *oid)
1734
1729
1735
1730
static int do_commit (struct repository * r ,
1736
1731
const char * msg_file , const char * author ,
1732
+ const char * reflog_action ,
1737
1733
struct replay_opts * opts , unsigned int flags ,
1738
1734
struct object_id * oid )
1739
1735
{
@@ -1749,7 +1745,7 @@ static int do_commit(struct repository *r,
1749
1745
msg_file );
1750
1746
1751
1747
res = try_to_commit (r , msg_file ? & sb : NULL ,
1752
- author , opts , flags , & oid );
1748
+ author , reflog_action , opts , flags , & oid );
1753
1749
strbuf_release (& sb );
1754
1750
if (!res ) {
1755
1751
refs_delete_ref (get_main_ref_store (r ), "" ,
@@ -1765,7 +1761,7 @@ static int do_commit(struct repository *r,
1765
1761
if (is_rebase_i (opts ) && oid )
1766
1762
if (write_rebase_head (oid ))
1767
1763
return -1 ;
1768
- return run_git_commit (msg_file , opts , flags );
1764
+ return run_git_commit (msg_file , reflog_action , opts , flags );
1769
1765
}
1770
1766
1771
1767
return res ;
@@ -2278,13 +2274,19 @@ static int do_pick_commit(struct repository *r,
2278
2274
const char * msg_file = should_edit (opts ) ? NULL : git_path_merge_msg (r );
2279
2275
struct object_id head ;
2280
2276
struct commit * base , * next , * parent ;
2281
- const char * base_label , * next_label ;
2277
+ const char * base_label , * next_label , * reflog_action ;
2282
2278
char * author = NULL ;
2283
2279
struct commit_message msg = { NULL , NULL , NULL , NULL };
2284
2280
int res , unborn = 0 , reword = 0 , allow , drop_commit ;
2285
2281
enum todo_command command = item -> command ;
2286
2282
struct commit * commit = item -> commit ;
2287
2283
2284
+ if (is_rebase_i (opts ))
2285
+ reflog_action = reflog_message (
2286
+ opts , command_to_string (item -> command ), NULL );
2287
+ else
2288
+ reflog_action = sequencer_reflog_action (opts );
2289
+
2288
2290
if (opts -> no_commit ) {
2289
2291
/*
2290
2292
* We do not intend to commit immediately. We just want to
@@ -2536,14 +2538,15 @@ static int do_pick_commit(struct repository *r,
2536
2538
} /* else allow == 0 and there's nothing special to do */
2537
2539
if (!opts -> no_commit && !drop_commit ) {
2538
2540
if (author || command == TODO_REVERT || (flags & AMEND_MSG ))
2539
- res = do_commit (r , msg_file , author , opts , flags ,
2541
+ res = do_commit (r , msg_file , author , reflog_action ,
2542
+ opts , flags ,
2540
2543
commit ? & commit -> object .oid : NULL );
2541
2544
else
2542
2545
res = error (_ ("unable to parse commit author" ));
2543
2546
* check_todo = !!(flags & EDIT_MSG );
2544
2547
if (!res && reword ) {
2545
2548
fast_forward_edit :
2546
- res = run_git_commit (NULL , opts , EDIT_MSG |
2549
+ res = run_git_commit (NULL , reflog_action , opts , EDIT_MSG |
2547
2550
VERIFY_MSG | AMEND_MSG |
2548
2551
(flags & ALLOW_EMPTY ));
2549
2552
* check_todo = 1 ;
@@ -4092,6 +4095,7 @@ static int do_merge(struct repository *r,
4092
4095
int merge_arg_len , oneline_offset , can_fast_forward , ret , k ;
4093
4096
static struct lock_file lock ;
4094
4097
const char * p ;
4098
+ const char * reflog_action = reflog_message (opts , "merge" , NULL );
4095
4099
4096
4100
if (repo_hold_locked_index (r , & lock , LOCK_REPORT_ON_ERROR ) < 0 ) {
4097
4101
ret = -1 ;
@@ -4370,14 +4374,15 @@ static int do_merge(struct repository *r,
4370
4374
* value (a negative one would indicate that the `merge`
4371
4375
* command needs to be rescheduled).
4372
4376
*/
4373
- ret = !!run_git_commit (git_path_merge_msg (r ), opts ,
4374
- run_commit_flags );
4377
+ ret = !!run_git_commit (git_path_merge_msg (r ), reflog_action ,
4378
+ opts , run_commit_flags );
4375
4379
4376
4380
if (!ret && flags & TODO_EDIT_MERGE_MSG ) {
4377
4381
fast_forward_edit :
4378
4382
* check_todo = 1 ;
4379
4383
run_commit_flags |= AMEND_MSG | EDIT_MSG | VERIFY_MSG ;
4380
- ret = !!run_git_commit (NULL , opts , run_commit_flags );
4384
+ ret = !!run_git_commit (NULL , reflog_action , opts ,
4385
+ run_commit_flags );
4381
4386
}
4382
4387
4383
4388
@@ -4892,13 +4897,9 @@ static int pick_one_commit(struct repository *r,
4892
4897
struct replay_opts * opts ,
4893
4898
int * check_todo , int * reschedule )
4894
4899
{
4895
- struct replay_ctx * ctx = opts -> ctx ;
4896
4900
int res ;
4897
4901
struct todo_item * item = todo_list -> items + todo_list -> current ;
4898
4902
const char * arg = todo_item_get_arg (todo_list , item );
4899
- if (is_rebase_i (opts ))
4900
- ctx -> reflog_message = reflog_message (
4901
- opts , command_to_string (item -> command ), NULL );
4902
4903
4903
4904
res = do_pick_commit (r , item , opts , is_final_fixup (todo_list ),
4904
4905
check_todo );
@@ -4957,7 +4958,6 @@ static int pick_commits(struct repository *r,
4957
4958
struct replay_ctx * ctx = opts -> ctx ;
4958
4959
int res = 0 , reschedule = 0 ;
4959
4960
4960
- ctx -> reflog_message = sequencer_reflog_action (opts );
4961
4961
if (opts -> allow_ff )
4962
4962
assert (!(opts -> signoff || opts -> no_commit ||
4963
4963
opts -> record_origin || should_edit (opts ) ||
@@ -5218,6 +5218,7 @@ static int commit_staged_changes(struct repository *r,
5218
5218
unsigned int flags = ALLOW_EMPTY | EDIT_MSG ;
5219
5219
unsigned int final_fixup = 0 , is_clean ;
5220
5220
struct strbuf rev = STRBUF_INIT ;
5221
+ const char * reflog_action = reflog_message (opts , "continue" , NULL );
5221
5222
int ret ;
5222
5223
5223
5224
if (has_unstaged_changes (r , 1 )) {
@@ -5380,7 +5381,7 @@ static int commit_staged_changes(struct repository *r,
5380
5381
}
5381
5382
5382
5383
if (run_git_commit (final_fixup ? NULL : rebase_path_message (),
5383
- opts , flags )) {
5384
+ reflog_action , opts , flags )) {
5384
5385
ret = error (_ ("could not commit staged changes." ));
5385
5386
goto out ;
5386
5387
}
@@ -5412,7 +5413,6 @@ static int commit_staged_changes(struct repository *r,
5412
5413
5413
5414
int sequencer_continue (struct repository * r , struct replay_opts * opts )
5414
5415
{
5415
- struct replay_ctx * ctx = opts -> ctx ;
5416
5416
struct todo_list todo_list = TODO_LIST_INIT ;
5417
5417
int res ;
5418
5418
@@ -5433,7 +5433,6 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts)
5433
5433
unlink (rebase_path_dropped ());
5434
5434
}
5435
5435
5436
- ctx -> reflog_message = reflog_message (opts , "continue" , NULL );
5437
5436
if (commit_staged_changes (r , opts , & todo_list )) {
5438
5437
res = -1 ;
5439
5438
goto release_todo_list ;
@@ -5485,7 +5484,6 @@ static int single_pick(struct repository *r,
5485
5484
TODO_PICK : TODO_REVERT ;
5486
5485
item .commit = cmit ;
5487
5486
5488
- opts -> ctx -> reflog_message = sequencer_reflog_action (opts );
5489
5487
return do_pick_commit (r , & item , opts , 0 , & check_todo );
5490
5488
}
5491
5489
0 commit comments