From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id DC1DD1F428 for ; Thu, 16 Mar 2023 14:30:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231150AbjCPOaB (ORCPT ); Thu, 16 Mar 2023 10:30:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230325AbjCPOaA (ORCPT ); Thu, 16 Mar 2023 10:30:00 -0400 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9B7CCDE0 for ; Thu, 16 Mar 2023 07:29:58 -0700 (PDT) Received: (qmail 1052 invoked by uid 109); 16 Mar 2023 14:29:58 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Thu, 16 Mar 2023 14:29:58 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 14192 invoked by uid 111); 16 Mar 2023 14:29:57 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Thu, 16 Mar 2023 10:29:57 -0400 Authentication-Results: peff.net; auth=none Date: Thu, 16 Mar 2023 10:29:57 -0400 From: Jeff King To: Junio C Hamano Cc: John Cai , Philippe Blain , John Cai via GitGitGadget , git@vger.kernel.org Subject: Re: [PATCH 0/2] diff: support bare repositories when reading gitattributes for diff algorithm Message-ID: References: <20230314191833.qmiisyvsu2ppu4sh@pop-os> 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 Tue, Mar 14, 2023 at 01:44:11PM -0700, Junio C Hamano wrote: > John Cai writes: > > > I wasn't aware of those config options. Indeed that's a good option! My only > > concern with that is that there is already some precedence for passing a > > as a source for attributes in [1], so I thought adding a command line > > option would be somewhat consistent. > > > > But I can also see the benefit of using a config value since there is also > > precedence because of mailmap.file and mailmap.blob. Not sure what others think, > > but this may be the less invasive way to go. > > I actually hate these one-off variables, and I wish we didn't do > mailmap.file or mailmap.blob at all. Instead we could have taught > the machinery to read from $GIT_DIR/info/mailmap just like the > exclude and the attribute machinery already knows to read excludea > and attributes files in the directory. I don't think $GIT_DIR/info/mailmap is a good substitute for mailmap.blob. The point there is to pull it from the repository, and you'd have to do: git cat-file HEAD:.mailmap >.git/info/mailmap before each command to get the equivalent. It is even worse for attributes, because the in-tree representation is not even a single file that is compatible with $GIT_DIR/ (there can be many attributes spread throughout the tree). It's true that mailmap.file, when specified in the local config, is redundant with a repo-level info/mailmap file. I always assumed that people put it in their ~/.gitconfig, though, to cover multiple projects (just like we have core.attributesFile in addition to the in-repo meta-file). > As your "per filetype (determined by the attribute) diff algorithm > in a bare repository" feature already depends on being able to use > config (as the look-up is "attributes determines the diff filetype > name, and then diff..algo is looked up in the config") to > configure, it does not sound too bad to add the attribute info in > the $GIT_DIR/info/attributes file in your bare repository (and you'd > set the algorithm in $GIT_DIR/config file there), and it would just > work without any new "read from HEAD" feature, I would presume? I don't think that's quite a substitute. If you have a static list of attributes, that is OK (though you are presumably better off with /etc/gitattributes or similar that covers all repos). But if you want to respect in-repo ones, you need to look at the whole tree (and can't even just dump them out). It does seem at first glance that you are limited to a static list of attributes, because any diff "type" you mention has to have a corresponding entry in the config to do anything useful. But these lists are only loosely coupled. For example, you could have static entries like this: # in config [diff "json"] algorithm = patience # in attributes *.json diff=json but still tell users that "json" is a well-known name, and if they want to get the same treatment for an arbitrary file "foo" that they would get for "foo.json", they have to add attributes mapping it, like: foo diff=json inside their repo. -Peff