Subject: [PATCH v3 00/11] Drop support for git rebase --preserve-merges

From: "Johannes Schindelin via GitGitGadget" <[email-masked]>
Date: Tue, 07 Sep 2021 21:05:01 +0000

In 427c3bd28ab (rebase: deprecate --preserve-merges, 2019-03-11) (which was
included in v2.22.0), we officially deprecated the --preserve-merges
backend. Over two years later, it is time to drop that backend, and here is
a patch series that does just that.

Changes since v2:

 * Removed the no-longer-needed script_snippet variable
 * Enhanced the commit message of the git svn patch to clarify that the
   deprecation happened only in v2.25 there
 * Adjusted code comments that still talked about the removed option
 * Removed some no-longer-needed ACTION_* enum values
 * We now also drop check_todo_list_from_file() because it is no longer
   needed
 * The todo_list_add_exec_commands() function is now scoped to the file
   (because there are no longer any outside users)
 * When users still use the options, they are no longer met by Git's blank
   stares, but by a helpful error message suggesting to use --rebase-merges
   instead

Changes since v1:

 * Rebased onto v2.33.0

Johannes Schindelin (11):
  t5520: do not use `pull.rebase=preserve`
  remote: warn about unhandled branch.<name>.rebase values
  tests: stop testing `git rebase --preserve-merges`
  pull: remove support for `--rebase=preserve`
  rebase: drop support for `--preserve-merges`
  git-svn: drop support for `--preserve-merges`
  rebase: drop the internal `rebase--interactive` command
  rebase: remove obsolete code comment
  rebase: stop mentioning the -p option in comments
  rebase: remove a no-longer-used function
  sequencer: restrict scope of a formerly public function

 .github/workflows/main.yml                |    1 -
 .gitignore                                |    1 -
 Documentation/config/branch.txt           |    4 -
 Documentation/config/pull.txt             |    4 -
 Documentation/git-pull.txt                |    6 +-
 Documentation/git-rebase.txt              |   51 -
 Documentation/git-svn.txt                 |    1 -
 Makefile                                  |    2 -
 builtin/pull.c                            |    9 +-
 builtin/rebase.c                          |  335 +------
 builtin/remote.c                          |    3 +
 contrib/completion/git-completion.bash    |    2 +-
 git-rebase--preserve-merges.sh            | 1057 ---------------------
 git-svn.perl                              |    1 -
 git.c                                     |    1 -
 rebase-interactive.c                      |   29 -
 rebase-interactive.h                      |    2 -
 rebase.c                                  |    5 +-
 rebase.h                                  |    1 -
 sequencer.c                               |    4 +-
 sequencer.h                               |    2 -
 t/t3404-rebase-interactive.sh             |   76 --
 t/t3408-rebase-multi-line.sh              |   10 -
 t/t3409-rebase-preserve-merges.sh         |  130 ---
 t/t3410-rebase-preserve-dropped-merges.sh |   90 --
 t/t3411-rebase-preserve-around-merges.sh  |   80 --
 t/t3412-rebase-root.sh                    |   37 -
 t/t3414-rebase-preserve-onto.sh           |   85 --
 t/t3418-rebase-continue.sh                |   15 -
 t/t3421-rebase-topology-linear.sh         |   19 -
 t/t3422-rebase-incompatible-options.sh    |   11 -
 t/t3425-rebase-topology-merges.sh         |  151 ---
 t/t3427-rebase-subtree.sh                 |   26 +-
 t/t5520-pull.sh                           |   24 +-
 t/t7505-prepare-commit-msg-hook.sh        |    1 -
 t/t7517-per-repo-email.sh                 |   13 -
 t/test-lib.sh                             |    4 -
 37 files changed, 33 insertions(+), 2260 deletions(-)
 delete mode 100644 git-rebase--preserve-merges.sh
 delete mode 100755 t/t3409-rebase-preserve-merges.sh
 delete mode 100755 t/t3410-rebase-preserve-dropped-merges.sh
 delete mode 100755 t/t3411-rebase-preserve-around-merges.sh
 delete mode 100755 t/t3414-rebase-preserve-onto.sh

base-commit: 225bc32a989d7a22fa6addafd4ce7dcd04675dbf
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-195%2Fdscho%2Fdrop-rebase-p-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-195/dscho/drop-rebase-p-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/195

