@@ -79,8 +79,11 @@ struct rebase_options {
79
79
int allow_rerere_autoupdate ;
80
80
int keep_empty ;
81
81
int autosquash ;
82
+ int ignore_whitespace ;
82
83
char * gpg_sign_opt ;
83
84
int autostash ;
85
+ int committer_date_is_author_date ;
86
+ int ignore_date ;
84
87
char * cmd ;
85
88
int allow_empty_message ;
86
89
int rebase_merges , rebase_cousins ;
@@ -97,7 +100,7 @@ struct rebase_options {
97
100
.git_format_patch_opt = STRBUF_INIT \
98
101
}
99
102
100
- static struct replay_opts get_replay_opts (const struct rebase_options * opts )
103
+ static struct replay_opts get_replay_opts (struct rebase_options * opts )
101
104
{
102
105
struct replay_opts replay = REPLAY_OPTS_INIT ;
103
106
@@ -112,8 +115,22 @@ static struct replay_opts get_replay_opts(const struct rebase_options *opts)
112
115
replay .allow_empty_message = opts -> allow_empty_message ;
113
116
replay .verbose = opts -> flags & REBASE_VERBOSE ;
114
117
replay .reschedule_failed_exec = opts -> reschedule_failed_exec ;
118
+ replay .committer_date_is_author_date =
119
+ opts -> committer_date_is_author_date ;
120
+ replay .ignore_date = opts -> ignore_date ;
115
121
replay .gpg_sign = xstrdup_or_null (opts -> gpg_sign_opt );
116
122
replay .strategy = opts -> strategy ;
123
+
124
+ if (opts -> ignore_whitespace ) {
125
+ struct strbuf buf = STRBUF_INIT ;
126
+
127
+ if (opts -> strategy_opts )
128
+ strbuf_addstr (& buf , opts -> strategy_opts );
129
+
130
+ strbuf_addstr (& buf , " --ignore-space-change" );
131
+ free (opts -> strategy_opts );
132
+ opts -> strategy_opts = strbuf_detach (& buf , NULL );
133
+ }
117
134
if (opts -> strategy_opts )
118
135
parse_strategy_opts (& replay , opts -> strategy_opts );
119
136
@@ -512,13 +529,19 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
512
529
argc = parse_options (argc , argv , prefix , options ,
513
530
builtin_rebase_interactive_usage , PARSE_OPT_KEEP_ARGV0 );
514
531
532
+ opts .strategy_opts = xstrdup_or_null (opts .strategy_opts );
533
+
515
534
if (!is_null_oid (& squash_onto ))
516
535
opts .squash_onto = & squash_onto ;
517
536
518
537
if (opts .rebase_cousins >= 0 && !opts .rebase_merges )
519
538
warning (_ ("--[no-]rebase-cousins has no effect without "
520
539
"--rebase-merges" ));
521
540
541
+ if (opts .committer_date_is_author_date ||
542
+ opts .ignore_date )
543
+ opts .flags |= REBASE_FORCE ;
544
+
522
545
return !!run_rebase_interactive (& opts , command );
523
546
}
524
547
@@ -965,6 +988,12 @@ static int run_am(struct rebase_options *opts)
965
988
am .git_cmd = 1 ;
966
989
argv_array_push (& am .args , "am" );
967
990
991
+ if (opts -> ignore_whitespace )
992
+ argv_array_push (& am .args , "--ignore-whitespace" );
993
+ if (opts -> committer_date_is_author_date )
994
+ argv_array_push (& opts -> git_am_opts , "--committer-date-is-author-date" );
995
+ if (opts -> ignore_date )
996
+ argv_array_push (& opts -> git_am_opts , "--ignore-date" );
968
997
if (opts -> action && !strcmp ("continue" , opts -> action )) {
969
998
argv_array_push (& am .args , "--resolved" );
970
999
argv_array_pushf (& am .args , "--resolvemsg=%s" , resolvemsg );
@@ -1432,16 +1461,17 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1432
1461
PARSE_OPT_NOARG , NULL , REBASE_DIFFSTAT },
1433
1462
OPT_BOOL (0 , "signoff" , & options .signoff ,
1434
1463
N_ ("add a Signed-off-by: line to each commit" )),
1435
- OPT_PASSTHRU_ARGV (0 , "ignore-whitespace" , & options .git_am_opts ,
1436
- NULL , N_ ("passed to 'git am'" ),
1437
- PARSE_OPT_NOARG ),
1438
- OPT_PASSTHRU_ARGV (0 , "committer-date-is-author-date" ,
1439
- & options .git_am_opts , NULL ,
1440
- N_ ("passed to 'git am'" ), PARSE_OPT_NOARG ),
1441
- OPT_PASSTHRU_ARGV (0 , "ignore-date" , & options .git_am_opts , NULL ,
1442
- N_ ("passed to 'git am'" ), PARSE_OPT_NOARG ),
1464
+ OPT_BOOL (0 , "committer-date-is-author-date" ,
1465
+ & options .committer_date_is_author_date ,
1466
+ N_ ("make committer date match author date" )),
1467
+ OPT_BOOL (0 , "author-date-is-committer-date" , & options .ignore_date ,
1468
+ "ignore author date and use current date" ),
1469
+ OPT_BOOL (0 , "ignore-date" , & options .ignore_date ,
1470
+ "ignore author date and use current date" ),
1443
1471
OPT_PASSTHRU_ARGV ('C' , NULL , & options .git_am_opts , N_ ("n" ),
1444
1472
N_ ("passed to 'git apply'" ), 0 ),
1473
+ OPT_BOOL (0 , "ignore-whitespace" , & options .ignore_whitespace ,
1474
+ N_ ("ignore changes in whitespace" )),
1445
1475
OPT_PASSTHRU_ARGV (0 , "whitespace" , & options .git_am_opts ,
1446
1476
N_ ("action" ), N_ ("passed to 'git apply'" ), 0 ),
1447
1477
OPT_BIT ('f' , "force-rebase" , & options .flags ,
@@ -1709,11 +1739,13 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1709
1739
state_dir_base , cmd_live_rebase , buf .buf );
1710
1740
}
1711
1741
1742
+ if (options .committer_date_is_author_date ||
1743
+ options .ignore_date )
1744
+ options .flags |= REBASE_FORCE ;
1745
+
1712
1746
for (i = 0 ; i < options .git_am_opts .argc ; i ++ ) {
1713
1747
const char * option = options .git_am_opts .argv [i ], * p ;
1714
- if (!strcmp (option , "--committer-date-is-author-date" ) ||
1715
- !strcmp (option , "--ignore-date" ) ||
1716
- !strcmp (option , "--whitespace=fix" ) ||
1748
+ if (!strcmp (option , "--whitespace=fix" ) ||
1717
1749
!strcmp (option , "--whitespace=strip" ))
1718
1750
options .flags |= REBASE_FORCE ;
1719
1751
else if (skip_prefix (option , "-C" , & p )) {
@@ -1861,6 +1893,12 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1861
1893
"'--reschedule-failed-exec'" ));
1862
1894
}
1863
1895
1896
+ if (options .rebase_merges ) {
1897
+ if (options .ignore_whitespace )
1898
+ die (_ ("cannot combine '--rebase-merges' with "
1899
+ "'--ignore-whitespace'" ));
1900
+ }
1901
+
1864
1902
if (!options .root ) {
1865
1903
if (argc < 1 ) {
1866
1904
struct branch * branch ;
0 commit comments