From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-4.2 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 86B591F670 for ; Wed, 20 Oct 2021 17:09:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230354AbhJTRMM (ORCPT ); Wed, 20 Oct 2021 13:12:12 -0400 Received: from cloud.peff.net ([104.130.231.41]:42788 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230316AbhJTRMM (ORCPT ); Wed, 20 Oct 2021 13:12:12 -0400 Received: (qmail 9978 invoked by uid 109); 20 Oct 2021 17:09:57 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Wed, 20 Oct 2021 17:09:57 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 26466 invoked by uid 111); 20 Oct 2021 17:09:56 -0000 Received: from Unknown (HELO sigill.intra.peff.net) (10.0.1.3) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Wed, 20 Oct 2021 13:09:56 -0400 Authentication-Results: peff.net; auth=none Date: Wed, 20 Oct 2021 13:09:55 -0400 From: Jeff King To: Junio C Hamano Cc: Kenneth Arnold , Alex Henrie , "git@vger.kernel.org" Subject: Re: "Not possible to fast-forward" when pull.ff=only and new commits on remote Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Wed, Oct 20, 2021 at 09:28:08AM -0700, Junio C Hamano wrote: > Jeff King writes: > > > Thanks for reporting, this is an interesting case. I agree that it > > probably ought to continue to be a noop. There is nothing to pull, and > > so the question of ff-versus-merge should not even enter into it. > > Probably something along this line? Hasn't been tested beyond > compiling and passing > > $ git checkout master && ./git pull --ff-only -v . maint > > but that should be sufficient, I hope. Yeah, this direction makes sense to me. Just looking over the patch... > +/* > + * Is orig_head is a descendant of _all_ merge_heads? > + * Unfortunately is_descendant_of() cannot be used as it > + * asks if orig_head is a descendant of at least one of them. > + */ > +static int already_up_to_date(struct object_id *orig_head, > + struct oid_array *merge_heads) > +{ > + int i; > + struct commit *ours; > + > + ours = lookup_commit_reference(the_repository, orig_head); I think orig_head can be the null oid if we're on an unborn HEAD. I guess you'd want to return "1" in that case (but I could be wrong; it looks like get_can_ff() assumes it's valid, so perhaps that case is handled earlier). I'd expect that merge_heads can never be empty here, or we'd bail earlier in the command, but I didn't check (though again, get_can_ff() seems to assume there's at least one). > + for (i = 0; i < merge_heads->nr; i++) { > + struct commit_list *list = NULL; > + struct commit *theirs; > + int ok; > + > + theirs = lookup_commit_reference(the_repository, &merge_heads->oid[i]); > + commit_list_insert(theirs, &list); > + ok = repo_is_descendant_of(the_repository, ours, list); > + free_commit_list(list); > + if (!ok) > + return 0; > + } Running a sequence of traversals like this can be slow, because we may walk over the same history again and again. But I think in the usual non-octopus cases we'd only have one entry, so we'd only be adding a single extra merge-base traversal in most cases. It does feel like this could be combined with get_can_ff() somehow so that we're not adding even that single traversal. But I expect that may be hard to do because of the multiple heads (e.g., we cannot use the usual ahead/behind code). -Peff