Skip to content

Commit f68b169

Browse files
committed
Merge branch 'ra/rebase-i-more-options' into pu
* ra/rebase-i-more-options: rebase: add --reset-author-date rebase -i: support --ignore-date sequencer: rename amend_author to author_to_rename rebase -i: support --committer-date-is-author-date sequencer: allow callers of read_author_script() to ignore fields rebase -i: add --ignore-whitespace flag
2 parents 53cfe16 + fe28ad8 commit f68b169

File tree

6 files changed

+322
-28
lines changed

6 files changed

+322
-28
lines changed

Documentation/git-rebase.txt

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -393,16 +393,29 @@ your branch contains commits which were dropped, this option can be used
393393
with `--keep-base` in order to drop those commits from your branch.
394394

395395
--ignore-whitespace::
396+
Behaves differently depending on which backend is selected.
397+
+
398+
'am' backend: When applying a patch, ignore changes in whitespace in
399+
context lines if necessary.
400+
+
401+
'interactive' backend: Treat lines with only whitespace changes as
402+
unchanged for the sake of a three-way merge.
403+
396404
--whitespace=<option>::
397-
These flag are passed to the 'git apply' program
405+
This flag is passed to the 'git apply' program
398406
(see linkgit:git-apply[1]) that applies the patch.
399407
+
400408
See also INCOMPATIBLE OPTIONS below.
401409

402410
--committer-date-is-author-date::
411+
Instead of recording the time the rebased commits are
412+
created as the committer date, reuse the author date
413+
as the committer date. This implies --force-rebase.
414+
403415
--ignore-date::
404-
These flags are passed to 'git am' to easily change the dates
405-
of the rebased commits (see linkgit:git-am[1]).
416+
--reset-author-date::
417+
Instead of using the given author date, reset it to the
418+
current time. This implies --force-rebase.
406419
+
407420
See also INCOMPATIBLE OPTIONS below.
408421

@@ -539,10 +552,7 @@ INCOMPATIBLE OPTIONS
539552

540553
The following options:
541554

542-
* --committer-date-is-author-date
543-
* --ignore-date
544555
* --whitespace
545-
* --ignore-whitespace
546556
* -C
547557

548558
are incompatible with the following options:
@@ -565,6 +575,9 @@ In addition, the following pairs of options are incompatible:
565575
* --preserve-merges and --interactive
566576
* --preserve-merges and --signoff
567577
* --preserve-merges and --rebase-merges
578+
* --preserve-merges and --ignore-whitespace
579+
* --preserve-merges and --committer-date-is-author-date
580+
* --preserve-merges and --ignore-date
568581
* --keep-base and --onto
569582
* --keep-base and --root
570583

