summaryrefslogtreecommitdiffstats
path: root/scripts/mageia-reset-and-import.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/mageia-reset-and-import.sh')
-rwxr-xr-xscripts/mageia-reset-and-import.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/scripts/mageia-reset-and-import.sh b/scripts/mageia-reset-and-import.sh
index b24abe5..da290ec 100755
--- a/scripts/mageia-reset-and-import.sh
+++ b/scripts/mageia-reset-and-import.sh
@@ -99,6 +99,30 @@ else
git update-ref -m "Rewind SVN Git to pre-Magiea import" refs/remotes/trunk $resetsha1
git checkout master
git reset --hard trunk
+
+ # Remove any heads that are newer than this (except trunk)
+ resetreldate=$(git show -s --pretty='format:%ar' $resetsha1)
+ resettimestamp=$(git show -s --pretty='format:%at' $resetsha1)
+ echo "Removing any branches/tags newer than '$resetsha1' ($resetreldate)..."
+ git for-each-ref --format='%(refname)' refs/remotes/tags/* refs/remotes/branches/* | \
+ while read ref; do
+ # As svn tags show as new commits, we mustn't parse $ref directly, but
+ # traverse back up the tag tree to find the first commit that *do not*
+ # result in any changes (i.e. not an svn cp) and use that as our reference
+ # comparison point.
+ refsha1=$(git rev-parse "$ref":)
+ parentref=$ref
+ while [ $(git rev-parse --quiet --verify "$parentref"^: ) = "$refsha1" ]; do
+ parentref="$parentref"^
+ done
+
+ reftimestamp=$(git show -s --pretty='format:%at' $parentref)
+ if [ $reftimestamp -gt $resettimestamp ]; then
+ echo " Removing '$ref'"
+ git update-ref -d $ref
+ fi
+ done
+ echo "... done"
fi