@@ -122,6 +122,8 @@ struct rebase_options {
122
122
int reapply_cherry_picks ;
123
123
int fork_point ;
124
124
int update_refs ;
125
+ int config_autosquash ;
126
+ int config_update_refs ;
125
127
};
126
128
127
129
#define REBASE_OPTIONS_INIT { \
@@ -136,6 +138,10 @@ struct rebase_options {
136
138
.fork_point = -1, \
137
139
.reapply_cherry_picks = -1, \
138
140
.allow_empty_message = 1, \
141
+ .autosquash = -1, \
142
+ .config_autosquash = -1, \
143
+ .update_refs = -1, \
144
+ .config_update_refs = -1, \
139
145
}
140
146
141
147
static 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)
778
784
}
779
785
780
786
if (!strcmp (var , "rebase.autosquash" )) {
781
- opts -> autosquash = git_config_bool (var , value );
787
+ opts -> config_autosquash = git_config_bool (var , value );
782
788
return 0 ;
783
789
}
784
790
@@ -795,7 +801,7 @@ static int rebase_config(const char *var, const char *value, void *data)
795
801
}
796
802
797
803
if (!strcmp (var , "rebase.updaterefs" )) {
798
- opts -> update_refs = git_config_bool (var , value );
804
+ opts -> config_update_refs = git_config_bool (var , value );
799
805
return 0 ;
800
806
}
801
807
@@ -1366,7 +1372,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1366
1372
if ((options .flags & REBASE_INTERACTIVE_EXPLICIT ) ||
1367
1373
(options .action != ACTION_NONE ) ||
1368
1374
(options .exec .nr > 0 ) ||
1369
- options .autosquash ) {
1375
+ (options .autosquash == -1 && options .config_autosquash == 1 ) ||
1376
+ options .autosquash == 1 ) {
1370
1377
allow_preemptive_ff = 0 ;
1371
1378
}
1372
1379
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)
1499
1506
if (strcmp (options .git_am_opts .v [i ], "-q" ))
1500
1507
break ;
1501
1508
1502
- if (i >= 0 ) {
1509
+ if (i >= 0 || options . type == REBASE_APPLY ) {
1503
1510
if (is_merge (& options ))
1504
1511
die (_ ("apply options and merge options "
1505
1512
"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" ));
1506
1517
else
1507
1518
options .type = REBASE_APPLY ;
1508
1519
}
1509
1520
}
1510
1521
1511
- if (options .update_refs )
1522
+ if (options .update_refs == 1 )
1512
1523
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 );
1513
1526
1514
- if (options .autosquash )
1527
+ if (options .autosquash == 1 )
1515
1528
imply_merge (& options , "--autosquash" );
1529
+ options .autosquash = (options .autosquash >= 0 ) ? options .autosquash :
1530
+ ((options .config_autosquash >= 0 ) ? options .config_autosquash : 0 );
1516
1531
1517
1532
if (options .type == REBASE_UNSPECIFIED ) {
1518
1533
if (!strcmp (options .default_backend , "merge" ))
0 commit comments