]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'pw/rebase-i-more-options'
authorJunio C Hamano <gitster@pobox.com>
Thu, 3 Sep 2020 19:37:01 +0000 (12:37 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 3 Sep 2020 19:37:01 +0000 (12:37 -0700)
"git rebase -i" learns a bit more options.

* pw/rebase-i-more-options:
  t3436: do not run git-merge-recursive in dashed form
  rebase: add --reset-author-date
  rebase -i: support --ignore-date
  rebase -i: support --committer-date-is-author-date
  am: stop exporting GIT_COMMITTER_DATE
  rebase -i: add --ignore-whitespace flag

1  2 
Documentation/git-rebase.txt
builtin/am.c
builtin/commit.c
builtin/rebase.c
commit.c
commit.h
ident.c
sequencer.c
sequencer.h

index 374d2486f71c6659d48ea6105e877d89b9fe8d28,1ee3bb4facb09edd21d1cb4ce61a1f9d2b9e22ce..e8df8d521467e433aeaa2568772957dfa1f2bf35
@@@ -455,12 -420,25 +455,27 @@@ If <upstream> is given on the command l
  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.
  +
@@@ -636,9 -616,11 +654,12 @@@ In addition, the following pairs of opt
   * --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
  -----------------------
diff --cc builtin/am.c
index dd4e6c2d9b7f478c322a469fd64cbaf3de285d17,896cd0f827485193492f6bc036f8c3a7f05b52c4..b5c63ddf1df8ea5be5b11944b23f3411686b0287
@@@ -161,8 -173,10 +173,10 @@@ static void am_state_release(struct am_
        free(state->author_name);
        free(state->author_email);
        free(state->author_date);
+       free(state->committer_name);
+       free(state->committer_email);
        free(state->msg);
 -      argv_array_clear(&state->git_apply_opts);
 +      strvec_clear(&state->git_apply_opts);
  }
  
  /**
Simple merge
index dadb52fa92e7f28e0c81b27b74b9a23b289e4be9,b126fbe940bc6b3af87282be67e16699fbfa2667..c4ff2039ef08635798365084f4a9a2847c280ba6
@@@ -1624,12 -1801,12 +1632,12 @@@ int cmd_rebase(int argc, const char **a
            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;
  
diff --cc commit.c
Simple merge
diff --cc commit.h
Simple merge
diff --cc ident.c
Simple merge
diff --cc sequencer.c
index d7db076715ad6ef622fdb558a39b9fec66861ea4,4ccb5451a9815da6df2d8222e46651d7f0f557ef..e8676e965fca6813d49cb4b30cc4fab5b8da3390
@@@ -864,6 -876,22 +868,22 @@@ static char *get_author(const char *mes
        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"
@@@ -930,24 -958,30 +950,32 @@@ static int run_git_commit(struct reposi
                             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)
@@@ -3552,25 -3632,33 +3642,33 @@@ static int do_merge(struct repository *
                        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)
@@@ -3909,14 -3913,13 +4007,16 @@@ static int pick_commits(struct reposito
                        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;
  
diff --cc sequencer.h
Simple merge