{"thread":{"id":"27892","subject":"RFC: Should git gc/repack respect .git/refs/replace?","startedAt":"2011-07-23T08:39:17Z","lastAt":"2011-07-23T09:25:50Z","messageCount":4,"participants":["Jon Seymour","Andreas Schwab","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"171878","messageId":"CAH3AnrqDbebODK-A90msoB9JXUwDHKKtQAQo5VdXZ=k8bxzkYQ@mail.gmail.com","threadId":"27892","inReplyTo":null,"subject":"RFC: Should git gc/repack respect .git/refs/replace?","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-07-23T08:39:17Z","receivedAt":"2011-07-23T08:39:17Z","isPatch":false,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"I recently damaged a USB drive containing an archive of a finished project.\n\nI am able to paper over a week of missing history by using the git\nreplace mechanism, so that git rev-list now works as expected.\n\nWhen I run git gc or git repack, I get the following:\n\n   error: Could not read 023a1d5d3977420ba041cb556c0eee17c326aeb6\n   fatal: Failed to traverse parents of commit\n44d578ea81f7a90989e2ee3c676f50e3aff7071f\n\nwhere 0bbded9a764d9f4c8dc27b778f70d044df65f65f is one of the missing\ncommits I replaced with:\n\n   git replace 023a1d5d3977420ba041cb556c0eee17c326aeb6\n238d237db9137b4eaf96f1d554bf2668729b9b93\n\nIs this expected behaviour? I had assumed that git repack would\nrespect the topology implied by git replace.\n\nSome other differences:\n\n    git cat-file commit 023a1d5d3977420ba041cb556c0eee17c326aeb6\n\nproduces the expected output (that is the same as git cat-file commit\n238d237db9137b4eaf96f1d554bf2668729b9b93), but\n\n   git cat-file commit -t 023a1d5d3977420ba041cb556c0eee17c326aeb6\n\nfails with:\n\n   error: unable to find 023a1d5d3977420ba041cb556c0eee17c326aeb6\n   fatal: git cat-file 023a1d5d3977420ba041cb556c0eee17c326aeb6: bad file\n\nIn my view, it seems reasonable that git repack should tolerate repos\nthat have replace references in them otherwise you can never recover\nunused space.\n\nThoughts?\n\njon.\n"},{"id":"171879","messageId":"m2wrf9cq0i.fsf@igel.home","threadId":"27892","inReplyTo":"CAH3AnrqDbebODK-A90msoB9JXUwDHKKtQAQo5VdXZ=k8bxzkYQ@mail.gmail.com","subject":"Re: RFC: Should git gc/repack respect .git/refs/replace?","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2011-07-23T09:20:13Z","receivedAt":"2011-07-23T09:20:13Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Jon Seymour <jon.seymour@gmail.com> writes:\n\n> I recently damaged a USB drive containing an archive of a finished project.\n>\n> I am able to paper over a week of missing history by using the git\n> replace mechanism, so that git rev-list now works as expected.\n>\n> When I run git gc or git repack, I get the following:\n>\n>    error: Could not read 023a1d5d3977420ba041cb556c0eee17c326aeb6\n>    fatal: Failed to traverse parents of commit\n> 44d578ea81f7a90989e2ee3c676f50e3aff7071f\n\ngit-replace(1):\n\n       Replacement references will be used by default by all git commands\n       except those doing reachability traversal (prune, pack transfer and\n       fsck).\n\nThis is required, since the replaced objects are not supposed to be\nrecycled.  If you want to make the replacements permanent use git\nfilter-branch.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"171880","messageId":"m3ipqts671.fsf@localhost.localdomain","threadId":"27892","inReplyTo":"CAH3AnrqDbebODK-A90msoB9JXUwDHKKtQAQo5VdXZ=k8bxzkYQ@mail.gmail.com","subject":"Re: RFC: Should git gc/repack respect .git/refs/replace?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-07-23T09:22:24Z","receivedAt":"2011-07-23T09:22:24Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Jon Seymour <jon.seymour@gmail.com> writes:\n\n> I recently damaged a USB drive containing an archive of a finished project.\n> \n> I am able to paper over a week of missing history by using the git\n> replace mechanism, so that git rev-list now works as expected.\n> \n> When I run git gc or git repack, I get the following:\n> \n>    error: Could not read 023a1d5d3977420ba041cb556c0eee17c326aeb6\n>    fatal: Failed to traverse parents of commit\n> 44d578ea81f7a90989e2ee3c676f50e3aff7071f\n> \n> where 0bbded9a764d9f4c8dc27b778f70d044df65f65f is one of the missing\n> commits I replaced with:\n> \n>    git replace 023a1d5d3977420ba041cb556c0eee17c326aeb6\n> 238d237db9137b4eaf96f1d554bf2668729b9b93\n> \n> Is this expected behaviour? I had assumed that git repack would\n> respect the topology implied by git replace.\n\nThis is the expected behavior. \n\nReplace mechanism is meant to be transferable and safe wrt. repacking.\nTherefore repack should not remove commits hidden by replacement\nobjects, otherwise if you push to repository instance that doesn't\nhave replace refs, you would get corrupt repository.  \n\nAs replace mechanism uses ordinary refs, therefore replaced object are\nsafe against repacking / pruning and transferrable in the same way as\nother refs.\n\n\nIf you want paper over missing history, you need to use GRAFTS, not\nreplace objects.\n\n> \n> Some other differences:\n> \n>     git cat-file commit 023a1d5d3977420ba041cb556c0eee17c326aeb6\n> \n> produces the expected output (that is the same as git cat-file commit\n> 238d237db9137b4eaf96f1d554bf2668729b9b93), but\n> \n>    git cat-file commit -t 023a1d5d3977420ba041cb556c0eee17c326aeb6\n\nErrr... isn't it\n\n     git cat-file -t 023a1d5d3977420ba041cb556c0eee17c326aeb6\n\n> \n> fails with:\n> \n>    error: unable to find 023a1d5d3977420ba041cb556c0eee17c326aeb6\n>    fatal: git cat-file 023a1d5d3977420ba041cb556c0eee17c326aeb6: bad file\n\nHmmm... that looks like bug, assuming that you didn't make mistake in\nwriting command.\n\nBTW. do git-cat-file respect replace object, or is it only git-show\nthat respect them?\n \n> In my view, it seems reasonable that git repack should tolerate repos\n> that have replace references in them otherwise you can never recover\n> unused space.\n\nReplace are not meant for this.  You can use grafts instead, but they\nare not transferable in-band, so forget about sharing repository if\nyou do surgery on it like that...\n\n-- \nJakub Narebski\n"},{"id":"171881","messageId":"CAH3Anrqt-s6mPLXw_Uzf0YODFtTPRPJEDgvphjMFxybJibvbPg@mail.gmail.com","threadId":"27892","inReplyTo":"m2wrf9cq0i.fsf@igel.home","subject":"Re: RFC: Should git gc/repack respect .git/refs/replace?","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-07-23T09:25:50Z","receivedAt":"2011-07-23T09:25:50Z","isPatch":false,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"On Sat, Jul 23, 2011 at 7:20 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:\n> Jon Seymour <jon.seymour@gmail.com> writes:\n>\n>> I recently damaged a USB drive containing an archive of a finished project.\n>>\n>> I am able to paper over a week of missing history by using the git\n>> replace mechanism, so that git rev-list now works as expected.\n>>\n>> When I run git gc or git repack, I get the following:\n>>\n>>    error: Could not read 023a1d5d3977420ba041cb556c0eee17c326aeb6\n>>    fatal: Failed to traverse parents of commit\n>> 44d578ea81f7a90989e2ee3c676f50e3aff7071f\n>\n> git-replace(1):\n>\n>       Replacement references will be used by default by all git commands\n>       except those doing reachability traversal (prune, pack transfer and\n>       fsck).\n>\n\nOops. Missed that - thanks.\n\n> This is required, since the replaced objects are not supposed to be\n> recycled.  If you want to make the replacements permanent use git\n> filter-branch.\n\nAh, makes sense.\n\njon.\n"}]}