If your branch was based on <upstream> but <upstream> was rewound and
your branch contains commits which were dropped, this option can be used
with `--keep-base` in order to drop those commits from your branch.
++
+See also INCOMPATIBLE OPTIONS below.
--ignore-whitespace::
+ Ignore whitespace differences when trying to reconcile
+ differences. Currently, each backend implements an approximation of
+ this behavior:
+ +
+ apply backend: When applying a patch, ignore changes in whitespace in
+ context lines. Unfortunately, this means that if the "old" lines being
+ replaced by the patch differ only in whitespace from the existing
+ file, you will get a merge conflict instead of a successful patch
+ application.
+ +
+ merge backend: Treat lines with only whitespace changes as unchanged
+ when merging. Unfortunately, this means that any patch hunks that were
+ intended to modify whitespace and nothing else will be dropped, even
+ if the other side had no changes that conflicted.
+
--whitespace=<option>::
- These flags are passed to the 'git apply' program
+ This flag is passed to the 'git apply' program
(see linkgit:git-apply[1]) that applies the patch.
Implies --apply.
+
* --preserve-merges and --signoff
* --preserve-merges and --rebase-merges
* --preserve-merges and --empty=
+ * --preserve-merges and --ignore-whitespace
+ * --preserve-merges and --committer-date-is-author-date
+ * --preserve-merges and --ignore-date
* --keep-base and --onto
* --keep-base and --root
+ * --fork-point and --root
BEHAVIORAL DIFFERENCES
-----------------------
options.autosquash) {
allow_preemptive_ff = 0;
}
+ 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;
+ for (i = 0; i < options.git_am_opts.nr; i++) {
+ const char *option = options.git_am_opts.v[i], *p;
- if (!strcmp(option, "--committer-date-is-author-date") ||
- !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)) {
imply_merge(&options, "--rebase-merges");
}
- argv_array_push(&options.git_am_opts,
- "--ignore-whitespace");
+ if (options.type == REBASE_APPLY) {
+ if (ignore_whitespace)
- argv_array_push(&options.git_am_opts,
- "--committer-date-is-author-date");
++ strvec_push(&options.git_am_opts,
++ "--ignore-whitespace");
+ if (options.committer_date_is_author_date)
- argv_array_push(&options.git_am_opts, "--ignore-date");
++ strvec_push(&options.git_am_opts,
++ "--committer-date-is-author-date");
+ if (options.ignore_date)
++ strvec_push(&options.git_am_opts, "--ignore-date");
+ } else {
+ /* REBASE_MERGE and PRESERVE_MERGES */
+ if (ignore_whitespace) {
+ string_list_append(&strategy_options,
+ "ignore-space-change");
+ }
+ }
+
if (strategy_options.nr) {
int i;
return NULL;
}
-static const char *author_date_from_env_array(const struct argv_array *env)
++static const char *author_date_from_env_array(const struct strvec *env)
+ {
+ int i;
+ const char *date;
+
- for (i = 0; i < env->argc; i++)
- if (skip_prefix(env->argv[i],
++ for (i = 0; i < env->nr; i++)
++ if (skip_prefix(env->v[i],
+ "GIT_AUTHOR_DATE=", &date))
+ return date;
+ /*
+ * If GIT_AUTHOR_DATE is missing we should have already errored out when
+ * reading the script
+ */
+ BUG("GIT_AUTHOR_DATE missing from author script");
+ }
+
static const char staged_changes_advice[] =
N_("you have staged changes in your working tree\n"
"If these changes are meant to be squashed into the previous commit, run:\n"
gpg_opt, gpg_opt);
}
- argv_array_pushf(&cmd.env_array, "GIT_COMMITTER_DATE=%s",
- opts->ignore_date ?
- "" :
- author_date_from_env_array(&cmd.env_array));
+ if (opts->committer_date_is_author_date)
- argv_array_push(&cmd.env_array, "GIT_AUTHOR_DATE=");
++ strvec_pushf(&cmd.env_array, "GIT_COMMITTER_DATE=%s",
++ opts->ignore_date ?
++ "" :
++ author_date_from_env_array(&cmd.env_array));
+ if (opts->ignore_date)
- argv_array_push(&cmd.args, "commit");
++ strvec_push(&cmd.env_array, "GIT_AUTHOR_DATE=");
+
+ strvec_push(&cmd.args, "commit");
if (!(flags & VERIFY_MSG))
- argv_array_push(&cmd.args, "-n");
+ strvec_push(&cmd.args, "-n");
if ((flags & AMEND_MSG))
- argv_array_push(&cmd.args, "--amend");
+ strvec_push(&cmd.args, "--amend");
if (opts->gpg_sign)
- argv_array_pushf(&cmd.args, "-S%s", opts->gpg_sign);
+ strvec_pushf(&cmd.args, "-S%s", opts->gpg_sign);
+ else
+ strvec_push(&cmd.args, "--no-gpg-sign");
if (defmsg)
- argv_array_pushl(&cmd.args, "-F", defmsg, NULL);
+ strvec_pushl(&cmd.args, "-F", defmsg, NULL);
else if (!(flags & EDIT_MSG))
- argv_array_pushl(&cmd.args, "-C", "HEAD", NULL);
+ strvec_pushl(&cmd.args, "-C", "HEAD", NULL);
if ((flags & CLEANUP_MSG))
- argv_array_push(&cmd.args, "--cleanup=strip");
+ strvec_push(&cmd.args, "--cleanup=strip");
if ((flags & EDIT_MSG))
- argv_array_push(&cmd.args, "-e");
+ strvec_push(&cmd.args, "-e");
else if (!(flags & CLEANUP_MSG) &&
!opts->signoff && !opts->record_origin &&
!opts->explicit_cleanup)
goto leave_merge;
}
- argv_array_pushf(&cmd.env_array, "GIT_COMMITTER_DATE=%s",
- opts->ignore_date ?
- "" :
- author_date_from_env_array(&cmd.env_array));
+ if (opts->committer_date_is_author_date)
- argv_array_push(&cmd.env_array, "GIT_AUTHOR_DATE=");
++ strvec_pushf(&cmd.env_array, "GIT_COMMITTER_DATE=%s",
++ opts->ignore_date ?
++ "" :
++ author_date_from_env_array(&cmd.env_array));
+ if (opts->ignore_date)
++ strvec_push(&cmd.env_array, "GIT_AUTHOR_DATE=");
+
cmd.git_cmd = 1;
- argv_array_push(&cmd.args, "merge");
- argv_array_push(&cmd.args, "-s");
+ strvec_push(&cmd.args, "merge");
+ strvec_push(&cmd.args, "-s");
if (!strategy)
- argv_array_push(&cmd.args, "octopus");
+ strvec_push(&cmd.args, "octopus");
else {
- argv_array_push(&cmd.args, strategy);
+ strvec_push(&cmd.args, strategy);
for (k = 0; k < opts->xopts_nr; k++)
- argv_array_pushf(&cmd.args,
- "-X%s", opts->xopts[k]);
+ strvec_pushf(&cmd.args,
+ "-X%s", opts->xopts[k]);
}
- argv_array_push(&cmd.args, "--no-edit");
- argv_array_push(&cmd.args, "--no-ff");
- argv_array_push(&cmd.args, "--no-log");
- argv_array_push(&cmd.args, "--no-stat");
- argv_array_push(&cmd.args, "-F");
- argv_array_push(&cmd.args, git_path_merge_msg(r));
+ strvec_push(&cmd.args, "--no-edit");
+ strvec_push(&cmd.args, "--no-ff");
+ strvec_push(&cmd.args, "--no-log");
+ strvec_push(&cmd.args, "--no-stat");
+ strvec_push(&cmd.args, "-F");
+ strvec_push(&cmd.args, git_path_merge_msg(r));
if (opts->gpg_sign)
- argv_array_push(&cmd.args, opts->gpg_sign);
+ strvec_push(&cmd.args, opts->gpg_sign);
/* Add the tips to be merged */
for (j = to_merge; j; j = j->next)
struct replay_opts *opts)
{
int res = 0, reschedule = 0;
+ char *prev_reflog_action;
+ /* Note that 0 for 3rd parameter of setenv means set only if not set */
setenv(GIT_REFLOG_ACTION, action_name(opts), 0);
+ prev_reflog_action = xstrdup(getenv(GIT_REFLOG_ACTION));
if (opts->allow_ff)
assert(!(opts->signoff || opts->no_commit ||
- opts->record_origin || opts->edit));
+ opts->record_origin || opts->edit ||
+ opts->committer_date_is_author_date ||
+ opts->ignore_date));
if (read_and_refresh_cache(r, opts))
return -1;