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

Re: [PATCH 2/2] Make Git respect changes to .gitattributes during checkout.

From
KAKristian Amlie <kristian.amlie@nokia.com>
Date
Mar 20, 2009, 08:11 UTC
Message-ID
<49C34FB1.4040100@nokia.com>
In-Reply-To
<7v8wn18bo2.fsf@gitster.siamese.dyndns.org>
ext Junio C Hamano wrote:
Show 25 quoted lines
> Kristian Amlie <kristian.amlie@nokia.com> writes:
> 
>> ext Junio C Hamano wrote:
>> ...
>>> For example, you may notice that, after making a clean checkout, one path
>>> has a wrong attribute assigned to it, and may try to correct it.  But how?
>>>
>>>  $ edit .gitattributes ;# mark foo.dat as binary
>>>  $ rm foo.dat
>>>  $ git checkout foo.dat ;# make sure the new settings is correct???
>> As far as I can see, this works without any modifications to the patch.
>> Is that maybe because git_attr_set_direction() is not called if you use
>> that form of checkout?
> 
> But that in itself can be seen as a bug, right?  In another use case,
> suppose you botched your .gitattributes in HEAD version and noticed that
> foo.dat is checked out with a wrong attribute.  You try to fix it like
> this:
> 
>     $ git reset HEAD^ .gitattributes
>     $ rm foo.dat
>     $ git checkout foo.dat
> 
> If you do not flip the direction, the one from the work tree is used which
> is not what you want.  If you do, then you break the other use case.

Right, I didn't even think about that case. My idea of gitattributes was that the working tree copy is always the master version, and takes precedence. The only reason that the index takes precedence in the "git checkout <branch>" case is that there is no other way to get it checked out correctly, so I see this as an implementation detail. I'm sure some people would disagree though.

But you're right, there is no way to make both cases correct. From my standpoint I'd say that the behavior of your patch is the most intuitive.

I'll follow up with the test case.

-- Kristian

Previous: Junio C HamanoNext: Kristian Amlie
Message 17 of 22 in “Honoring a checked out gitattributes file”
  1. Kristian AmlieJan 28, 2009
  2. Michael J GruberJan 28, 2009
  3. Kristian AmlieJan 28, 2009
  4. Kristian AmlieJan 30, 2009
  5. Add a test for checking whether gitattributes is honored by checkout.Kristian Amlie, Jan 30, 2009
  6. Kristian AmlieMar 12, 2009
  7. 1/2 Add a test for checking whether gitattributes is honored by checkout.Kristian Amlie, Mar 12, 2009
  8. 2/2 Make Git respect changes to .gitattributes during checkout.Kristian Amlie, Mar 12, 2009
  9. Johannes SixtMar 12, 2009
  10. Kristian AmlieMar 12, 2009
  11. Kristian AmlieMar 13, 2009
  12. 1/2 Add a test for checking whether gitattributes is honored by checkout.Kristian Amlie, Mar 13, 2009
  13. 2/2 Make Git respect changes to .gitattributes during checkout.Kristian Amlie, Mar 13, 2009
  14. Junio C HamanoMar 14, 2009
  15. Kristian AmlieMar 19, 2009
  16. Junio C HamanoMar 19, 2009
  17. Kristian AmlieMar 20, 2009
  18. Add a test for checking whether gitattributes is honored by checkout.Kristian Amlie, Mar 20, 2009
  19. Junio C HamanoMar 14, 2009
  20. Matthieu MoyMar 12, 2009
  21. Kristian AmlieMar 12, 2009
  22. Jeff KingJan 28, 2009

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.