Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.0k views
in Technique[技术] by (71.8m points)

git - invalid author/committer line - missing space before email

I have a git repository that was cloned from a bzr repository using git-remote-bzr as follows: git clone bzr::/repo new-repo. After a few hundreds of commits, I executed git fsck and I got the following error for all the bzr commits:

error in commit 41bf5: invalid author/committer line - missing space before email

When I check these revisions with git cat-file -p 41bf5 I can indeed see that the author name and the email are not separated with a space.

How can I add this missing space for all the bad commits ?

I have full access to the repo on the server so I can rewrite the history without any problems. After modifications the users of the code will have to reclone the repository. I already tried without success the solutions proposed in the following posts:

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The solution to my question came from a friend that asked me to write the answer on his behalf:

  1. Filter the repo, changing the bogus author with the following. Note that this should be on two separate lines (normally using shift+enter):

    $ git filter-branch --commit-filter 'case "$GIT_AUTHOR_NAME" in
    > *author< email*) GIT_AUTHOR_NAME=author_name; GIT_AUTHOR_EMAIL=author_email;; esac; git commit-tree "$@" '
    
  2. Since the faulty commits are still in the repository, git fsck will still fail on them. To get rid of those commits, clone the repo and then prune unused objects:

    $ git clone badrepo goodrepo && cd goodrepo
    $ git gc --prune=all
    
  3. The new repository is clean. git fsck returns no errors.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...