RE: I have gone and done a bad thing - malformed tree objects

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Jeff King
> Sent: Friday, July 31, 2020 9:45 PM
> 
> On Fri, Jul 31, 2020 at 08:01:58PM -0400, Jason Pyeron wrote:
> 
> > > That should be dropping everything that isn't reachable. I'd suggest to
> > > expire reflogs, though it looks like you've also tried "git gc" with
> > > reflog expiration. Does removing .git/logs entirely help?
> > >
> > > If not, are you sure it isn't actually reachable from your history? What
> > > does:
> > >
> > >   git rev-list --all --objects | grep 00009623a06
> >
> > $ git rev-list --all --objects | grep 00009623a06
> > 00009623a06b8dea7c151542fc789539599c07d0 src/htdocs
> > (it is still running...)

$ git rev-list --all --objects | grep 00009623a06
00009623a06b8dea7c151542fc789539599c07d0 src/htdocs

$ git rev-list --all --objects --reflog | grep 00009623a06
00009623a06b8dea7c151542fc789539599c07d0 src/htdocs

No unexpected results, just the correct tree pointing to the 00009623a06 as a tree.

> >
> > But that is an expected result, I will be back at work on Sunday.
> 
> So it sounds like it's still reachable, and you'd need to rewrite
> history to get rid of it. Or is that object OK, and it's a containing
> tree that mentions it with the wrong mode the problem? In that case,
> same question: is the containing tree reachable?

Backing up to the beginning.

There has always been a tree with a tree entry for that blob - which is reachable.

I then created a tree manually, in it I added that tree id as a blob reference when it should have been a tree. (e.g. 100644 blob 00009623a06b8dea7c151542fc789539599c07d0 00009623a06b8dea7c151542fc789539599c07d0.blob) 

I realized my mistake, dropped the commit referring to my butchered tree object (reset to new correct commit with correct tree).

The tree I created should no longer be reachable.

$ mv logs logs.bak

$ git cat-file --batch-all-objects --batch=objecttype --unordered --allow-unknown-type
objecttype
fatal: object 00009623a06b8dea7c151542fc789539599c07d0 changed type!?

$ git cat-file -t 00009623a06b8dea7c151542fc789539599c07d0
tree

$ git cat-file -s 00009623a06b8dea7c151542fc789539599c07d0
2375

$ echo -e 'import zlib\nfrom hashlib import sha1\ndecompressed_contents=zlib.decompress(open("objects/00/009623a06b8dea7c151542fc789539599c07d0", "rb").read())\nprint sha1(decompressed_contents).hexdigest()\nprint decompressed_contents[0:19]' | python | hexdump -C
00000000  30 30 30 30 39 36 32 33  61 30 36 62 38 64 65 61  |00009623a06b8dea|
00000010  37 63 31 35 31 35 34 32  66 63 37 38 39 35 33 39  |7c151542fc789539|
00000020  35 39 39 63 30 37 64 30  0a 74 72 65 65 20 32 33  |599c07d0.tree 23|
00000030  37 35 00 31 30 30 36 34  34 20 2e 70 0a           |75.100644 .p.|
0000003d

$ git cat-file -p 00009623a06b8dea7c151542fc789539599c07d0 | cut -c -55 | head
100644 blob e465d57c345e2dcb117b5a30f9272b7fc5ec77cd    .p
100755 blob 7f16c1d4cbb75cf7bd635970a2588ced6ccea8ad    Ap
040000 tree 5261c0a3f3b4c688a082c3c5eaf03f8039bf153c    CA
100644 blob 188c0d0541523016352b6851e0f7200c18a372e6    CM
100644 blob c8b040ec356b21fcc06911c544149dc6f5d5b861    CM
100644 blob e441983f0fd4d57fb7bf640de31f728529f12c29    CM
100644 blob fd06c9c6ad662e099341f4e0a05b272c6370e64b    CM
100644 blob d433fb05ebca807f4487ae4cecf48ec3b66cce78    CM
100755 blob 4b1b049b83bcc7821a7b62977124bfcaa024d960    CM
040000 tree 150d60813c913ec9a178c4230b18fbda84edc2af    RE







[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux