git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: John Cai <johncai86@gmail.com>,
	Philippe Blain <levraiphilippeblain@gmail.com>,
	John Cai via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org
Subject: Re: [PATCH 0/2] diff: support bare repositories when reading gitattributes for diff algorithm
Date: Thu, 16 Mar 2023 10:29:57 -0400	[thread overview]
Message-ID: <ZBMn5T6zfKK+PYUe@coredump.intra.peff.net> (raw)
In-Reply-To: <xmqqttynoyg4.fsf@gitster.g>

On Tue, Mar 14, 2023 at 01:44:11PM -0700, Junio C Hamano wrote:

> John Cai <johncai86@gmail.com> 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
> > <tree-ish> 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.<filetype>.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

  reply	other threads:[~2023-03-16 14:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-14  1:53 [PATCH 0/2] diff: support bare repositories when reading gitattributes for diff algorithm John Cai via GitGitGadget
2023-03-14  1:53 ` [PATCH 1/2] diff: use HEAD for attributes when using bare repository John Cai via GitGitGadget
2023-03-14 16:54   ` Junio C Hamano
2023-03-14 17:43     ` Junio C Hamano
2023-03-14 19:38       ` John Cai
2023-03-14 20:37         ` Junio C Hamano
2023-03-16 16:46           ` John Cai
2023-03-16 22:56             ` Junio C Hamano
2023-03-17 14:11               ` John Cai
2023-03-14  1:53 ` [PATCH 2/2] diff: add --attr-source to read gitattributes from a commit John Cai via GitGitGadget
2023-03-14 17:21 ` [PATCH 0/2] diff: support bare repositories when reading gitattributes for diff algorithm Philippe Blain
2023-03-14 19:18   ` John Cai
2023-03-14 20:44     ` Junio C Hamano
2023-03-16 14:29       ` Jeff King [this message]
2023-03-16 16:44         ` Junio C Hamano

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=ZBMn5T6zfKK+PYUe@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=johncai86@gmail.com \
    --cc=levraiphilippeblain@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).