From f276815a6468a10da9ea381b58b92e32450cf7ab Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Fri, 14 Sep 2012 09:34:32 +0100 Subject: Script for converting git cache. This script converts a git cache from the current format to the new bare format. It need only stay around for a while (perhaps until after the next Baserock release) and then it can be removed. --- scripts/convert-git-cache | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 scripts/convert-git-cache (limited to 'scripts/convert-git-cache') diff --git a/scripts/convert-git-cache b/scripts/convert-git-cache new file mode 100755 index 00000000..95ed83c8 --- /dev/null +++ b/scripts/convert-git-cache @@ -0,0 +1,51 @@ +#!/bin/sh +# +# Copyright (C) 2012 Codethink Limited +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# This is a program to convert the json dump of the overlaps between artifacts +# in a format more suited to shell programs, or human reading + +set -eu + +CACHE_ROOT=$(morph --dump-config | grep cachedir | cut -d\ -f3) + +REPO_CACHE="${CACHE_ROOT}/gits" + +for REPO_DIR in $(cd "${REPO_CACHE}"; ls); do + cd "${REPO_CACHE}/${REPO_DIR}" + if test -d .git; then + echo "Converting ${REPO_DIR}" + mv .git/* . + rmdir .git + git config core.bare true + git config remote.origin.mirror true + git config remote.origin.fetch "+refs/*:refs/*" + echo "Migrating refs, please hold..." + rm -f refs/remotes/origin/HEAD + for REF in $(git branch -r); do + BRANCH=${REF#origin/} + git update-ref "refs/heads/${BRANCH}" \ + $(git rev-parse "refs/remotes/${REF}") + git update-ref -d "refs/remotes/${REF}" + done + echo "Re-running remote update with --prune" + if ! git remote update origin --prune; then + echo "${REPO_DIR} might be broken." + fi + else + echo "Do not need to convert ${REPO_DIR}" + fi +done -- cgit v1.2.1