使用hg-fast-export.sh后如何修复git log?

时间:2011-07-31 18:18:23

标签: git git-filter-branch

我的git repo似乎已损坏。

$ git push -u origin master
Counting objects: 16157, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5794/5794), done.
error: object 7e2ee8b2364db1cab7a340a1d5d26cd40aa0deff:invalid author/committer line - bad date
fatal: Error in object
error: pack-objects died of signal 13

$ git cat-file -p  7e2ee8b2364db1cab7a340a1d5d26cd40aa0deff
tree 00258bdecaf83c001ae1be7dbedbd0eeee25c373
parent 7d15e8d2ea1ff5ef98a0996ed14b8b236f1461ec
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> <Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>> 1219589646 +0200
committer Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> <Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>> 1219589646 +0200

Add __APPLE__ to most #if linux compile time switches.

所以电子邮件似乎错了,雅各布·卡尔博格如何解决它?

1 个答案:

答案 0 :(得分:1)

似乎已修复

#!/usr/bin/env bash
git filter-branch --env-filter '
get_name () {
    grep "^$1=" "$authors_file" |
    sed "s/^.*=\(.*\) <.*>$/\1/"
}

get_email () {
    grep "^$1=" "$authors_file" |
    sed "s/^.*=.* <\(.*\)>$/\1/"
}

an="$GIT_AUTHOR_NAME"
am="$GIT_AUTHOR_EMAIL"
cn="$GIT_COMMITTER_NAME"
cm="$GIT_COMMITTER_EMAIL"

if [ $GIT_COMMIT = "7e2ee8b2364db1cab7a340a1d5d26cd40aa0deff" ]
then
    cn="Jacob Carlborg"
    cm="<jacob.carlborg@gmail.com>"
    an="Jacob Carlborg"
    am="<jacob.carlborg@gmail.com>"
else
    cn="$GIT_AUTHOR_NAME"
    cm="$GIT_AUTHOR_EMAIL"
    an="$GIT_AUTHOR_NAME"
    am="get_email $GIT_COMMITTER_NAME"
fi

export GIT_AUTHOR_NAME="$an"
export GIT_AUTHOR_EMAIL="$am"
export GIT_COMMITTER_NAME="$cn"
export GIT_COMMITTER_EMAIL="$cm"

可以删除其他块