git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC] Define "precious" attribute and support it in `git clean`

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 10, 2023, 17:02 UTC
Message-ID
<xmqqttqytnqb.fsf@gitster.g>
In-Reply-To
<79901E6C-9839-4AB2-9360-9EBCA1AAE549@icloud.com>
Sebastian Thiel <sebastian.thiel@icloud.com> writes:
> I'd like to propose adding a new standard gitattribute "precious".
;-).

Over the years, I've seen many times scenarios that would have been helped if we had not just "tracked? ignored? unignored?" but also the fourth kind [*]. The word "ignored" (or "excluded") has always meant "not tracked, not to be tracked, and expendable" to Git, and "ignored but unexpendable" class was missing. I even used the term "precious" myself in those discussions. At the concept level, I support the effort 100%, but as always, the devil will be in the details.

Scenarios that people wished for "precious" traditionally have been
 * You are working on 'master'.  You have in your .gitignore or
   .git/info/exclude a line to ignore path A, and have random
   scribbles in a throw-away file there.  There is another branch
   'seen', where they added some tracked contents at path A/B.  You
   do "git checkout seen" and your file A that is an expendable file,
   because it is listed as ignored in .git/info/exclude, is removed
   to make room for creating A/B.
 * Similar situation, but this time, 'seen' branch added a tracked
   contents at path A.  Again, "git checkout seen" will discard the
   expendable file A and replace it with tracked contents.
 * Instead of "git checkout", you decide to merge the branch 'seen'
   to the checkout of 'master', where you have an ignored path A.
   Because merging 'seen' would need to bring the tracked contents
   of either A/B (in the first scenario above) or A (in the second
   scenario), your "expendable" A will be removed to make room.

In previous discussions, nobody was disturbed that "git clean" was unaware of the "precious" class, but if we were to have the "precious" class in addition to "ignored" aka "expendable", I would not oppose to teach "git clean" about it, too.

There was an early and rough design draft there in
https://lore.kernel.org/git/7vipsnar23.fsf@alter.siamese.dyndns.org/
which probably is worth a read, too.

Even though I referred to the precious _attribute_ in some of these discussions, between the attribute mechanism and the ignore mechanism, I am actually leaning toward suggesting to extend the exclude/ignore mechanism to introduce the "precious" class. That way, we can avoid possible snafu arising from marking a path in .gitignore as ignored, and in .gitattrbutes as precious, and have to figure out how these two settings are to work together.

In any case, the "precious" paths are expected to be small minority of what people never want to "git add" or "git commit", so coming up with a special syntax to be used in .gitignore, even if that special syntax is ugly and cumbersome to type, would be perfectly OK.

[Reference]
 * https://lore.kernel.org/git/7viptp9jos.fsf@alter.siamese.dyndns.org/
 * https://lore.kernel.org/git/xmqqva534vnb.fsf@gitster-ct.c.googlers.com/
Previous: Josh TriplettNext: Richard Kerry
Message 8 of 28 in “[RFC] Define "precious" attribute and support it in `git clean`”
  1. Sebastian ThielOct 10, 2023
  2. Kristoffer HaugsbakkOct 10, 2023
  3. Josh TriplettOct 10, 2023
  4. Junio C HamanoOct 10, 2023
  5. Josh TriplettOct 12, 2023
  6. Kristoffer HaugsbakkOct 10, 2023
  7. Josh TriplettOct 12, 2023
  8. Junio C HamanoOct 10, 2023
  9. Richard KerryOct 11, 2023
  10. Jeff KingOct 11, 2023
  11. Junio C HamanoOct 11, 2023
  12. Sebastian ThielOct 12, 2023
  13. Junio C HamanoOct 12, 2023
  14. Sebastian ThielOct 13, 2023
  15. Junio C HamanoOct 13, 2023
  16. Sebastian ThielOct 14, 2023
  17. Phillip WoodOct 13, 2023
  18. Junio C HamanoOct 14, 2023
  19. Oswald BuddenhagenOct 13, 2023
  20. Josh TriplettOct 14, 2023
  21. Junio C HamanoOct 14, 2023
  22. Elijah NewrenOct 15, 2023
  23. Sebastian ThielOct 15, 2023
  24. Junio C HamanoOct 15, 2023
  25. Sebastian ThielOct 16, 2023
  26. Sebastian ThielOct 23, 2023
  27. Elijah NewrenOct 29, 2023
  28. Kristoffer HaugsbakkOct 11, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.