From: Linus Torvalds Date: Tue, 03 May 2005 19:47:36 GMT Subject: Re: Careful object writing.. Message-ID: In-Reply-To: <20050503192753.GA6435@taniwha.stupidest.org> On Tue, 3 May 2005, Chris Wedgwood wrote: > > how is this better than a single rename? i take it there is something > fundamental from clue.101 i slept though here? A rename will overwrite any old object, which means that you cannot do any collision checks. In contrast, a "link()" will return EEXIST if somebody else raced with you and created a new object, and you can do collision checks instead of overwriting another persons object. > also, if you are *really* paranoid you want to fsync *before* you do > the link/unklink or rename --- which is what MTAs do[1] Me, I refuse to slow down my habits for old filesystems. You can either fsck, or use a logging filesystem. I don't see anybody not using logging filesystems these days, so.. > also, shouldn't HEAD (and similar)[2] be updated with a temporary and > a rename too? Maybe. Much less important, though. > > NOTE NOTE NOTE! I have _not_ updated all the helper stuff that also > > write objects. > > i thought this was all common code? if it's not maybe now is the time > to change that? It is all common code, except: - things like "fetch from another host" will use rsync/wget/xxx to actually get the files. To those programs, we're not talking about git objects, we're just talking "regular files" - rpull.c has a special different routine to write its objects. I don't use it, so.. Anyway, it should be reasonably easily fixable. Linus