fork-dev / Tracker

Bug and issue tracker for Fork for Mac
493 stars 12 forks source link

[bug?] Strange behavior on seemingly corrupted repository #2118

Open Meorge opened 2 months ago

Meorge commented 2 months ago

Today I restored a Time Machine backup on my computer, and after doing so went to check on one of my repositories. I found I was unable to view the list of commits, and the "detail" panel was full of numbers:

CleanShot 2024-04-27 at 21 42 04@2x

When I tried to fetch changes, I got this: CleanShot 2024-04-27 at 22 08 24@2x

Running git fsck on the repository, I can see there are a bunch of issues with it:

Checking object directories: 100% (256/256), done.
Checking objects: 100% (868/868), done.
error: HEAD: invalid reflog entry 976361a9018a860de264cf827d753b8e541c4abf
error: HEAD: invalid reflog entry 976361a9018a860de264cf827d753b8e541c4abf
error: refs/heads/main: invalid reflog entry 976361a9018a860de264cf827d753b8e541c4abf
error: refs/heads/main: invalid reflog entry 976361a9018a860de264cf827d753b8e541c4abf
error: refs/remotes/origin/main: invalid reflog entry 976361a9018a860de264cf827d753b8e541c4abf
error: refs/remotes/origin/main: invalid reflog entry 976361a9018a860de264cf827d753b8e541c4abf
error: c21a5acfe67a7485727588a49f225b488a23cffc: invalid sha1 pointer in cache-tree
broken link from    tree 063343e946d1507efa4b503d25f40b99991f9b78
              to    tree c21a5acfe67a7485727588a49f225b488a23cffc
broken link from  commit f3bb6f3d3df4dd197cca151fa1acdcce73da623a
              to  commit 976361a9018a860de264cf827d753b8e541c4abf
broken link from    tree cbf0869df75ee3ad24af3664deb4d1258c9f9501
              to    blob 640b37dcbb010fa22198f0180f455a4a959c6553
dangling blob 3a40e320fb00f0196df664c632987efd97c1a455
dangling blob e740509f7b8ee6cb7eaafe6a0cb05193159639ce
dangling blob 4ac136f3e742b1cbbdf5edd68513df93829979dd
... (a bunch more "dangling blobs")

I've gone through and checked older copies of the repository via Time Machine, and as far as I can tell, the corruption appeared to have happened during one of the Time Machine backups (i.e., Fork did not corrupt the repository, to my understanding). Between that and cloning a new copy from GitHub, it looks like everything is ultimately okay, but it could be nice to have a more usable message for situations like this.

I'm holding onto the corrupted copy of the repository for now, so if there's any more information you'd like me to gather on it, I can do so.

DanPristupov commented 2 months ago

Hi,

I think, the problem is unrelated to Fork. It just happened that the repository got corrupted. I don't know how Time Machine works internally, but may be it made a snapshot in some intermediate repository state (when gc was running, for example).

DanPristupov commented 2 months ago
error: refs/heads/main: invalid reflog entry 976361a9018a860de264cf827d753b8e541c4abf
error: refs/heads/main: invalid reflog entry 976361a9018a860de264cf827d753b8e541c4abf
error: refs/remotes/origin/main: invalid reflog entry 976361a9018a860de264cf827d753b8e541c4abf
error: refs/remotes/origin/main: invalid reflog entry 976361a9018a860de264cf827d753b8e541c4abf

Make a backup of the repo and try to remove those reflog files: .git/logs/refs/heads/main and .git/logs/refs/remotes/origin/main

Or even remove whole .git/logs/ directory

Meorge commented 2 months ago

Thanks for the quick response! Unfortunately, I tried both of those, and it appears the issue is persisting. I was able to pull the most recent version of the repository from GitHub, though, so it's not a huge issue. šŸ˜„

As I said before, I don't think that Fork was to blame for the corruption - looks more likely to me that it had to do with Time Machine, as well. I just thought that Fork's behavior displaying the corrupted repository (empty commit view with a bunch of numbers in the detail panel) was confusing, and it might be good to have it display something else instead, perhaps detecting when the repository is corrupted and telling the user so?

The reason I marked this as [bug?] and not just [bug] is that it's dealing with a corrupted repository, so I'm not sure how much Fork should be expected to handle that kind of situation šŸ˜… Tools for recognizing (and especially repairing) corrupted repos would be awesome, but also perhaps out of scope