git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Alex Henrie <alexhenrie24@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Phillip Wood" <phillip.wood123@gmail.com>,
	"Git mailing list" <git@vger.kernel.org>,
	"Elijah Newren" <newren@gmail.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: Re: [PATCH RFC] rebase: respect --ff-only option
Date: Mon, 5 Jul 2021 13:48:05 -0600	[thread overview]
Message-ID: <CAMMLpeQG-eYgWTXyG0YzgN3U8QDASAtNFpxyXDFFPSVNzfw18g@mail.gmail.com> (raw)
In-Reply-To: <xmqqlf6kmup4.fsf@gitster.g>

On Mon, Jul 5, 2021 at 2:53 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
>
> On 05/07/2021 05:45, Alex Henrie wrote:
> > index 12f093121d..b88f0cbcca 100644
> > --- a/builtin/rebase.c
> > +++ b/builtin/rebase.c
> > @@ -1345,12 +1349,14 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
> >                        N_("ignore changes in whitespace")),
> >               OPT_PASSTHRU_ARGV(0, "whitespace", &options.git_am_opts,
> >                                 N_("action"), N_("passed to 'git apply'"), 0),
> > -             OPT_BIT('f', "force-rebase", &options.flags,
> > -                     N_("cherry-pick all commits, even if unchanged"),
> > -                     REBASE_FORCE),
> > -             OPT_BIT(0, "no-ff", &options.flags,
> > -                     N_("cherry-pick all commits, even if unchanged"),
> > -                     REBASE_FORCE),
> > +             OPT_SET_INT_F('f', "force-rebase", &options.fast_forward,
> > +                           N_("cherry-pick all commits, even if unchanged"),
> > +                           FF_NO, PARSE_OPT_NONEG),
>
> Why does this change rebase to start rejecting --no-force-rebase? This
> is the sort of behavior change that deserves a mention in the commit
> message.

That was accidental, sorry. I copied and pasted option code from
another place without paying attention to the PARSE_OPT_NONEG.

> > +             OPT_SET_INT(0, "ff", &options.fast_forward, N_("allow fast-forward"),
> > +                         FF_ALLOW),
>
> The useful option when rebasing is '--no-ff', now that will no longer
> appear in the output of 'git rebase -h'

Yeah, that's a good point.

On Mon, Jul 5, 2021 at 3:36 AM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
>
> On Sun, Jul 04 2021, Alex Henrie wrote:
>
> > +int error_ff_impossible(void)
> > +{
> > +     error(_("Not possible to fast-forward, aborting."));
> > +     return -1;
> > +}
>
> Here's one, the idiom is just "return error", i.e it itself returns -1.

That would indeed be simpler; thanks for pointing that out.

> FWIW I'd consider doing:
>
>         /* earlier, static scope */
>         static const char error_ff_impossible = N_("Not possible...");
>         /* later, function scope */
>             return error(error_ff_impossible);
>
> It's a small difference, but for translators who use the jump-to-source
> while translating not having the indirection helps, and in this case
> it's just used 3 times...

Wouldn't jump-to-source take the user to the English text in advice.c
either way? How does putting it in a static variable help?

> > [...]
> >       if (parent && parse_commit(parent) < 0)
> >               /* TRANSLATORS: The first %s will be a "todo" command like
> > @@ -2764,7 +2769,7 @@ static int populate_opts_cb(const char *key, const char *value, void *data)
> >       else if (!strcmp(key, "options.record-origin"))
> >               opts->record_origin = git_config_bool_or_int(key, value, &error_flag);
> >       else if (!strcmp(key, "options.allow-ff"))
> > -             opts->allow_ff = git_config_bool_or_int(key, value, &error_flag);
> > +             opts->fast_forward = git_config_bool_or_int(key, value, &error_flag) ? FF_ALLOW : FF_NO;
>
> Since we're on nits, we try to wrap at 80 characters.

Thanks, I didn't know what the exact cutoff was.

> > +test_expect_success "rebase: impossible fast-forward rebase" '
> > +     test_config rebase.autostash true &&
> > +     git reset --hard &&
> > +     echo dirty >>file1 &&
> > +     (git rebase --ff-only unrelated-onto-branch || true) &&
>
> Never "||" git commands, better as test_might_fail. We don't want to
> hide segfaults.

Also thanks for the advice here.

On Mon, Jul 5, 2021 at 10:50 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> Phillip Wood <phillip.wood123@gmail.com> writes:
>
> > Looking at origin/seen:builtin/pull.c we already check if we can
> > fast-forward and unconditionally merge in that case irrespective of
> > any '--rebase' option or pull.rebase config. It should be simple for
> > pull to error out if '--ff-only' is given and we cannot fast-forward.
>
> Excellent.
>
> Even though teaching even more special case on the "git pull" side
> makes me feel somewhat dirty, but I think it would be a small price
> to pay, and the end result would save an useless fork whose sole
> purpose is to make the integration step after fetch fail when "pull"
> can easily tell, as you said, that it ought to fail, so overall it
> would probably be a net win.

Okay, so it sounds like I should just scrap this patch and try again,
after "pull: cleanup autostash check" is in master, with a patch that
only modifies `git pull` and not `git rebase`. (Unless someone more
experienced wants to take over, which would be fine by me.)

Thanks anyway to Phillip and Ævar: Your feedback will help me write
better patches in the future.

-Alex

  reply	other threads:[~2021-07-05 19:48 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-05  4:45 [PATCH RFC] rebase: respect --ff-only option Alex Henrie
2021-07-05  8:53 ` Phillip Wood
2021-07-05  9:58   ` Junio C Hamano
2021-07-05 12:09     ` Felipe Contreras
2021-07-05 13:54     ` Phillip Wood
2021-07-07  0:30       ` Felipe Contreras
2021-07-05 15:29   ` Phillip Wood
2021-07-05 16:50     ` Junio C Hamano
2021-07-05 19:23       ` Junio C Hamano
2021-07-05 19:48         ` Alex Henrie [this message]
2021-07-06 13:52           ` Phillip Wood
2021-07-06 14:43           ` Ævar Arnfjörð Bjarmason
2021-07-07  1:13       ` Felipe Contreras
2021-07-05  9:27 ` Ævar Arnfjörð Bjarmason
2021-07-05 12:00 ` Felipe Contreras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMMLpeQG-eYgWTXyG0YzgN3U8QDASAtNFpxyXDFFPSVNzfw18g@mail.gmail.com \
    --to=alexhenrie24@gmail.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=newren@gmail.com \
    --cc=phillip.wood123@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).