Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix Git zero-padded file modes warning

Tags:

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.

  1. Go through all the commits from git rev-list HEAD.
  2. For each of those commits, do a git ls-tree -rd to find all the relevant object SHAs.
  3. 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.

like image 211
Senthil Kumaran Avatar asked Feb 05 '13 05:02

Senthil Kumaran


2 Answers

Adding workaround from comments as answer:

Rebuilding the repo using git fast-export and then git fast-import resolves the problem but SHA values will change and tree references are not brought over.

Create a new empty repository:

mkdir /newrepo
cd /newrepo
git init

Go back to the old one with the fsck warnings:

cd /oldrepo

Pipe the data over using fast-export from old data to fast-import in the new repo

git fast-export --all | (cd /newrepo && git fast-import)
like image 66
JosefAssad Avatar answered Oct 03 '22 07:10

JosefAssad


Just a supplement with @9000's answer:

Create an empty git repo in ../newrepo, and

git fast-export --signed-tags=strip --all | (cd ../newrepo/ && git fast-import)
like image 21
NewPtone Avatar answered Oct 03 '22 07:10

NewPtone