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

Re: [PATCH 1/1] Introduce "precious" file concept

From
Duy Nguyen <pclouds@gmail.com>
Date
Feb 22, 2019, 09:46 UTC
Message-ID
<CACsJy8C377NmLv9edNYjinKAQf-P1y5+Nwhdj3vRkz_E__x43Q@mail.gmail.com>
In-Reply-To
<B168DCB1-7A69-4729-89C7-B513464DD468@gmx.net>
On Wed, Feb 20, 2019 at 6:11 PM Clemens Buchacher <drizzd@gmx.net> wrote:
Show 17 quoted lines
> >And requiring to mark trashable files manually duplicates a
> >lot of ignore patterns. Have a look at any .gitignore file, the
> >majority of them is for discardable files because "ignored" class was
> >created with those in mind (*.o and friends). So now you would need to
> >add more or less the same set of ignore rules in .gitattributes to
> >mark them trashable, and gitignore/gitattributes rules are not exactly
> >compatible, you can't just blindly copy them over. Every time you add
> >one more .gitignore rule, there's a good chance you need to add a
> >similar rule for trashable attribute.
>
> I agree that ignored precious files are typically a small subset of the ignore files. Maintaining separate rules for ignored files and for trashable files would result in a lot of duplication.
>
> On the other hand, how frequently do we really have to trash ignored files? Trashing a file should only be necessary if a tracked file overwrites an ignored file. When does this happen? I don't think it will happen for *.o files. So in most cases, there is simply no need to specify which files are precious. The default could simply be that all files are precious.
>
> To support more complex use cases, we could specify precious files in addition to ignored files. Only if we specify precious files (and/or enable the ignored-are-trashable config option on a repository level), all other files become trashable.
>
> Functionally this is equivalent the newbie option which you suggest, but I think it is not an issue of newbie vs experienced users but an issue of common vs special use cases.

So far the two conflicting cases are "git checkout/merge" and "git clean". Ignored files are valuable by default in the former, while it's expendable by default in the latter.

So if you add this ignored-are-trashable config key (defaults to false), git-clean -if will not do anything anymore. We _could_ advice the user to turn the config on (with all the consequences). I don't know if we have any other use cases that deserve the same advice.

Another option is simply leave the expendable/precious nature of ignored files undefined like it is now and handle case by case:

 - git-clean learns to use a new attribute "clean". Undefined
attribute is seen as +clean. To keep some files "precious" you update
.gitattributes and add -clean rules.
 - git merge/checkout learns another attribute,
checkout-overwrite-ignore? Undefined attribute is seen as
-checkout-overwrite-ignore (i.e. abort the operation).

We stay away from any generic attribute name in this direction to make clear it's only applicable to specific use cases.

-- 
Duy
Previous: Clemens BuchacherNext: Junio C Hamano
Message 15 of 19 in “Introduce "precious" file attribute”
  1. 0/1 Introduce "precious" file attributeNguyễn Thái Ngọc Duy, Feb 16, 2019
  2. 1/1 Introduce "precious" file conceptNguyễn Thái Ngọc Duy, Feb 16, 2019
  3. Ævar Arnfjörð BjarmasonFeb 16, 2019
  4. Duy NguyenFeb 17, 2019
  5. Ævar Arnfjörð BjarmasonFeb 18, 2019
  6. Duy NguyenFeb 18, 2019
  7. Junio C HamanoFeb 19, 2019
  8. Duy NguyenFeb 20, 2019
  9. Clemens BuchacherFeb 20, 2019
  10. Junio C HamanoFeb 20, 2019
  11. Ævar Arnfjörð BjarmasonFeb 20, 2019
  12. Duy NguyenFeb 20, 2019
  13. Ævar Arnfjörð BjarmasonFeb 20, 2019
  14. Clemens BuchacherFeb 20, 2019
  15. Duy NguyenFeb 22, 2019
  16. Junio C HamanoFeb 20, 2019
  17. Duy NguyenFeb 22, 2019
  18. Junio C HamanoFeb 22, 2019
  19. Steffen JostFeb 20, 2019

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.