Skip to content
Browse files

Scripts to fix the broken commits in this repo

The result of this can be pushed to github and passes a "git fsck"
  • Loading branch information...
1 parent 3921792 commit 04849db0a374f6bab15444e27cc25ba797d9987a David Scott committed Jan 8, 2013
Showing with 28 additions and 0 deletions.
  1. +24 −0 fix-broken-repo.sh
  2. +4 −0 fix-date.sh
View
24 fix-broken-repo.sh
@@ -0,0 +1,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 <Jonathan.Ludlam@eu.citrix.com> > 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
View
4 fix-date.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+echo "$1" | sed -r 's/.*@[^0-9]*([0-9]+ [+-][0-9]+)/@\1/g'
+

0 comments on commit 04849db

Please sign in to comment.
Something went wrong with that request. Please try again.