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

Re: Careful object writing..

From
CWChris Wedgwood <cw@f00f.org>
Date
May 3, 2005, 19:27 UTC
Message-ID
<20050503192753.GA6435@taniwha.stupidest.org>
In-Reply-To
<Pine.LNX.4.58.0505031204030.26698@ppc970.osdl.org>
On Tue, May 03, 2005 at 12:15:08PM -0700, Linus Torvalds wrote:
> So now I do it "right", and create a temporary file in the "top"
> object directory, and then when it's all done, I do a "link()" to
> the final place and unlink the original.

how is this better than a single rename? i take it there is something fundamental from clue.101 i slept though here?

also, if you are *really* paranoid you want to fsync *before* you do the link/unklink or rename --- which is what MTAs do[1]

however, that said it *kills* performance and if it's not critical it's really a terrible idea

also, shouldn't HEAD (and similar)[2] be updated with a temporary and a rename too?

> I also change the permission to 0444 before it gets its final name.
cool
> 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?

[1] yes, i know this depends on the fs used and various things and
    ext3 should be fine, blah blah blah, but not everyone uses ext3
    and quite probably not everyone will use git under Linux
[2] i didn't check the code as i'm still using BK in places
Previous: Linus TorvaldsNext: Linus Torvalds
Message 2 of 19 in “Careful object writing..”
  1. Linus TorvaldsMay 3, 2005
  2. Chris WedgwoodMay 3, 2005
  3. Linus TorvaldsMay 3, 2005
  4. Chris WedgwoodMay 3, 2005
  5. Linus TorvaldsMay 3, 2005
  6. Daniel BarkalowMay 3, 2005
  7. Jan HarkesMay 3, 2005
  8. Linus TorvaldsMay 3, 2005
  9. Jan HarkesMay 3, 2005
  10. Linus TorvaldsMay 3, 2005
  11. Linus TorvaldsMay 3, 2005
  12. H. Peter AnvinMay 3, 2005
  13. Alex RiesenMay 3, 2005
  14. Linus TorvaldsMay 3, 2005
  15. Alex RiesenMay 3, 2005
  16. Junio C HamanoMay 3, 2005
  17. Careful object pullingDaniel Barkalow, May 4, 2005
  18. Morten WelinderMay 4, 2005
  19. Daniel BarkalowMay 4, 2005

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.