{"thread":{"id":"101","subject":"A couple of questions","startedAt":"2005-04-18T11:51:00Z","lastAt":"2005-04-18T16:23:52Z","messageCount":3,"participants":["Imre Simon","Linus Torvalds","Paul Jackson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"649","messageId":"42639F24.90007@ime.usp.br","threadId":"101","inReplyTo":null,"subject":"A couple of questions","fromName":"Imre Simon","fromEmail":"is@ime.usp.br","sentAt":"2005-04-18T11:51:00Z","receivedAt":"2005-04-18T11:51:00Z","isPatch":false,"sender":{"key":"is@ime.usp.br","avatar":null},"body":"How will git handle a corrupted (git) file system?\n\nFor instance, what can be done if objects/xy/z{38} does not pass the\nsimple consistency test, i.e. if the file's sha1 hash is not xyz{38}?\nThis might be a serious problem because, in general, one cannot\nreconstruct the contents of file objects/xy/z{38} from its name\nxyz{38}.\n\nAnother problem might come up if the file does pass the simple\nconsistency test but the file's contents is not a valid git file,\ni.e. something that\n\n  (*) successfully inflates to a stream of bytes that forms a sequence of\n  <ascii tag without space> + <space> + <ascii decimal size> +\n  <byte\\0> + <binary object data>.\n\nAre there enough internal redundancies in git to allow fixing at least\nsome corrupted file systems? Shouldn't there be some?\n\nAnother related observation is that git is not really based on a 160 bit\nhashing scheme. Indeed, only files that satisfy the above condition\n(*) are allowed and this most certainly reduces the valid range of the\nhashing function. I do not think that this will be a problem, but it\ndoesn't hurt to point this out once.\n\nCheers,\n\nImre Simon\n\n"},{"id":"663","messageId":"Pine.LNX.4.58.0504180825280.7211@ppc970.osdl.org","threadId":"101","inReplyTo":"42639F24.90007@ime.usp.br","subject":"Re: A couple of questions","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-04-18T15:31:24Z","receivedAt":"2005-04-18T15:31:24Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Mon, 18 Apr 2005, Imre Simon wrote:\n>\n> How will git handle a corrupted (git) file system?\n> \n> For instance, what can be done if objects/xy/z{38} does not pass the\n> simple consistency test, i.e. if the file's sha1 hash is not xyz{38}?\n> This might be a serious problem because, in general, one cannot\n> reconstruct the contents of file objects/xy/z{38} from its name\n> xyz{38}.\n\nNothing beats backups and distribution. The distributed nature of git \nmeans that you can replicate your objects abitrarily.\n\n> Another problem might come up if the file does pass the simple\n> consistency test but the file's contents is not a valid git file,\n\nRun \"fsck-cache\". It not only tests SHA1 and general object sanity, but it\ndoes full tracking of the resulting reachability and everything else. It\nprints out any corruption it finds (missing or bad objects), and if you\nuse the \"--unreachable\" flag it will also print out objects that exist but \nthat aren't readable from any of the HEAD nodes (which you need to \nspecify).\n\nSo for example\n\n\tfsck-cache --unreachable $(cat .git/HEAD)\n\nwill do quite a _lot_ of verification on the tree. There are a few extra \nvalidity tests I'm going to add (make sure that tree objects are sorted \nproperly etc), but on the whole if \"fsck-cache\" is happy, you do have a \nvalid tree.\n\nAny corrupt objects you will have to find in backups or other archives (ie\nyou can just remove them and do an \"rsync\" with some other site in the\nhopes that somebody else has the object you have corrupted).\n\nOf course, \"valid tree\" doesn't mean that it wasn't generated by some evil \nperson, and the end result might be crap. Git is a revision tracking \nsystem, not a quality assurance system ;)\n\n\t\tLinus\n"},{"id":"666","messageId":"20050418092352.140e7241.pj@sgi.com","threadId":"101","inReplyTo":"Pine.LNX.4.58.0504180825280.7211@ppc970.osdl.org","subject":"Re: A couple of questions","fromName":"Paul Jackson","fromEmail":"pj@sgi.com","sentAt":"2005-04-18T16:23:52Z","receivedAt":"2005-04-18T16:23:52Z","isPatch":false,"sender":{"key":"pj@sgi.com","avatar":null},"body":"Linus wrote:\n> Nothing beats backups and distribution.\n\nFamous quote from the past:\n\n\"Only wimps use tape backup: real men just upload their important stuff on ftp,\n and let the rest of the world mirror it ;)\" Linus Torvalds\n\n-- \n                  I won't rest till it's the best ...\n                  Programmer, Linux Scalability\n                  Paul Jackson <pj@engr.sgi.com> 1.650.933.1373, 1.925.600.0401\n"}]}