builtin/rebase.c

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,11 @@ struct rebase_options {
7979
int allow_rerere_autoupdate;
8080
int keep_empty;
8181
int autosquash;
82+
int ignore_whitespace;
8283
char *gpg_sign_opt;
8384
int autostash;
85+
int committer_date_is_author_date;
86+
int ignore_date;
8487
char *cmd;
8588
int allow_empty_message;
8689
int rebase_merges, rebase_cousins;
@@ -99,6 +102,7 @@ struct rebase_options {
99102

100103
static struct replay_opts get_replay_opts(const struct rebase_options *opts)
101104
{
105+
struct strbuf strategy_buf = STRBUF_INIT;
102106
struct replay_opts replay = REPLAY_OPTS_INIT;
103107

104108
replay.action = REPLAY_INTERACTIVE_REBASE;
@@ -112,10 +116,20 @@ static struct replay_opts get_replay_opts(const struct rebase_options *opts)
112116
replay.allow_empty_message = opts->allow_empty_message;
113117
replay.verbose = opts->flags & REBASE_VERBOSE;
114118
replay.reschedule_failed_exec = opts->reschedule_failed_exec;
119+
replay.committer_date_is_author_date =
120+
opts->committer_date_is_author_date;
121+
replay.ignore_date = opts->ignore_date;
115122
replay.gpg_sign = xstrdup_or_null(opts->gpg_sign_opt);
116123
replay.strategy = opts->strategy;
124+
117125
if (opts->strategy_opts)
118-
parse_strategy_opts(&replay, opts->strategy_opts);
126+
strbuf_addstr(&strategy_buf, opts->strategy_opts);
127+
if (opts->ignore_whitespace)
128+
strbuf_addstr(&strategy_buf, " --ignore-space-change");
129+
if (strategy_buf.len)
130+
parse_strategy_opts(&replay, strategy_buf.buf);
131+
132+
strbuf_release(&strategy_buf);
119133

120134
if (opts->squash_onto) {
121135
oidcpy(&replay.squash_onto, opts->squash_onto);
@@ -517,6 +531,8 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
517531
argc = parse_options(argc, argv, prefix, options,
518532
builtin_rebase_interactive_usage, PARSE_OPT_KEEP_ARGV0);
519533

534+
opts.strategy_opts = xstrdup_or_null(opts.strategy_opts);
535+
520536
if (!is_null_oid(&squash_onto))
521537
opts.squash_onto = &squash_onto;
522538

@@ -970,6 +986,12 @@ static int run_am(struct rebase_options *opts)
970986
am.git_cmd = 1;
971987
argv_array_push(&am.args, "am");
972988

989+
if (opts->ignore_whitespace)
990+
argv_array_push(&am.args, "--ignore-whitespace");
991+
if (opts->committer_date_is_author_date)
992+
argv_array_push(&opts->git_am_opts, "--committer-date-is-author-date");
993+
if (opts->ignore_date)
994+
argv_array_push(&opts->git_am_opts, "--ignore-date");
973995
if (opts->action && !strcmp("continue", opts->action)) {
974996
argv_array_push(&am.args, "--resolved");
975997
argv_array_pushf(&am.args, "--resolvemsg=%s", resolvemsg);
@@ -1436,16 +1458,17 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
14361458
PARSE_OPT_NOARG, NULL, REBASE_DIFFSTAT },
14371459
OPT_BOOL(0, "signoff", &options.signoff,
14381460
N_("add a Signed-off-by: line to each commit")),
1439-
OPT_PASSTHRU_ARGV(0, "ignore-whitespace", &options.git_am_opts,
1440-
NULL, N_("passed to 'git am'"),
1441-
PARSE_OPT_NOARG),
1442-
OPT_PASSTHRU_ARGV(0, "committer-date-is-author-date",
1443-
&options.git_am_opts, NULL,
1444-
N_("passed to 'git am'"), PARSE_OPT_NOARG),
1445-
OPT_PASSTHRU_ARGV(0, "ignore-date", &options.git_am_opts, NULL,
1446-
N_("passed to 'git am'"), PARSE_OPT_NOARG),
1461+
OPT_BOOL(0, "committer-date-is-author-date",
1462+
&options.committer_date_is_author_date,
1463+
N_("make committer date match author date")),
1464+
OPT_BOOL(0, "reset-author-date", &options.ignore_date,
1465+
"ignore author date and use current date"),
1466+
OPT_BOOL(0, "ignore-date", &options.ignore_date,
1467+
"ignore author date and use current date"),
14471468
OPT_PASSTHRU_ARGV('C', NULL, &options.git_am_opts, N_("n"),
14481469
N_("passed to 'git apply'"), 0),
1470+
OPT_BOOL(0, "ignore-whitespace", &options.ignore_whitespace,
1471+
N_("ignore changes in whitespace")),
14491472
OPT_PASSTHRU_ARGV(0, "whitespace", &options.git_am_opts,
14501473
N_("action"), N_("passed to 'git apply'"), 0),
14511474
OPT_BIT('f', "force-rebase", &options.flags,
@@ -1718,11 +1741,13 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
17181741
state_dir_base, cmd_live_rebase, buf.buf);
17191742
}
17201743

1744+
if (options.committer_date_is_author_date ||
1745+
options.ignore_date)
1746+
options.flags |= REBASE_FORCE;
1747+
17211748
for (i = 0; i < options.git_am_opts.argc; i++) {
17221749
const char *option = options.git_am_opts.argv[i], *p;
1723-
if (!strcmp(option, "--committer-date-is-author-date") ||
1724-
!strcmp(option, "--ignore-date") ||
1725-
!strcmp(option, "--whitespace=fix") ||
1750+
if (!strcmp(option, "--whitespace=fix") ||
17261751
!strcmp(option, "--whitespace=strip"))
17271752
options.flags |= REBASE_FORCE;
17281753
else if (skip_prefix(option, "-C", &p)) {

0 commit comments

Comments
 (0)