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

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

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

From: Jan Hudec <hidden>
Date: 2016-06-15 22:43:33

On Tue, Aug 28, 2007 at 09:49:47 +0100, Johannes Schindelin wrote:
Hi,

On Mon, 27 Aug 2007, Dmitry Kakurin wrote:
quoted
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.
I do not see these cases.  You can have these cases, basically:

- .gitattributes in worktree (then it does not matter what else we have),
- .gitattributes not in the worktree, but in the index (then that is taken)

In the latter case, there could be conflicts _in_ .gitattributes, in which 
case those .gitattributes are ignored.

I do not see any problem with that.
I do.

IMNSHO it should be the other way around:
 .gitattributes in index, than index version is used.
 .gitattributes not in index, but in worktree, than that tree version is used.

Why? Because when you check out another version, the .gitattributes commited
in that version need to be applied, since it might be different from whatever
is currently in the tree.

In the other direction, the tree version seems to make more sense, but in
reality it does not. If you do a partial commit of a single file, than the
index version gets into the commit, so that should better be the version used
to store the file. On the other hand if you change .gitattributes, the normal
commit rules are that you need to add it for commit, so needing to add it to
make it effective goes well together with it. update-index would need to
always handle .git* before other entries to make add . and commit -a work
correctly.

The case for worktree only is for cases when you for some reason want to have
local .gitattributes. Though I am not sure that should actually work, because
you couldn't have local .gitattributes if there is versioned version.
.git/info/attributes would be better for that. Which gets us back to "always
use .gitattributes from *index*" (and read it from tree before other files
when adding it).

-- 
						 Jan 'Bulb' Hudec [off-list ref]

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

From: Dmitry Kakurin <hidden>
Date: 2016-06-15 22:43:33

On 9/4/07, Jan Hudec [off-list ref] wrote:
On Tue, Aug 28, 2007 at 09:49:47 +0100, Johannes Schindelin wrote:
quoted
On Mon, 27 Aug 2007, Dmitry Kakurin wrote:
quoted
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.
I do not see these cases.  You can have these cases, basically:

- .gitattributes in worktree (then it does not matter what else we have),
- .gitattributes not in the worktree, but in the index (then that is taken)

In the latter case, there could be conflicts _in_ .gitattributes, in which
case those .gitattributes are ignored.

I do not see any problem with that.
I do.

IMNSHO it should be the other way around:
 .gitattributes in index, than index version is used.
 .gitattributes not in index, but in worktree, than that tree version is used.
Consider scenario when my commit #1 has .gitattributes:
    a.txt -nocrlf
and file a.txt
You pull it.
Now I make some changes to a.txt and realize that a.txt *is* a text
file now. I remove the entry from .gitattributes and notice that it
becomes empty. So I just remove .gitattributes file all together. It
becomes commit#2.
Now you pull it again. There *is* .gitattributes in local directory,
but index does not have it (because I've removed it on purpose). What
should happen?
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.
With every commit 3 things could happen: .gitattributes could appear,
disappear or change. In every case "build machine" must produce the
exact copy of what-was-checked-in. The only way I see this happening
is by using *only* index version of .gitattributes when files are
moved index -> workspace.

A similar reasoning works for other direction (workplace -> index).
-- 
- Dmitry
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help