@@ -122,6 +122,8 @@ struct rebase_options {
122122 int reapply_cherry_picks ;
123123 int fork_point ;
124124 int update_refs ;
125+ int config_autosquash ;
126+ int config_update_refs ;
125127};
126128
127129#define REBASE_OPTIONS_INIT { \
@@ -136,6 +138,10 @@ struct rebase_options {
136138 .fork_point = -1, \
137139 .reapply_cherry_picks = -1, \
138140 .allow_empty_message = 1, \
141+ .autosquash = -1, \
142+ .config_autosquash = -1, \
143+ .update_refs = -1, \
144+ .config_update_refs = -1, \
139145 }
140146
141147static struct replay_opts get_replay_opts (const struct rebase_options * opts )
@@ -778,7 +784,7 @@ static int rebase_config(const char *var, const char *value, void *data)
778784 }
779785
780786 if (!strcmp (var , "rebase.autosquash" )) {
781- opts -> autosquash = git_config_bool (var , value );
787+ opts -> config_autosquash = git_config_bool (var , value );
782788 return 0 ;
783789 }
784790
@@ -795,7 +801,7 @@ static int rebase_config(const char *var, const char *value, void *data)
795801 }
796802
797803 if (!strcmp (var , "rebase.updaterefs" )) {
798- opts -> update_refs = git_config_bool (var , value );
804+ opts -> config_update_refs = git_config_bool (var , value );
799805 return 0 ;
800806 }
801807
@@ -1366,7 +1372,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
13661372 if ((options .flags & REBASE_INTERACTIVE_EXPLICIT ) ||
13671373 (options .action != ACTION_NONE ) ||
13681374 (options .exec .nr > 0 ) ||
1369- options .autosquash ) {
1375+ (options .autosquash == -1 && options .config_autosquash == 1 ) ||
1376+ options .autosquash == 1 ) {
13701377 allow_preemptive_ff = 0 ;
13711378 }
13721379 if (options .committer_date_is_author_date || options .ignore_date )
@@ -1499,20 +1506,28 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
14991506 if (strcmp (options .git_am_opts .v [i ], "-q" ))
15001507 break ;
15011508
1502- if (i >= 0 ) {
1509+ if (i >= 0 || options . type == REBASE_APPLY ) {
15031510 if (is_merge (& options ))
15041511 die (_ ("apply options and merge options "
15051512 "cannot be used together" ));
1513+ else if (options .autosquash == -1 && options .config_autosquash == 1 )
1514+ die (_ ("apply options are incompatible with rebase.autosquash. Consider adding --no-autosquash" ));
1515+ else if (options .update_refs == -1 && options .config_update_refs == 1 )
1516+ die (_ ("apply options are incompatible with rebase.updateRefs. Consider adding --no-update-refs" ));
15061517 else
15071518 options .type = REBASE_APPLY ;
15081519 }
15091520 }
15101521
1511- if (options .update_refs )
1522+ if (options .update_refs == 1 )
15121523 imply_merge (& options , "--update-refs" );
1524+ options .update_refs = (options .update_refs >= 0 ) ? options .update_refs :
1525+ ((options .config_update_refs >= 0 ) ? options .config_update_refs : 0 );
15131526
1514- if (options .autosquash )
1527+ if (options .autosquash == 1 )
15151528 imply_merge (& options , "--autosquash" );
1529+ options .autosquash = (options .autosquash >= 0 ) ? options .autosquash :
1530+ ((options .config_autosquash >= 0 ) ? options .config_autosquash : 0 );
15161531
15171532 if (options .type == REBASE_UNSPECIFIED ) {
15181533 if (!strcmp (options .default_backend , "merge" ))
0 commit comments