git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: John Cai <johncai86@gmail.com>
Cc: John Cai via GitGitGadget <gitgitgadget@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH 1/2] diff: use HEAD for attributes when using bare repository
Date: Tue, 14 Mar 2023 13:37:48 -0700	[thread overview]
Message-ID: <xmqqy1nzoyqr.fsf@gitster.g> (raw)
In-Reply-To: <20230314193839.wevenngf324pijhb@pop-os> (John Cai's message of "Tue, 14 Mar 2023 15:38:39 -0400")

John Cai <johncai86@gmail.com> writes:

>> Just for illustration, here is one way to do so.
>> 
>> The implementation goes in the opposite direction from the more
>> recent trend, which is why I am not making it an official patch, but
>
> Could you explain why this goes against the "more recent trend" for my
> understanding?

The illustration uses a global state.

The recent trend is to reduce reliance on global states and use the
repository object and others that hold such state through the
callchain.

But a new global variable that holds the fallback tree-ish object name
was a so convenient way to illustrate the core of the idea, without
having to change many callchains.

>> with this you can do things like:
>> 
>>   $ git --attr-source=e83c5163 check-attr whitespace cache.h
>>   cache.h: whitespace: unspecified
>>   $ git --attr-source=e2f6331a142^ check-attr whitespace cache.h
>>   cache.h: whitespace: set
>>   $ git --attr-source=HEAD check-attr whitespace cache.h
>>   cache.h: whitespace: indent,trail,space
>
> I like the idea of an option that is global. For git-check-attr however, we

I guess I shouldn't have used check-attr to avoid confusion.

The point is that the internal mechanisms introduced by 47cfc9bd
(attr: add flag `--source` to work with tree-ish, 2023-01-14), which
taught check-attr the --source option and is reused by this
illustration patch, was a good idea, but its UI was a mistake.  We
do not need per-command --source option the commit adds if we did
the global option from day one.  Yes, I think we can deprecate the
"--source" option from there, if we all prefer the global option
avenue.  I _think_ git_all_attrs() needs to be told about the
default attr-source trick (which I didn't touch in my illustration
patch) before it happens, though.

If you used the mechanism in the illustration patch I gave you, and
adjusted the test part of your patch to match (i.e. "diff" does not
learn "--attr-source" option, but "git --attr-source=... diff" is
how you make it read attributes from a tree-ish), would the result
work well, or do we need more work to make it usable?  How well do
other commands (e.g. "git show") work in the same test repository
you created in your version?

Thanks.

  reply	other threads:[~2023-03-14 20:38 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 [this message]
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
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=xmqqy1nzoyqr.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=johncai86@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).