summaryrefslogtreecommitdiff
path: root/builtin/rebase.c
diff options
context:
space:
mode:
authorPhillip Wood <phillip.wood@dunelm.org.uk>2020-08-17 17:40:03 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-08-19 22:19:59 (GMT)
commita3894aad67df655a9c7f3b511093f681d3a01fb7 (patch)
tree52dc920b2f4465db647f8b1f3b86c62b324f1a83 /builtin/rebase.c
parent7573cec52c0274ceb166c425be4288f6b3103d6f (diff)
downloadgit-a3894aad67df655a9c7f3b511093f681d3a01fb7.zip
git-a3894aad67df655a9c7f3b511093f681d3a01fb7.tar.gz
git-a3894aad67df655a9c7f3b511093f681d3a01fb7.tar.bz2
rebase -i: support --ignore-date
Rebase is implemented with two different backends - 'apply' and 'merge' each of which support a different set of options. In particular the apply backend supports a number of options implemented by 'git am' that are not implemented in the merge backend. This means that the available options are different depending on which backend is used which is confusing. This patch adds support for the --ignore-date option to the merge backend. This option uses the current time as the author date rather than reusing the original author date when rewriting commits. We take care to handle the combination of --ignore-date and --committer-date-is-author-date in the same way as the apply backend. Original-patch-by: Rohit Ashiwal <rohit.ashiwal265@gmail.com> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/rebase.c')
-rw-r--r--builtin/rebase.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 2579380..583ac96 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -89,6 +89,7 @@ struct rebase_options {
char *gpg_sign_opt;
int autostash;
int committer_date_is_author_date;
+ int ignore_date;
char *cmd;
int allow_empty_message;
int rebase_merges, rebase_cousins;
@@ -127,6 +128,7 @@ static struct replay_opts get_replay_opts(const struct rebase_options *opts)
replay.reschedule_failed_exec = opts->reschedule_failed_exec;
replay.committer_date_is_author_date =
opts->committer_date_is_author_date;
+ replay.ignore_date = opts->ignore_date;
replay.gpg_sign = xstrdup_or_null(opts->gpg_sign_opt);
replay.strategy = opts->strategy;
@@ -1503,8 +1505,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
OPT_BOOL(0, "committer-date-is-author-date",
&options.committer_date_is_author_date,
N_("make committer date match author date")),
- OPT_PASSTHRU_ARGV(0, "ignore-date", &options.git_am_opts, NULL,
- N_("passed to 'git am'"), PARSE_OPT_NOARG),
+ OPT_BOOL(0, "ignore-date", &options.ignore_date,
+ N_("ignore author date and use current date")),
OPT_PASSTHRU_ARGV('C', NULL, &options.git_am_opts, N_("n"),
N_("passed to 'git apply'"), 0),
OPT_BOOL(0, "ignore-whitespace", &ignore_whitespace,
@@ -1797,13 +1799,12 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
options.autosquash) {
allow_preemptive_ff = 0;
}
- if (options.committer_date_is_author_date)
+ if (options.committer_date_is_author_date || options.ignore_date)
options.flags |= REBASE_FORCE;
for (i = 0; i < options.git_am_opts.argc; i++) {
const char *option = options.git_am_opts.argv[i], *p;
- if (!strcmp(option, "--ignore-date") ||
- !strcmp(option, "--whitespace=fix") ||
+ if (!strcmp(option, "--whitespace=fix") ||
!strcmp(option, "--whitespace=strip"))
allow_preemptive_ff = 0;
else if (skip_prefix(option, "-C", &p)) {
@@ -1862,6 +1863,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
if (options.committer_date_is_author_date)
argv_array_push(&options.git_am_opts,
"--committer-date-is-author-date");
+ if (options.ignore_date)
+ argv_array_push(&options.git_am_opts, "--ignore-date");
} else {
/* REBASE_MERGE and PRESERVE_MERGES */
if (ignore_whitespace) {