Skip to content

Commit 278f4be

Browse files
felipecgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 77a7ec6 commit 278f4be

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

builtin/pull.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include "commit-reach.h"
2828
#include "sequencer.h"
2929

30+
static int default_mode;
31+
3032
/**
3133
* Parses the value of --rebase. If value is a false value, returns
3234
* 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)
344346
if (!git_config_get_value("pull.rebase", &value))
345347
return parse_config_rebase("pull.rebase", value, 1);
346348

347-
if (opt_verbosity >= 0 && !opt_ff) {
348-
advise(_("Pulling without specifying how to reconcile divergent branches is\n"
349-
"discouraged. You can squelch this message by running one of the following\n"
350-
"commands sometime before your next pull:\n"
351-
"\n"
352-
" git config pull.rebase false # merge (the default strategy)\n"
353-
" git config pull.rebase true # rebase\n"
354-
" git config pull.ff only # fast-forward only\n"
355-
"\n"
356-
"You can replace \"git config\" with \"git config --global\" to set a default\n"
357-
"preference for all repositories. You can also pass --rebase, --no-rebase,\n"
358-
"or --ff-only on the command line to override the configured default per\n"
359-
"invocation.\n"));
360-
}
349+
default_mode = 1;
361350

362351
return REBASE_FALSE;
363352
}
@@ -1040,6 +1029,21 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
10401029
if (opt_rebase && merge_heads.nr > 1)
10411030
die(_("Cannot rebase onto multiple branches."));
10421031

1032+
if (default_mode && opt_verbosity >= 0 && !opt_ff) {
1033+
advise(_("Pulling without specifying how to reconcile divergent branches is\n"
1034+
"discouraged. You can squelch this message by running one of the following\n"
1035+
"commands sometime before your next pull:\n"
1036+
"\n"
1037+
" git config pull.rebase false # merge (the default strategy)\n"
1038+
" git config pull.rebase true # rebase\n"
1039+
" git config pull.ff only # fast-forward only\n"
1040+
"\n"
1041+
"You can replace \"git config\" with \"git config --global\" to set a default\n"
1042+
"preference for all repositories. You can also pass --rebase, --no-rebase,\n"
1043+
"or --ff-only on the command line to override the configured default per\n"
1044+
"invocation.\n"));
1045+
}
1046+
10431047
if (opt_rebase) {
10441048
int ret = 0;
10451049
int ran_ff = 0;

0 commit comments

Comments
 (0)