The behavior of warning but merging anyway is difficult to explain to users because it sends mixed signals. End the confusion by firmly requiring the user to specify whether they want a merge or a rebase. Signed-off-by: Alex Henrie <alexhenrie24@xxxxxxxxx> --- Documentation/git-pull.txt | 14 +++++++++----- builtin/pull.c | 32 +++++++++++++++----------------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt index 5c3fb67c01..0fb185811e 100644 --- a/Documentation/git-pull.txt +++ b/Documentation/git-pull.txt @@ -16,13 +16,17 @@ DESCRIPTION ----------- Incorporates changes from a remote repository into the current -branch. In its default mode, `git pull` is shorthand for -`git fetch` followed by `git merge FETCH_HEAD`. +branch. `git pull` is shorthand for `git fetch` followed by +`git merge FETCH_HEAD` or `git rebase FETCH_HEAD`. More precisely, 'git pull' runs 'git fetch' with the given -parameters and calls 'git merge' to merge the retrieved branch -heads into the current branch. -With `--rebase`, it runs 'git rebase' instead of 'git merge'. +parameters and then, by default, attempts to fast-forward the +current branch to the remote branch head. If fast-forwarding +is not possible because the local and remote branches have +diverged, the `--rebase` option causes 'git rebase' to be +called to rebase the local branch upon the remote branch, and +the `--no-rebase` option causes 'git merge' to be called to +merge the retrieved branch heads into the current branch. <repository> should be the name of a remote repository as passed to linkgit:git-fetch[1]. <refspec> can name an diff --git a/builtin/pull.c b/builtin/pull.c index e8927fc2ff..21eaebc463 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -925,20 +925,20 @@ static int get_can_ff(struct object_id *orig_head, struct object_id *orig_merge_ return ret; } -static void show_advice_pull_non_ff(void) +static void die_pull_non_ff(void) { - advise(_("Pulling without specifying how to reconcile divergent branches is\n" - "discouraged. You can squelch this message by running one of the following\n" - "commands sometime before your next pull:\n" - "\n" - " git config pull.rebase false # merge (the default strategy)\n" - " git config pull.rebase true # rebase\n" - " git config pull.ff only # fast-forward only\n" - "\n" - "You can replace \"git config\" with \"git config --global\" to set a default\n" - "preference for all repositories. You can also pass --rebase, --no-rebase,\n" - "or --ff-only on the command line to override the configured default per\n" - "invocation.\n")); + die(_("Pulling without specifying how to reconcile divergent branches is not\n" + "possible. You can squelch this message by running one of the following\n" + "commands sometime before your next pull:\n" + "\n" + " git config pull.rebase false # merge\n" + " git config pull.rebase true # rebase\n" + " git config pull.ff only # fast-forward only\n" + "\n" + "You can replace \"git config\" with \"git config --global\" to set a default\n" + "preference for all repositories. You can also pass --rebase, --no-rebase,\n" + "or --ff-only on the command line to override the configured default per\n" + "invocation.\n")); } int cmd_pull(int argc, const char **argv, const char *prefix) @@ -1047,10 +1047,8 @@ int cmd_pull(int argc, const char **argv, const char *prefix) can_ff = get_can_ff(&orig_head, &merge_heads.oid[0]); - if (rebase_unspecified && !opt_ff && !can_ff) { - if (opt_verbosity >= 0) - show_advice_pull_non_ff(); - } + if (rebase_unspecified && !opt_ff && !can_ff) + die_pull_non_ff(); if (opt_rebase) { int ret = 0; -- 2.32.0.95.g4a22da5c5a