* [PATCH] pull: do not warn when opt_ff is explicitly specified
@ 2020-09-23 9:56 Denton Liu
2020-09-23 16:40 ` Junio C Hamano
2020-09-23 18:25 ` Alex Henrie
0 siblings, 2 replies; 4+ messages in thread
From: Denton Liu @ 2020-09-23 9:56 UTC (permalink / raw)
To: Git Mailing List; +Cc: Alex Henrie
In d18c950a69 (pull: warn if the user didn't say whether to rebase or to
merge, 2020-03-09), `git pull` was taught to warn users if they
have `pull.rebase` unset or `pull.ff != "only"`. However, this warning
is a little too eager about happening.
If the warning is silenced by specifying `pull.ff = "only"`, as
instructed, the warning will arise again if the user runs
something like `git pull --no-ff`. However, the warning should not
happen as the user clearly knows what they're doing.
Don't display the warning if opt_ff is explicitly set by a command-line
option given by a user.
Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
builtin/pull.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/builtin/pull.c b/builtin/pull.c
index 015f6ded0b..307b4b5d21 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -83,6 +83,7 @@ static char *opt_commit;
static char *opt_edit;
static char *cleanup_arg;
static char *opt_ff;
+static int opt_ff_explicit;
static char *opt_verify_signatures;
static int opt_autostash = -1;
static int config_autostash;
@@ -344,7 +345,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 &&
+ if (!opt_ff_explicit && opt_verbosity >= 0 &&
(!opt_ff || strcmp(opt_ff, "--ff-only"))) {
warning(_("Pulling without specifying how to reconcile divergent branches is\n"
"discouraged. You can squelch this message by running one of the following\n"
@@ -933,6 +934,8 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
if (!opt_ff)
opt_ff = xstrdup_or_null(config_get_ff());
+ else
+ opt_ff_explicit = 1;
if (opt_rebase < 0)
opt_rebase = config_get_rebase();
--
2.28.0.760.g8d73e04208
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] pull: do not warn when opt_ff is explicitly specified
2020-09-23 9:56 [PATCH] pull: do not warn when opt_ff is explicitly specified Denton Liu
@ 2020-09-23 16:40 ` Junio C Hamano
2020-09-23 18:25 ` Alex Henrie
1 sibling, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2020-09-23 16:40 UTC (permalink / raw)
To: Denton Liu; +Cc: Git Mailing List, Alex Henrie
Denton Liu <liu.denton@gmail.com> writes:
> In d18c950a69 (pull: warn if the user didn't say whether to rebase or to
> merge, 2020-03-09), `git pull` was taught to warn users if they
> have `pull.rebase` unset or `pull.ff != "only"`. However, this warning
> is a little too eager about happening.
In d18c950a69, we added some tests to keep the warning working as
intended, and the fact that this patch does not touch anything in
the t/ directory means that its test coverage was not perfect.
We'd need to add a test or two to make sure this new behaviour is
protected against future breakages.
Thanks.
> If the warning is silenced by specifying `pull.ff = "only"`, as
> instructed, the warning will arise again if the user runs
> something like `git pull --no-ff`. However, the warning should not
> happen as the user clearly knows what they're doing.
>
> Don't display the warning if opt_ff is explicitly set by a command-line
> option given by a user.
>
> Signed-off-by: Denton Liu <liu.denton@gmail.com>
> ---
> builtin/pull.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/builtin/pull.c b/builtin/pull.c
> index 015f6ded0b..307b4b5d21 100644
> --- a/builtin/pull.c
> +++ b/builtin/pull.c
> @@ -83,6 +83,7 @@ static char *opt_commit;
> static char *opt_edit;
> static char *cleanup_arg;
> static char *opt_ff;
> +static int opt_ff_explicit;
> static char *opt_verify_signatures;
> static int opt_autostash = -1;
> static int config_autostash;
> @@ -344,7 +345,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 &&
> + if (!opt_ff_explicit && opt_verbosity >= 0 &&
> (!opt_ff || strcmp(opt_ff, "--ff-only"))) {
> warning(_("Pulling without specifying how to reconcile divergent branches is\n"
> "discouraged. You can squelch this message by running one of the following\n"
> @@ -933,6 +934,8 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
>
> if (!opt_ff)
> opt_ff = xstrdup_or_null(config_get_ff());
> + else
> + opt_ff_explicit = 1;
>
> if (opt_rebase < 0)
> opt_rebase = config_get_rebase();
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] pull: do not warn when opt_ff is explicitly specified
2020-09-23 9:56 [PATCH] pull: do not warn when opt_ff is explicitly specified Denton Liu
2020-09-23 16:40 ` Junio C Hamano
@ 2020-09-23 18:25 ` Alex Henrie
2020-09-23 18:33 ` Alex Henrie
1 sibling, 1 reply; 4+ messages in thread
From: Alex Henrie @ 2020-09-23 18:25 UTC (permalink / raw)
To: Denton Liu; +Cc: Git Mailing List
On Wed, Sep 23, 2020 at 3:56 AM Denton Liu <liu.denton@gmail.com> wrote:
>
> In d18c950a69 (pull: warn if the user didn't say whether to rebase or to
> merge, 2020-03-09), `git pull` was taught to warn users if they
> have `pull.rebase` unset or `pull.ff != "only"`. However, this warning
> is a little too eager about happening.
>
> If the warning is silenced by specifying `pull.ff = "only"`, as
> instructed, the warning will arise again if the user runs
> something like `git pull --no-ff`. However, the warning should not
> happen as the user clearly knows what they're doing.
>
> Don't display the warning if opt_ff is explicitly set by a command-line
> option given by a user.
Hi Denton, thanks for working on this! We can also assume that the
user knows what they are doing and does not need a warning if they
have run `git config --global pull.ff no`. So really, we can just get
rid of the check for strcmp(opt_ff, "--ff-only") altogether and
instead only check !opt_ff. Could you do that and add some more tests
to t5521-pull-options.sh?
-Alex
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] pull: do not warn when opt_ff is explicitly specified
2020-09-23 18:25 ` Alex Henrie
@ 2020-09-23 18:33 ` Alex Henrie
0 siblings, 0 replies; 4+ messages in thread
From: Alex Henrie @ 2020-09-23 18:33 UTC (permalink / raw)
To: Denton Liu; +Cc: Git Mailing List
On Wed, Sep 23, 2020 at 12:25 PM Alex Henrie <alexhenrie24@gmail.com> wrote:
>
> Hi Denton, thanks for working on this! We can also assume that the
> user knows what they are doing and does not need a warning if they
> have run `git config --global pull.ff no`. So really, we can just get
> rid of the check for strcmp(opt_ff, "--ff-only") altogether and
> instead only check !opt_ff. Could you do that and add some more tests
> to t5521-pull-options.sh?
Actually, never mind, I'll send the patch myself. When I originally
put in the warning I didn't stop to think that if the user is
proficient enough to set pull.ff to any value, they really don't need
a warning.
-Alex
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-09-23 18:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-23 9:56 [PATCH] pull: do not warn when opt_ff is explicitly specified Denton Liu
2020-09-23 16:40 ` Junio C Hamano
2020-09-23 18:25 ` Alex Henrie
2020-09-23 18:33 ` Alex Henrie
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).