@@ -776,6 +776,23 @@ static void NORETURN error_on_missing_default_upstream(void)
776776 exit (1 );
777777}
778778
779+ static void set_reflog_action (struct rebase_options * options )
780+ {
781+ const char * env ;
782+ struct strbuf buf = STRBUF_INIT ;
783+
784+ if (!is_interactive (options ))
785+ return ;
786+
787+ env = getenv (GIT_REFLOG_ACTION_ENVIRONMENT );
788+ if (env && strcmp ("rebase" , env ))
789+ return ; /* only override it if it is "rebase" */
790+
791+ strbuf_addf (& buf , "rebase -i (%s)" , options -> action );
792+ setenv (GIT_REFLOG_ACTION_ENVIRONMENT , buf .buf , 1 );
793+ strbuf_release (& buf );
794+ }
795+
779796int cmd_rebase (int argc , const char * * argv , const char * prefix )
780797{
781798 struct rebase_options options = {
@@ -978,6 +995,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
978995
979996 if (action != NO_ACTION && !in_progress )
980997 die (_ ("No rebase in progress?" ));
998+ setenv (GIT_REFLOG_ACTION_ENVIRONMENT , "rebase" , 0 );
981999
9821000 if (action == ACTION_EDIT_TODO && !is_interactive (& options ))
9831001 die (_ ("The --edit-todo action can only be used during "
@@ -990,6 +1008,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
9901008 int fd ;
9911009
9921010 options .action = "continue" ;
1011+ set_reflog_action (& options );
9931012
9941013 /* Sanity check */
9951014 if (get_oid ("HEAD" , & head ))
@@ -1018,6 +1037,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
10181037 struct string_list merge_rr = STRING_LIST_INIT_DUP ;
10191038
10201039 options .action = "skip" ;
1040+ set_reflog_action (& options );
10211041
10221042 rerere_clear (& merge_rr );
10231043 string_list_clear (& merge_rr , 1 );
@@ -1033,6 +1053,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
10331053 case ACTION_ABORT : {
10341054 struct string_list merge_rr = STRING_LIST_INIT_DUP ;
10351055 options .action = "abort" ;
1056+ set_reflog_action (& options );
10361057
10371058 rerere_clear (& merge_rr );
10381059 string_list_clear (& merge_rr , 1 );
@@ -1440,11 +1461,12 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
14401461 }
14411462
14421463 strbuf_reset (& buf );
1443- strbuf_addf (& buf , "rebase: checkout %s" ,
1464+ strbuf_addf (& buf , "%s: checkout %s" ,
1465+ getenv (GIT_REFLOG_ACTION_ENVIRONMENT ),
14441466 options .switch_to );
14451467 if (reset_head (& oid , "checkout" ,
14461468 options .head_name , 0 ,
1447- NULL , NULL ) < 0 ) {
1469+ NULL , buf . buf ) < 0 ) {
14481470 ret = !!error (_ ("could not switch to "
14491471 "%s" ),
14501472 options .switch_to );
@@ -1508,7 +1530,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
15081530 printf (_ ("First, rewinding head to replay your work on top of "
15091531 "it...\n" ));
15101532
1511- strbuf_addf (& msg , "rebase: checkout %s" , options .onto_name );
1533+ strbuf_addf (& msg , "%s: checkout %s" ,
1534+ getenv (GIT_REFLOG_ACTION_ENVIRONMENT ), options .onto_name );
15121535 if (reset_head (& options .onto -> object .oid , "checkout" , NULL ,
15131536 RESET_HEAD_DETACH , NULL , msg .buf ))
15141537 die (_ ("Could not detach HEAD" ));
0 commit comments