I believe, my Git repository is not in good shape, wherein when I do a
git fsck
I get the following warnings at the top.
103b5dd53f7a96f8e3a02aea0d3d4d9bb19644ed: contains zero-padded file modes
bb4729593e76f66b46292ad6ae61bfe909558337: contains zero-padded file modes
4709aa73691ce7da36dd22ccfd157c4514395330: contains zero-padded file modes
I tried the following (suggested by a colleague) to find the offending commits, so that I could correct them. I tried the following methods.
- Go through all the commits from
git rev-list HEAD
. - For each of those commits, do a
git ls-tree -rd
to find all the relevant object SHAs. - See if any of those, matches with the above in the
git fsck
.
The logic of the above seemed right to me, but it was not able to find the offending commit.
git rev-list --all --remotes | while read commit; do git ls-tree -rd $commit | grep -E "103b5dd53f7a96f8e3a02aea0d3d4d9bb19644ed|bb4729593e76f66b46292ad6ae61bfe909558337|4709aa73691ce7da36dd22ccfd157c4514395330" && echo -e "HIT @ $commit\n\n"; done
What are we missing here? How can we find either the offending commit or file is having the problem? At the end, I want to fix the repository.