{"thread":{"id":"27896","subject":"Is there a quick way to identify commits that reference missing trees or blobs?","startedAt":"2011-07-23T16:48:20Z","lastAt":"2011-07-26T04:20:00Z","messageCount":5,"participants":["Jon Seymour","Clemens Buchacher"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"171892","messageId":"CAH3AnroyfeGOo_23nHKhLjxEnP_qEMi7as1UjXEFjjuVOckBjw@mail.gmail.com","threadId":"27896","inReplyTo":null,"subject":"Is there a quick way to identify commits that reference missing trees or blobs?","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-07-23T16:48:20Z","receivedAt":"2011-07-23T16:48:20Z","isPatch":false,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"I was wondering if there is a quick way to identify commits that\nreference missing trees or blobs as identified by git fsck?\n\nThis would be quite useful in situations where one is trying to\nsalvage as much history as possible from a damaged repository.\n\njon.\n"},{"id":"172024","messageId":"20110725223449.GA25560@toss.lan","threadId":"27896","inReplyTo":"CAH3AnroyfeGOo_23nHKhLjxEnP_qEMi7as1UjXEFjjuVOckBjw@mail.gmail.com","subject":"Re: Is there a quick way to identify commits that reference missing trees or blobs?","fromName":"Clemens Buchacher","fromEmail":"drizzd@aon.at","sentAt":"2011-07-25T22:34:50Z","receivedAt":"2011-07-25T22:34:50Z","isPatch":false,"sender":{"key":"drizzd@gmx.net","avatar":"https://avatars.githubusercontent.com/u/59082?v=4"},"body":"On Sun, Jul 24, 2011 at 02:48:20AM +1000, Jon Seymour wrote:\n>\n> I was wondering if there is a quick way to identify commits that\n> reference missing trees or blobs as identified by git fsck?\n\nThe following command has served me well for this purpose. I apply\nit to each ref in git-for-each-ref:\n\n$ git rev-list --objects $ref | git cat-file --batch-check\n\nIt may not be the fastest way to do it, but it did the trick for\nme. I then simply deleted any broken refs using git update-ref -d\n$ref, even if the tip of the branch was still intact. I could have\ntried to salvage some history from those refs, but I had a backup\nand at that point I just wanted to continue working.\n\nhth,\nClemens\n"},{"id":"172025","messageId":"20110725224408.GA26057@toss.lan","threadId":"27896","inReplyTo":"20110725223449.GA25560@toss.lan","subject":"Re: Is there a quick way to identify commits that reference missing trees or blobs?","fromName":"Clemens Buchacher","fromEmail":"drizzd@aon.at","sentAt":"2011-07-25T22:44:08Z","receivedAt":"2011-07-25T22:44:08Z","isPatch":false,"sender":{"key":"drizzd@gmx.net","avatar":"https://avatars.githubusercontent.com/u/59082?v=4"},"body":"On Tue, Jul 26, 2011 at 12:34:50AM +0200, Clemens Buchacher wrote:\n> On Sun, Jul 24, 2011 at 02:48:20AM +1000, Jon Seymour wrote:\n> >\n> > I was wondering if there is a quick way to identify commits that\n> > reference missing trees or blobs as identified by git fsck?\n> \n> The following command has served me well for this purpose. I apply\n> it to each ref in git-for-each-ref:\n> \n> $ git rev-list --objects $ref | git cat-file --batch-check\n\nOh, and here is the output you get for different situations. Exit\nstatus is always 0 unfortunately.\n\n - missing blob\n\nfatal: missing blob object '78981922613b2afb6025042ff6bd878ac1994e85'\nd165426eba5cb4c125bd6e100d1b5de7298eb601 commit 168\n848740929e99bda0e1a9783e7daa314c5a9732d5  missing\n\n - missing tree\n\nerror: Could not read 84bf061d017459b4be45a49b8d8dc945e7a7fdf5\nfatal: bad tree object 84bf061d017459b4be45a49b8d8dc945e7a7fdf5\nabce3ad54002628ab74d72b7e2baa687abcb77f9 commit 168\n\n - missing parent commit\n\nerror: Could not read 3aa66f30aa9799ac38a53b551ac4faca9cbd400b\nfatal: Failed to traverse parents of commit 3cfb98a3cbd3f42852e20bd011c7b835b8750df7\n\nClemens\n"},{"id":"172030","messageId":"CAH3AnrouGUPvnYk_O1W_a5qZCmePC41GgEX_qcS3HLpkEm9pHw@mail.gmail.com","threadId":"27896","inReplyTo":"20110725224408.GA26057@toss.lan","subject":"Re: Is there a quick way to identify commits that reference missing trees or blobs?","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-07-26T01:39:55Z","receivedAt":"2011-07-26T01:39:55Z","isPatch":false,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"On Tue, Jul 26, 2011 at 8:44 AM, Clemens Buchacher <drizzd@aon.at> wrote:\n> On Tue, Jul 26, 2011 at 12:34:50AM +0200, Clemens Buchacher wrote:\n>> On Sun, Jul 24, 2011 at 02:48:20AM +1000, Jon Seymour wrote:\n>> >\n>> > I was wondering if there is a quick way to identify commits that\n>> > reference missing trees or blobs as identified by git fsck?\n>>\n>> The following command has served me well for this purpose. I apply\n>> it to each ref in git-for-each-ref:\n>>\n>> $ git rev-list --objects $ref | git cat-file --batch-check\n>\n> Oh, and here is the output you get for different situations. Exit\n> status is always 0 unfortunately.\n>\n>  - missing blob\n>\n> fatal: missing blob object '78981922613b2afb6025042ff6bd878ac1994e85'\n> d165426eba5cb4c125bd6e100d1b5de7298eb601 commit 168\n> 848740929e99bda0e1a9783e7daa314c5a9732d5  missing\n>\n>  - missing tree\n>\n> error: Could not read 84bf061d017459b4be45a49b8d8dc945e7a7fdf5\n> fatal: bad tree object 84bf061d017459b4be45a49b8d8dc945e7a7fdf5\n> abce3ad54002628ab74d72b7e2baa687abcb77f9 commit 168\n>\n>  - missing parent commit\n>\n> error: Could not read 3aa66f30aa9799ac38a53b551ac4faca9cbd400b\n> fatal: Failed to traverse parents of commit 3cfb98a3cbd3f42852e20bd011c7b835b8750df7\n>\n> Clemens\n>\n\nThanks for that.\n\nJunio, also pointed out in another thread that git rev-list --objects\nis quite useful for this purpose. His variant used git pack-objects\nwhich apparently does exit with zero status code.  The zero exit code\nhere looks like a bug, I think, so perhaps I will submit a patch for\nthat too (I just did one for git ls-tree).\n\nWhile concise it isn't a particularly fast way to find commits\naffected by damaged trees - it is O(N^2*M), where N is the number of\ncommits and M is the size of the tree. As indicated in another thread,\nI think bisection can potentially be O(K * log(N) * M + K*N), where K\nis the number of fully connected bad subgraphs. [ by that I mean a\nsubgraph consisting only of commits with damaged trees).\n\njon.\n"},{"id":"172032","messageId":"CAH3Anrp-pQg8x-UHKDMb+VXFT_m4LiWX=cezoZWstCoFsiJWMQ@mail.gmail.com","threadId":"27896","inReplyTo":"CAH3AnrouGUPvnYk_O1W_a5qZCmePC41GgEX_qcS3HLpkEm9pHw@mail.gmail.com","subject":"Re: Is there a quick way to identify commits that reference missing trees or blobs?","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-07-26T04:20:00Z","receivedAt":"2011-07-26T04:20:00Z","isPatch":false,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"On Tue, Jul 26, 2011 at 11:39 AM, Jon Seymour <jon.seymour@gmail.com> wrote:\n> On Tue, Jul 26, 2011 at 8:44 AM, Clemens Buchacher <drizzd@aon.at> wrote:\n>> On Tue, Jul 26, 2011 at 12:34:50AM +0200, Clemens Buchacher wrote:\n>>> On Sun, Jul 24, 2011 at 02:48:20AM +1000, Jon Seymour wrote:\n>>> >\n>>> > I was wondering if there is a quick way to identify commits that\n>>> > reference missing trees or blobs as identified by git fsck?\n>>>\n>>> The following command has served me well for this purpose. I apply\n>>> it to each ref in git-for-each-ref:\n>>>\n>>> $ git rev-list --objects $ref | git cat-file --batch-check\n>>\n>> Oh, and here is the output you get for different situations. Exit\n>> status is always 0 unfortunately.\n>>\n>>  - missing blob\n>>\n>> fatal: missing blob object '78981922613b2afb6025042ff6bd878ac1994e85'\n>> d165426eba5cb4c125bd6e100d1b5de7298eb601 commit 168\n>> 848740929e99bda0e1a9783e7daa314c5a9732d5  missing\n>>\n>>  - missing tree\n>>\n>> error: Could not read 84bf061d017459b4be45a49b8d8dc945e7a7fdf5\n>> fatal: bad tree object 84bf061d017459b4be45a49b8d8dc945e7a7fdf5\n>> abce3ad54002628ab74d72b7e2baa687abcb77f9 commit 168\n>>\n>>  - missing parent commit\n>>\n>> error: Could not read 3aa66f30aa9799ac38a53b551ac4faca9cbd400b\n>> fatal: Failed to traverse parents of commit 3cfb98a3cbd3f42852e20bd011c7b835b8750df7\n>>\n>> Clemens\n>>\n>\n> Thanks for that.\n>\n> Junio, also pointed out in another thread that git rev-list --objects\n> is quite useful for this purpose. His variant used git pack-objects\n> which apparently does exit with zero status code.\n\n| _non-zero_ !\n"}]}