@@ -3724,10 +3724,11 @@ static const char *reflog_message(struct replay_opts *opts,
3724
3724
{
3725
3725
va_list ap ;
3726
3726
static struct strbuf buf = STRBUF_INIT ;
3727
+ char * reflog_action = getenv (GIT_REFLOG_ACTION );
3727
3728
3728
3729
va_start (ap , fmt );
3729
3730
strbuf_reset (& buf );
3730
- strbuf_addstr (& buf , action_name (opts ));
3731
+ strbuf_addstr (& buf , reflog_action ? reflog_action : action_name (opts ));
3731
3732
if (sub_action )
3732
3733
strbuf_addf (& buf , " (%s)" , sub_action );
3733
3734
if (fmt ) {
@@ -3815,8 +3816,11 @@ static int pick_commits(struct repository *r,
3815
3816
struct replay_opts * opts )
3816
3817
{
3817
3818
int res = 0 , reschedule = 0 ;
3819
+ char * prev_reflog_action ;
3818
3820
3821
+ /* Note that 0 for 3rd parameter of setenv means set only if not set */
3819
3822
setenv (GIT_REFLOG_ACTION , action_name (opts ), 0 );
3823
+ prev_reflog_action = xstrdup (getenv (GIT_REFLOG_ACTION ));
3820
3824
if (opts -> allow_ff )
3821
3825
assert (!(opts -> signoff || opts -> no_commit ||
3822
3826
opts -> record_origin || opts -> edit ));
@@ -3861,12 +3865,14 @@ static int pick_commits(struct repository *r,
3861
3865
}
3862
3866
if (item -> command <= TODO_SQUASH ) {
3863
3867
if (is_rebase_i (opts ))
3864
- setenv (" GIT_REFLOG_ACTION" , reflog_message (opts ,
3868
+ setenv (GIT_REFLOG_ACTION , reflog_message (opts ,
3865
3869
command_to_string (item -> command ), NULL ),
3866
3870
1 );
3867
3871
res = do_pick_commit (r , item -> command , item -> commit ,
3868
3872
opts , is_final_fixup (todo_list ),
3869
3873
& check_todo );
3874
+ if (is_rebase_i (opts ))
3875
+ setenv (GIT_REFLOG_ACTION , prev_reflog_action , 1 );
3870
3876
if (is_rebase_i (opts ) && res < 0 ) {
3871
3877
/* Reschedule */
3872
3878
advise (_ (rescheduled_advice ),
0 commit comments