From: Sebastian Thiel <sebastian.thiel@icloud.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Josh Triplett <josh@joshtriplett.org>,
Kristoffer Haugsbakk <code@khaugsbakk.name>
Subject: Re: [RFC] Define "precious" attribute and support it in `git clean`
Date: Fri, 13 Oct 2023 11:09:27 +0200 [thread overview]
Message-ID: <9C4A2AFD-AAA2-4ABA-8A8B-2133FD870366@icloud.com> (raw)
In-Reply-To: <xmqqttqvg4lw.fsf@gitster.g>
On 12 Oct 2023, at 18:58, Junio C Hamano wrote:
> I presume you picked '$' > exactly because of this reason?
Yes, and because I thought '$' seems a great fit to represent value.
> I do not think it will be the end of the world if we don't do so,
> but it would be really really nice if we at least explored a way (or
> two) to make a big enough hole in the syntax to not just add
> "precious", but leave room to later add other traits, without having
> to worry about breaking the backward compatibility again. A
> simplest and suboptimal way may be to declare that a path that
> begins with '$' now needs '\'-quoting (just like your proposal),
> reserve '$$' as the precious prefix, and '$' followed by any other
> byte reserved for future use, but there may be better ideas.
Even though I'd love to go with the unextensible option assuming it would last
another 15 years, I can see the appeal of making it extensible from the start.
In a world where '$' is a prefix, I'd also think that it's now possible to
specify exclusion using '$!path' for completeness, if '$$path' marks 'path'
precious.
But if there is now a prefix, I feel that it might as well be chosen so that it
is easier to remember and/or less likely to cause conflicts. I think it must
have been that reason for pathspecs to choose ':' as their prefix, and it seems
to be an equally good choice here.
This would give us the following, taking the Linux kernel as example:
.*
!this-file-is-hidden-and-tracked
:!new-syntax-for-negation-for-completeness
\!an-ignored-file-with-leading-!
\:an-ignored-file-with-leading-:-which-is-technically-breaking
:$.config
:x-invalid-as-:-needs-either-!-or-$-to-follow-it
Now ':$path' would make any path precious, which is `:$.config` in the example
above.
How does that 'feel'? Is the similarity to pathspecs without being pathspecs
an anti-feature maybe?
>> Thus, to make this work, projects that ship the `.gitignore` files would *have
>> to add patterns* that make certain files precious.
>
> Not really. They do not have to do anything if they are content
> with the current Git ecosystem. And users who have precious stuff
> can mark them in the.git/info/excludes no?
Yes, but only if they control all the ignore patterns in their global files. If
the repository decides to exclude a file they deem precious, now it won't be
precious anymore as their ':$make-this-precious' pattern is seen sequentially
after the pattern in the repository.
For instance, tooling-specific ignores are typically fully controlled by the
user, like '/.idea/', which could now easily be made precious with ':$/idea/'.
But as the Linux kernel repository ships with a '.gitignore' file that includes
the '.*' pattern, users won't be able to 'get ahead' of that pattern with their
':$.config' specification.
> The only case that is
> problematic is when the project says 'foo' is ignored and expendable
> but the user thinks otherwise. So to make this work, projects that
> ship the ".gitignore" files have to avoid adding patterns to ignore
> things that it may reasonably be expected for its users to mark
> precious.
Yes, I think my paragraph above is exactly that but with examples to practice
the new syntax-proposal.
>
>> Such opted-in projects would produce `.gitignore` files like these:
>>
>> .*
>> $.config
>
> I would understand if you ignored "*~" or "*.o", but why ignore ".*"?
I don't have an answer, the example is from the Linux Kernel repository was
added in 1e65174a33784 [1].
I am definitely getting excited about the progress the syntax is making :),
thanks for proposing it!
[ Reference ]
1. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1e65174a33784
next prev parent reply other threads:[~2023-10-13 9:09 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-10 12:37 [RFC] Define "precious" attribute and support it in `git clean` Sebastian Thiel
2023-10-10 13:38 ` Kristoffer Haugsbakk
2023-10-10 14:10 ` Josh Triplett
2023-10-10 17:07 ` Junio C Hamano
2023-10-12 8:47 ` Josh Triplett
2023-10-10 19:10 ` Kristoffer Haugsbakk
2023-10-12 9:04 ` Josh Triplett
2023-10-10 17:02 ` Junio C Hamano
2023-10-11 10:06 ` Richard Kerry
2023-10-11 22:40 ` Jeff King
2023-10-11 23:35 ` Junio C Hamano
2023-10-12 10:55 ` Sebastian Thiel
2023-10-12 16:58 ` Junio C Hamano
2023-10-13 9:09 ` Sebastian Thiel [this message]
2023-10-13 16:39 ` Junio C Hamano
2023-10-14 7:30 ` Sebastian Thiel
2023-10-13 10:06 ` Phillip Wood
2023-10-14 16:10 ` Junio C Hamano
2023-10-13 11:25 ` Oswald Buddenhagen
2023-10-14 5:59 ` Josh Triplett
2023-10-14 17:41 ` Junio C Hamano
2023-10-15 6:44 ` Elijah Newren
2023-10-15 7:33 ` Sebastian Thiel
2023-10-15 16:31 ` Junio C Hamano
2023-10-16 6:02 ` Sebastian Thiel
2023-10-23 7:15 ` Sebastian Thiel
2023-10-29 6:44 ` Elijah Newren
2023-10-11 21:41 ` Kristoffer Haugsbakk
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9C4A2AFD-AAA2-4ABA-8A8B-2133FD870366@icloud.com \
--to=sebastian.thiel@icloud.com \
--cc=code@khaugsbakk.name \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=josh@joshtriplett.org \
/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.
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 NNTP newsgroup(s).