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

.gitignore, .gitattributes, .gitmodules, .gitprecious?,.gitacls? etc.

From
DKDmitry Kakurin <dmitry.kakurin@gmail.com>
Date
Aug 27, 2007, 20:27 UTC
Message-ID
<a1bbc6950708271327x4dd948d4m8e9e35f757a7d92e@mail.gmail.com>
In-Reply-To
<4C603F7C51884DF8AFAEC3F6E263798D@ntdev.corp.microsoft.com>
----- Original Message -----
From: "Petr Baudis" <pasky@suse.cz>
Show 19 quoted lines
> On Sun, Aug 26, 2007 at 10:02:50AM CEST, Dmitry Kakurin wrote:
>>>> My knowledge of Git internals is quite limited, but if *I* were to do
>>>> it right now, I'd introduce a META entry in every TREE object that
>>>> would point to a BLOB that contains combined content of
>>>> .gitattributes, .gitignore etc.
>>> A tree that has .gitattributes (and I am assuming in the longer
>>> term you can use "ignore" and "precious" in .gitattributes
>>> instead of using .gitignore) POINTS TO A BLOB already, so what
>>> you are saying does not add anything to what we already have,
>>> other than that you are renaming .gitattributes to "META ENTRY".
>>
>> Almost true! The difference is: META BLOBS are not created as files in the
>> workspace (not during checkout, not ever).
>> In order to edit it you'd have to use 'git meta' command.
>> So once again, there is only one place to check for metadata - the index.
>
> It's still not clear to me how this would help anything, though I didn't
> watch late Git development. Can you explain some particular scenario
> where this would improve the current situation?
Here is the problem: we need to apply crlf attributes to a file. We
could have .gitattributes both in the index and in the worktree.
Which one do we use?
In general .gitattributes file could be (U)nchanged, (C)hanged, (NP)
NotPresent in each place.
This gives us 3x3 matrix = 9 special cases to handle. When you think
about this a little more you realize that even that
is not enough and we need to take into account direction of data
movement (index -> filesystem or vice versa).
This doubles the matrix to 18 cases. Even if we come up with a very
good choice for every case (which is doubtful)
there is no way this could be *easily* explained to end user, or even memorized.
This leads to a simple idea that mostly works:
1. when files are moved from index to filesystem, then only
.gitattributes in the index is used, if it's not there == no special
attributes.
2. when files are moved from filesystem to index, then only
.gitattributes in filesystem is used, again if it's not there == no
special attributes.

Then, in any operation, only one .gitattributes is taken into account. We could stop here, but to me this redundancy still has some room for confusion and looks unnecessary. Plus there is still room for unintentional abuse (by mistake).

That's why I think it's a good idea to always have only one .gitattributes.
- Dmitry
Previous: Jan HudecNext: Jan Hudec
Message 22 of 28 in “.gitignore, .gitattributes, .gitmodules, .gitprecious?, .gitacls? etc.”
  1. Dmitry KakurinAug 26, 2007
  2. Junio C HamanoAug 26, 2007
  3. Dmitry KakurinAug 26, 2007
  4. Junio C HamanoAug 26, 2007
  5. Dmitry KakurinAug 26, 2007
  6. Junio C HamanoAug 26, 2007
  7. Dmitry KakurinAug 26, 2007
  8. Petr BaudisAug 26, 2007
  9. Sam VilainAug 27, 2007
  10. David KastrupAug 27, 2007
  11. Sam VilainAug 27, 2007
  12. David KastrupAug 27, 2007
  13. Johannes SchindelinAug 27, 2007
  14. Johannes SchindelinAug 26, 2007
  15. martin f krafftAug 27, 2007
  16. Sergio CallegariAug 27, 2007
  17. David KastrupAug 27, 2007
  18. Petr BaudisAug 27, 2007
  19. Sergio CallegariAug 27, 2007
  20. Sergio CallegariAug 27, 2007
  21. Jan HudecSep 4, 2007
  22. .gitignore, .gitattributes, .gitmodules, .gitprecious?,.gitacls? etc.Dmitry Kakurin, Aug 27, 2007
  23. Jan HudecSep 4, 2007
  24. Dmitry KakurinSep 5, 2007
  25. Junio C HamanoSep 5, 2007
  26. Dmitry KakurinSep 5, 2007
  27. Jan HudecSep 5, 2007
  28. Jan HudecSep 4, 2007

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.