forked from xapi-project/xen-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fix-broken-repo.sh
executable file
·24 lines (23 loc) · 1.06 KB
/
fix-broken-repo.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
export FIX_DATE=`pwd`/../fix-date.sh
[ -x $FIX_DATE ] || exit 1
# xen-api fails a "git fsck" because it has bad timezone data in commit timestamps::
# '@ <Jonathan Ludlam <[email protected]> > 1255377615 +0100'
git filter-branch -f --commit-filter '
echo "id = $GIT_COMMIT committer date = $GIT_COMMITTER_DATE" >> /tmp/foo
echo "id = $GIT_COMMIT author date = $GIT_AUTHOR_DATE" >> /tmp/foo
GIT_COMMITTER_DATE2=$(${FIX_DATE} "${GIT_COMMITTER_DATE}")
GIT_AUTHOR_DATE2=$(${FIX_DATE} "${GIT_AUTHOR_DATE}")
if [ "${GIT_COMMITTER_DATE}" != "${GIT_COMMITTER_DATE2}" ];
then
echo "Rewriting ${GIT_COMMITTER_DATE} > ${GIT_COMMITTER_DATE2}" >> /tmp/foo
export GIT_COMMITTER_DATE="${GIT_COMMITTER_DATE2}"
fi
if [ "${GIT_AUTHOR_DATE}" != "${GIT_AUTHOR_DATE2}" ];
then
echo "Rewriting ${GIT_AUTHOR_DATE} > ${GIT_AUTHOR_DATE2}" >> /tmp/foo
export GIT_AUTHOR_DATE="${GIT_AUTHOR_DATE2}"
fi
git commit-tree "$@";
' --tag-name-filter cat -- --all
rm -rf .git/refs/original/ && git reflog expire --all && git gc --aggressive --prune