summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorFelipe Contreras <felipe.contreras@gmail.com>2020-12-12 16:52:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-12-14 17:03:17 (GMT)
commit278f4be806f93579c64cd9993fdad2eb589f86c6 (patch)
tree8bca30d506814e16d4892e8a51e2cf5ea51eca20 /builtin
parent77a7ec632952ee335cb544fee7c6b3fb1c5ec147 (diff)
downloadgit-278f4be806f93579c64cd9993fdad2eb589f86c6.zip
git-278f4be806f93579c64cd9993fdad2eb589f86c6.tar.gz
git-278f4be806f93579c64cd9993fdad2eb589f86c6.tar.bz2
pull: give the advice for choosing rebase/merge much later
Eventually we want to be omit the advice when we can fast-forward in which case there is no reason to require the user to choose between rebase or merge. In order to do so, we need to delay giving the advice up to the point where we can check if we can fast-forward or not. Additionally, config_get_rebase() was probably never its true home. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/pull.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/builtin/pull.c b/builtin/pull.c
index 03e6d53..ff8e3ce 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -27,6 +27,8 @@
#include "commit-reach.h"
#include "sequencer.h"
+static int default_mode;
+
/**
* Parses the value of --rebase. If value is a false value, returns
* REBASE_FALSE. If value is a true value, returns REBASE_TRUE. If value is
@@ -344,20 +346,7 @@ static enum rebase_type config_get_rebase(void)
if (!git_config_get_value("pull.rebase", &value))
return parse_config_rebase("pull.rebase", value, 1);
- if (opt_verbosity >= 0 && !opt_ff) {
- 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"));
- }
+ default_mode = 1;
return REBASE_FALSE;
}
@@ -1040,6 +1029,21 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
if (opt_rebase && merge_heads.nr > 1)
die(_("Cannot rebase onto multiple branches."));
+ if (default_mode && opt_verbosity >= 0 && !opt_ff) {
+ 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"));
+ }
+
if (opt_rebase) {
int ret = 0;
int ran_ff = 0;