Re: Is cp -al safe with git?

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Johannes Sixt <johannes.sixt@...>
Cc: <git@...>
Date: Thursday, November 16, 2006 - 3:19 pm

On Thu, 16 Nov 2006, Johannes Sixt wrote:

It works, but I don't think you should depend on it.


We _tried_ to make sure it is ok, but since it's not a normal mode of 
operation, I would not guarantee it.


Yes and no. They do _not_ actually break links of files that they know 
stay the same, but your example breaks the internal knowledge by using 
that "cp -al". That changes the modification time of the inodes, so git 
thinks that the files _may_ have changed, and when you do a "git reset", 
it will overwrite them all.


If you do a

	git update-index --refresh

(or, more easily, a "git status", which will do the index refresh for you) 
before you do the "git reset", you will get:

	$ ls -l
	total 8
	-rw-r--r-- 1 jsixt users 4 Nov 16 19:24 a
	-rw-r--r-- 2 jsixt users 4 Nov 16 19:24 b

like you want to. The reason "git reset" overwrites _both_ files in your 
example is that the stat() information for those files changed, so "git 
reset" thinks they are both dirty and both need to be rewritten.

That said, I would seriously suggest that you try these things out, and 
realize that most people do _not_ use the hardlinked approach. For all I 
know, some piece of git might change some files in-place. I don't _think_ 
we do, and it would strictly speaking be a bug, but because people don't 
use it that way, you'd be the guinea pig.

I think we'll happily fix any bugs you find, but that may not make you any 
happier if the bug corrupted your lifes work ;)

In general, you might want to use

	git clone -l -s

instead, but that will _not_ hardlink the actual checked-out contents, so 
it's not going to get the kind of sharing you look for. On the other hand, 
especially with good maintenance (doing "git repack -l -d -a" etc), you 
may end up sharing _more_ that way at least in the repository object 
database (but never in the actual checked-out directories).

		Linus
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Is cp -al safe with git?, Johannes Sixt, (Thu Nov 16, 2:47 pm)
Re: Is cp -al safe with git?, Junio C Hamano, (Thu Nov 16, 3:19 pm)
Re: Is cp -al safe with git?, Linus Torvalds, (Thu Nov 16, 3:19 pm)