@@ -776,6 +776,23 @@ static void NORETURN error_on_missing_default_upstream(void)
776
776
exit (1 );
777
777
}
778
778
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
+
779
796
int cmd_rebase (int argc , const char * * argv , const char * prefix )
780
797
{
781
798
struct rebase_options options = {
@@ -978,6 +995,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
978
995
979
996
if (action != NO_ACTION && !in_progress )
980
997
die (_ ("No rebase in progress?" ));
998
+ setenv (GIT_REFLOG_ACTION_ENVIRONMENT , "rebase" , 0 );
981
999
982
1000
if (action == ACTION_EDIT_TODO && !is_interactive (& options ))
983
1001
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)
990
1008
int fd ;
991
1009
992
1010
options .action = "continue" ;
1011
+ set_reflog_action (& options );
993
1012
994
1013
/* Sanity check */
995
1014
if (get_oid ("HEAD" , & head ))
@@ -1018,6 +1037,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1018
1037
struct string_list merge_rr = STRING_LIST_INIT_DUP ;
1019
1038
1020
1039
options .action = "skip" ;
1040
+ set_reflog_action (& options );
1021
1041
1022
1042
rerere_clear (& merge_rr );
1023
1043
string_list_clear (& merge_rr , 1 );
@@ -1033,6 +1053,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1033
1053
case ACTION_ABORT : {
1034
1054
struct string_list merge_rr = STRING_LIST_INIT_DUP ;
1035
1055
options .action = "abort" ;
1056
+ set_reflog_action (& options );
1036
1057
1037
1058
rerere_clear (& merge_rr );
1038
1059
string_list_clear (& merge_rr , 1 );
@@ -1440,11 +1461,12 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1440
1461
}
1441
1462
1442
1463
strbuf_reset (& buf );
1443
- strbuf_addf (& buf , "rebase: checkout %s" ,
1464
+ strbuf_addf (& buf , "%s: checkout %s" ,
1465
+ getenv (GIT_REFLOG_ACTION_ENVIRONMENT ),
1444
1466
options .switch_to );
1445
1467
if (reset_head (& oid , "checkout" ,
1446
1468
options .head_name , 0 ,
1447
- NULL , NULL ) < 0 ) {
1469
+ NULL , buf . buf ) < 0 ) {
1448
1470
ret = !!error (_ ("could not switch to "
1449
1471
"%s" ),
1450
1472
options .switch_to );
@@ -1508,7 +1530,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1508
1530
printf (_ ("First, rewinding head to replay your work on top of "
1509
1531
"it...\n" ));
1510
1532
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 );
1512
1535
if (reset_head (& options .onto -> object .oid , "checkout" , NULL ,
1513
1536
RESET_HEAD_DETACH , NULL , msg .buf ))
1514
1537
die (_ ("Could not detach HEAD" ));
0 commit comments