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

Re: How to use git attributes to configure server-side checks?

From
Jeff King <peff@peff.net>
Date
Sep 22, 2011, 17:13 UTC
Message-ID
<20110922171340.GA2934@sigill.intra.peff.net>
In-Reply-To
<CAG+J_DxtCx6-RKWLKFy+V7tOtu7UnUrke7iN8gNdGiY-sC52sQ@mail.gmail.com>
On Thu, Sep 22, 2011 at 11:41:34AM -0400, Jay Soffian wrote:
> Thank you for this thread. I was under the illusion that diff-tree
> --check considered in-tree .gitattributes, but the code seems to
> indicate otherwise. :-(

No, we definitely don't use in-tree gitattributes. IIRC, there are some precedence and ordering questions. I think the ordering now is:

  1. Look in $GIT_DIR/info/attributes
  2. If not found, look in per-directory .gitattributes
  3. If not found, look in core.gitattributesfile

Where do in-tree attributes fit in? Between 1 and 2? Or 2 and 3? And which tree do we look at?

Here are some examples:
  a. If I do "git checkout branch-foo", we should look at branch-foo's
     tree for things like crlf, right?  Do we still fall back to
     per-directory .gitattributes in the working tree? On the one hand,
     they're not really relevant to the commit we're moving to. But they
     are respected in the current code, and can be useful when moving to
     old commits which lack attributes.
     I think this is where the index magic comes in in the current code
     (we do something like "load the index, then respect gitattributes
     from the index").
     So maybe this is solved already.
  b. You're diffing commit $a against commit $b. Whose gitattributes
     have precedence? Is order important? Are gitattributes in the
     working tree and index relevant?
  c. You're diffing commit $a against HEAD. Which gitattributes have
     precedence? Again, is order important (i.e., does "diff -R" look at
     different attributes than "diff")?

I'm sure there are others, too. And I don't think any of these is insurmountable. But somebody needs to think through a lot of cases and come up with consistent, sane behavior that does the right thing in each case (considering both bare repositories and ones with working trees).

-Peff
Previous: Jay SoffianNext: Jay Soffian
Message 6 of 31 in “How to use git attributes to configure server-side checks?”
  1. Michael HaggertySep 21, 2011
  2. Jay SoffianSep 21, 2011
  3. Junio C HamanoSep 21, 2011
  4. Michael HaggertySep 22, 2011
  5. Jay SoffianSep 22, 2011
  6. Jeff KingSep 22, 2011
  7. Jay SoffianSep 22, 2011
  8. Junio C HamanoSep 22, 2011
  9. Jeff KingSep 22, 2011
  10. Jeff KingSep 22, 2011
  11. Michael HaggertySep 23, 2011
  12. Jeff KingSep 23, 2011
  13. Junio C HamanoSep 23, 2011
  14. Jeff KingSep 23, 2011
  15. Michael HaggertySep 24, 2011
  16. Jeff KingSep 24, 2011
  17. Michael HaggertySep 24, 2011
  18. Junio C HamanoSep 26, 2011
  19. Michael HaggertySep 26, 2011
  20. Jeff KingSep 26, 2011
  21. Jakub NarebskiSep 26, 2011
  22. Michael HaggertySep 26, 2011
  23. Junio C HamanoSep 22, 2011
  24. Michael HaggertySep 23, 2011
  25. Stephen BashSep 23, 2011
  26. Michael HaggertySep 23, 2011
  27. Jakub NarebskiSep 22, 2011
  28. Michael HaggertySep 23, 2011
  29. Michael HaggertyFeb 17, 2012
  30. Junio C HamanoFeb 17, 2012
  31. Junio C HamanoFeb 17, 2012

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.