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

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

From
JHJan Hudec <bulb@ucw.cz>
Date
Sep 5, 2007, 18:38 UTC
Message-ID
<20070905183831.GA29370@efreet.light.src>
In-Reply-To
<7vk5r5jzpn.fsf@gitster.siamese.dyndns.org>
On Wed, Sep 05, 2007 at 01:14:44 -0700, Junio C Hamano wrote:
Show 21 quoted lines
> "Dmitry Kakurin" <dmitry.kakurin@gmail.com> writes:
> 
> > I assert that since index does not have .gitattributes the one from
> > local directory should not be used.
> >
> > Think about dedicated build machine scenario: I have a machine that
> > always does sync + build. After every sync the local directory should
> > always be identical to what-was-committed.
> 
> Thinking about the reason _why_ .gitattributes may be updated,
> one would notice that it is because somebody did this command
> sequence:
> 
> 	git checkout		;# now work tree is clean
> 	edit .gitattributes	;# modify the attributes of a file
> 	edit file		;# edit the file attributes talks about
> 	git add file		;# this can be affected by .gitattributes
> 	git add .gitattributes	;# this is changed in the same commit
> 	git commit
> 
> Now, should we always take .gitattributes from the index?
Yes, they should:

$ git checkout $ edit .gitattributes $ edit file $ git add file $ git commit ;# this does NOT have the changes to .gitattributes

the above case is a user error that can (at some cost) be detected:
$ git checkout
$ edit .gitattributes
$ edit file
$ git add file
$ git add .gitattributes
Warning! Changes to gitattributes affects handling of files scheduled for
commit. Please add following files again before commit:
  file
$
It would be possible to special-case .gitattributes in add to:
 - do diff between the old and new value of .gitattributes in index,
 - list files changed in index compared to HEAD,
 - match each of them to all patterns in the diff,
 - if any matches, print the warning and list of matches.
It might be even possible to actually inspect the changes and apply those
that can be automatically (and not ask user to re-add), but some filters
loose information, so user interaction is needed to add good version.
-- 
						 Jan 'Bulb' Hudec <bulb@ucw.cz>
Previous: Dmitry KakurinNext: Jan Hudec
Message 27 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.