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 19, 2009, 15:42 UTC
Message-ID
<49C267E3.1020205@nokia.com>
In-Reply-To
<7vprgkg2kx.fsf@gitster.siamese.dyndns.org>
ext Junio C Hamano wrote:
Show 12 quoted lines
> In a well structured git program, we always read from the work tree and
> the index (to see if there is something changed---you need to be able to
> apply convert_to_git when you do this), internally compute what should
> happen (e.g. decide that the new result needs to be checked out for a
> path), and then write it out (you apply convert_to_working_tree while you
> do this).  So how about doing something like the attached patch?
> 
> The patch allows the caller to tell the usual "read from the working tree,
> if not use the version from the index as the fallback" logic to be swapped
> around, and take the index version.  It may or may not pass your new tests
> (I haven't even compile tested it), but I think the damage is minimized
> compared to your version.

You're right, that's a much cleaner approach. The patch is really good as far as I can see. It fixes both my test cases (including the one I wasn't able to fix), and there are no additional failures when running the autotests. Do you have second thoughts about it, or is it good enough to apply?

If it is, I'll move the test case into t0021-conversion.sh like you said and give you a new patch for that.

Show 11 quoted lines
> It is great that you are trying to fix this issue for the most obvious
> "switching between two branches while not having a local change" case, but
> frankly, I do not think this is solvable in more general cases, and that
> is why it was kept "known to be broken, not worth fixing" state.
> 
> 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?

-- Kristian

Previous: Junio C HamanoNext: Junio C Hamano
Message 15 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.