Range-diff vs v2:

  1:  8da29d539fc =  1:  8da29d539fc t5520: do not use `pull.rebase=preserve`
  2:  acda0f59947 =  2:  acda0f59947 remote: warn about unhandled branch.<name>.rebase values
  3:  cdb9fae4b93 !  3:  e4b683f0cd6 tests: stop testing `git rebase --preserve-merges`
     @@ t/t3425-rebase-topology-merges.sh: test_run_rebase success 'd n o e' --apply
       test_done
      
       ## t/t3427-rebase-subtree.sh ##
     +@@ t/t3427-rebase-subtree.sh: commit_message() {
     + # where the root commit adds three files: topic_1.t, topic_2.t and topic_3.t.
     + #
     + # This commit history is then rebased onto `topic_3` with the
     +-# `-Xsubtree=files_subtree` option in three different ways:
     ++# `-Xsubtree=files_subtree` option in two different ways:
     + #
     +-# 1. using `--preserve-merges`
     +-# 2. using `--preserve-merges` and --keep-empty
     +-# 3. without specifying a rebase backend
     ++# 1. without specifying a rebase backend
     ++# 2. using the `--rebase-merges` backend
     + 
     + test_expect_success 'setup' '
     + 	test_commit README &&
      @@ t/t3427-rebase-subtree.sh: test_expect_success 'setup' '
       	git commit -m "Empty commit" --allow-empty
       '
  4:  b493046134d !  4:  6e45e90abe5 pull: remove support for `--rebase=preserve`
     @@ Commit message
          In preparation for `git-rebase--preserve-merges.sh` entering its after
          life, we remove this (deprecated) option that would still rely on it.
      
     +    To help users transition who still did not receive the memo about the
     +    deprecation, we offer a helpful error message instead of throwing our
     +    hands in the air and saying that we don't know that option, never heard
     +    of it.
     +
          Signed-off-by: Johannes Schindelin <[email-masked]>
      
       ## Documentation/config/branch.txt ##
     @@ contrib/completion/git-completion.bash: __git_complete_config_variable_value ()
       	remote.pushdefault)
      
       ## rebase.c ##
     +@@
     + #include "rebase.h"
     + #include "config.h"
     ++#include "gettext.h"
     + 
     + /*
     +  * Parses textual value for pull.rebase, branch.<name>.rebase, etc.
      @@ rebase.c: enum rebase_type rebase_parse_value(const char *value)
       		return REBASE_FALSE;
       	else if (v > 0)
     @@ rebase.c: enum rebase_type rebase_parse_value(const char *value)
       	else if (!strcmp(value, "merges") || !strcmp(value, "m"))
       		return REBASE_MERGES;
       	else if (!strcmp(value, "interactive") || !strcmp(value, "i"))
     + 		return REBASE_INTERACTIVE;
     ++	else if (!strcmp(value, "preserve") || !strcmp(value, "p"))
     ++		error(_("%s: 'preserve' superseded by 'merges'"), value);
     + 	/*
     + 	 * Please update _git_config() in git-completion.bash when you
     + 	 * add new rebase modes.
      
       ## rebase.h ##
      @@ rebase.h: enum rebase_type {
  5:  eb738b1bf05 !  5:  2d7a4a2c564 rebase: drop support for `--preserve-merges`
     @@ Commit message
          This option was deprecated in favor of `--rebase-merges` some time ago,
          and now we retire it.
      
     +    To assist users to transition away, we do not _actually_ remove the
     +    option, but now we no longer implement the functionality. Instead, we
     +    offer a helpful error message suggesting which option to use.
     +
          Signed-off-by: Johannes Schindelin <[email-masked]>
      
       ## .gitignore ##
     @@ builtin/rebase.c: static int run_am(struct rebase_options *opts)
       {
      -	const char *argv[] = { NULL, NULL };
      -	struct strbuf script_snippet = STRBUF_INIT, buf = STRBUF_INIT;
     -+	struct strbuf script_snippet = STRBUF_INIT;
       	int status;
      -	const char *backend, *backend_func;
       
     @@ builtin/rebase.c: static int run_specific_rebase(struct rebase_options *opts, en
       		BUG("Unhandled rebase type %d", opts->type);
      -		break;
      -	}
     - 
     +-
      -	strbuf_addf(&script_snippet,
      -		    ". git-sh-setup && . %s && %s", backend, backend_func);
      -	argv[0] = script_snippet.buf;
     --
     + 
      -	status = run_command_v_opt(argv, RUN_USING_SHELL);
      -finished_rebase:
       	if (opts->dont_finish_rebase)
       		; /* do nothing */
       	else if (opts->type == REBASE_MERGE)
     +@@ builtin/rebase.c: finished_rebase:
     + 		die("Nothing to do");
     + 	}
     + 
     +-	strbuf_release(&script_snippet);
     +-
     + 	return status ? -1 : 0;
     + }
     + 
     +@@ builtin/rebase.c: int cmd_rebase(int argc, const char **argv, const char *prefix)
     + 	char *squash_onto_name = NULL;
     + 	int reschedule_failed_exec = -1;
     + 	int allow_preemptive_ff = 1;
     ++	int preserve_merges_selected = 0;
     + 	struct option builtin_rebase_options[] = {
     + 		OPT_STRING(0, "onto", &options.onto_name,
     + 			   N_("revision"),
      @@ builtin/rebase.c: int cmd_rebase(int argc, const char **argv, const char *prefix)
       			N_("let the user edit the list of commits to rebase"),
       			PARSE_OPT_NOARG | PARSE_OPT_NONEG,
       			parse_opt_interactive),
      -		OPT_SET_INT_F('p', "preserve-merges", &options.type,
     --			      N_("(DEPRECATED) try to recreate merges instead of "
     --				 "ignoring them"),
     ++		OPT_SET_INT_F('p', "preserve-merges", &preserve_merges_selected,
     + 			      N_("(DEPRECATED) try to recreate merges instead of "
     + 				 "ignoring them"),
      -			      REBASE_PRESERVE_MERGES, PARSE_OPT_HIDDEN),
     ++			      1, PARSE_OPT_HIDDEN),
       		OPT_RERERE_AUTOUPDATE(&options.allow_rerere_autoupdate),
       		OPT_CALLBACK_F(0, "empty", &options, "{drop,keep,ask}",
       			       N_("how to handle commits that become empty"),
     @@ builtin/rebase.c: int cmd_rebase(int argc, const char **argv, const char *prefix
       		} else {
       			strbuf_reset(&buf);
       			strbuf_addf(&buf, "%s/interactive", merge_dir());
     +@@ builtin/rebase.c: int cmd_rebase(int argc, const char **argv, const char *prefix)
     + 			     builtin_rebase_options,
     + 			     builtin_rebase_usage, 0);
     + 
     ++	if (preserve_merges_selected)
     ++		die(_("--preserve-merges was replaced by --rebase-merges"));
     ++
     + 	if (action != ACTION_NONE && total_argc != 2) {
     + 		usage_with_options(builtin_rebase_usage,
     + 				   builtin_rebase_options);
      @@ builtin/rebase.c: int cmd_rebase(int argc, const char **argv, const char *prefix)
       		usage_with_options(builtin_rebase_usage,
       				   builtin_rebase_options);
  6:  a987e9439af !  6:  913647d8e76 git-svn: drop support for `--preserve-merges`
     @@ Commit message
          We already passed the `--rebase-merges` option to `git rebase` instead,
          now we make this move permanent.
      
     +    As pointed out by Ævar Arnfjörð Bjarmason, in contrast to the
     +    deprecation of `git rebase`'s `--preserve-merges` backend, `git svn`
     +    only deprecated this option in v2.25.0 (because this developer missed
     +    `git svn`'s use of that backend when deprecating the rebase backend
     +    running up to Git v2.22).
     +
     +    Still, v2.25.0 has been released on January 13th, 2020. In other words,
     +    `git svn` deprecated this option over one and a half years ago, _and_
     +    has been redirecting to the `--rebase-merges` option during all that
     +    time (read: `git svn rebase --preserve-merges` didn't do _precisely_
     +    what the user asked, since v2.25.0, anyway, it fell back to pretending
     +    that the user asked for `git svn rebase --rebase-merges` instead).
     +
     +    It is time to act on that deprecation and remove that option after all.
     +
          Signed-off-by: Johannes Schindelin <[email-masked]>
      
       ## Documentation/git-svn.txt ##
  7:  4492cca369c !  7:  b5a16e205e6 rebase: drop the internal `rebase--interactive` command
     @@ Commit message
          It was only used by the `--preserve-merges` backend, which we just
          removed.
      
     +    Helped-by: Alban Gruin <[email-masked]>
          Signed-off-by: Johannes Schindelin <[email-masked]>
      
       ## builtin/rebase.c ##
     +@@ builtin/rebase.c: enum action {
     + 	ACTION_ABORT,
     + 	ACTION_QUIT,
     + 	ACTION_EDIT_TODO,
     +-	ACTION_SHOW_CURRENT_PATCH,
     +-	ACTION_SHORTEN_OIDS,
     +-	ACTION_EXPAND_OIDS,
     +-	ACTION_CHECK_TODO_LIST,
     +-	ACTION_REARRANGE_SQUASH,
     +-	ACTION_ADD_EXEC
     ++	ACTION_SHOW_CURRENT_PATCH
     + };
     + 
     + static const char *action_names[] = { "undefined",
      @@ builtin/rebase.c: static const char *action_names[] = { "undefined",
       				      "edit_todo",
       				      "show_current_patch" };
     @@ builtin/rebase.c: static const char *action_names[] = { "undefined",
       {
       	const char *todo_file = rebase_path_todo();
      @@ builtin/rebase.c: static int run_sequencer_rebase(struct rebase_options *opts,
     + 	flags |= opts->rebase_merges ? TODO_LIST_REBASE_MERGES : 0;
     + 	flags |= opts->rebase_cousins > 0 ? TODO_LIST_REBASE_COUSINS : 0;
     + 	flags |= opts->root_with_onto ? TODO_LIST_ROOT_WITH_ONTO : 0;
     +-	flags |= command == ACTION_SHORTEN_OIDS ? TODO_LIST_SHORTEN_IDS : 0;
     + 	flags |= opts->reapply_cherry_picks ? TODO_LIST_REAPPLY_CHERRY_PICKS : 0;
     + 
     + 	switch (command) {
     +@@ builtin/rebase.c: static int run_sequencer_rebase(struct rebase_options *opts,
       
       		break;
       	}
  -:  ----------- >  8:  d23f245b684 rebase: remove obsolete code comment
  -:  ----------- >  9:  6905c8746ba rebase: stop mentioning the -p option in comments
  -:  ----------- > 10:  5bb04ea3f6c rebase: remove a no-longer-used function
  -:  ----------- > 11:  aae9323b25f sequencer: restrict scope of a formerly public function

-- 
gitgitgadget