From: John Cai <johncai86@gmail.com>
To: Junio C Hamano <gitster@pobox.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: Thu, 16 Mar 2023 12:46:51 -0400 [thread overview]
Message-ID: <9E479AA2-2D54-4CAF-899B-B25894B746AA@gmail.com> (raw)
In-Reply-To: <xmqqy1nzoyqr.fsf@gitster.g>
Hi Junio,
On 14 Mar 2023, at 16:37, Junio C Hamano wrote:
> 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.
Ah I see--in that case, what would be a good object to put this state into? Mabe
repo_settings?
>
> 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.
Good point. I think to have a global flag would be a better user experience.
>
> 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?
I think it works pretty smoothly. I adjusted my tests to work with this git
flag, and I also tested git show and it works well.
In fact, your proposal would serve the needs of my patch independently of any of
the diff code, which is nice.
>
> Thanks.
Thanks,
John
next prev parent reply other threads:[~2023-03-16 16:47 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 [this message]
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=9E479AA2-2D54-4CAF-899B-B25894B746AA@gmail.com \
--to=johncai86@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.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).