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.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,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 4648B1F953 for ; Wed, 27 Oct 2021 02:28:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237879AbhJ0Cae (ORCPT ); Tue, 26 Oct 2021 22:30:34 -0400 Received: from pb-smtp20.pobox.com ([173.228.157.52]:53311 "EHLO pb-smtp20.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230243AbhJ0Cad (ORCPT ); Tue, 26 Oct 2021 22:30:33 -0400 Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 3252C153B49; Tue, 26 Oct 2021 22:28:09 -0400 (EDT) (envelope-from junio@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:message-id:mime-version:content-type; s=sasl; bh=RaejG6tgAs6mkAcOsQ2JjoA/OMn2G8QcPtxsL8ZJtHs=; b=wB22 SSSW8cinvgWrX627FfMLnjEb7h073cV0VTbGIR24RK/SjVZqIrUBqNWFQ6GOcYPy CQrFJKSRC0h5ywkmvYQA/SlT0tIq0dkXRANiuyH9vDpIClXcwYROMkSe96TjqIXZ x44RBG8iuD4F6XB37XT0iNIMVjpOpnrvb43FE3I= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 2AE3D153B48; Tue, 26 Oct 2021 22:28:09 -0400 (EDT) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [104.133.2.91]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp20.pobox.com (Postfix) with ESMTPSA id 3C4B8153B47; Tue, 26 Oct 2021 22:28:05 -0400 (EDT) (envelope-from junio@pobox.com) From: Junio C Hamano To: Glen Choo Cc: git@vger.kernel.org Subject: Re: [PATCH v3 2/4] remote: use remote_state parameter internally References: Date: Tue, 26 Oct 2021 19:28:04 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 840327B4-36CD-11EC-9722-F327CE9DA9D6-77302942!pb-smtp20.pobox.com Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Glen Choo writes: > Junio C Hamano writes: > >>> c) Replace the backpointer with a remote_state parameter. Expressive and >>> fits the paradigm of "defaulting to the repo when needed", but >>> interfaces are repetitive and shifts the responsibility of >>> correctness to the caller (see v2). >> >> ... if we want to support the what-if callers, I >> think the best approach would be a slight variant of c) above. >> >> That is, pass branch and remote_state as two parameters, and when >> branch is not NULL, barf if it is not among remote_state.branches[], >> to protect against nonsense combinations. > > Sounds reasonable to me. The resulting interface would look like the v2 > one, but internally, this additional safety check will prevent misuse. Hopefully. Of course I think the implementation of the safety would actually be done, not by iterationg over branches[] array, but just checking branch->remote_state == remote_state pointer equality. > This "longer term direction" sounds like what I envisioned with (e). I > agree that detached HEAD is a state that should be expressed with more > than just NULL, though I'm not sure that "struct branch" is the correct > abstraction. No point bikeshedding now of course, we'll cross that > bridge when we get there ;) I actually was hoping that the time to cross the bridge was now, though ;-)