Question

I'm currently converting a CVS repository to multiple git repositories.

The cvs2git process is fine, but then I have problems running the filter-branch commands. I test the commands with simple scripts because the main repository size is 4Go with more than 14k commits.

During the process, I want to replace some archives by their content in the history of the git repo.

Here is the script I use to test my filter-branch --tree-filter command:

#!/bin/bash

BASEDIR=/tmp/migration_git
if test ! -d $BASEDIR; then
 mkdir $BASEDIR
fi

script_tree_filter='\
archives=`find . -name "archive.tgz"`; \
CURDIR=`pwd`; \
for archive in $archives; do \
cd `dirname $archive`; \
tar xzf archive.tgz ; \
rm -f archive.tgz ; \
cd $CURDIR;\
done'

cd $BASEDIR
if test -d repo.server.git; then
  rm -rf repo.server.git;
fi
mkdir repo.server.git && cd repo.server.git && git init
touch a toto && tar czf archive.tgz a && rm a && git add . && git commit -am "1st commit" && git tag commit1
touch b a && rm archive.tgz &&  tar czf archive.tgz a b && rm a b && git commit -am "2nd commit" && git tag commit2
touch a b c && rm archive.tgz &&  tar czf archive.tgz a b c && rm a b c && git commit -am "3rd commit" && git tag commit3
# git rm archive.tgz && mkdir rep1 rep2
mkdir rep1 rep2
cd rep1 && touch a b c d && tar czf archive.tgz a b c d && rm a b c d && cd ..
cd rep2 && touch a b c d && tar czf archive.tgz a b c d && rm a b c d && cd ..
git add . && git commit -am "4th commit" && git tag commit4

cd $BASEDIR
if test -d repo.client.git; then
  rm -rf repo.client.git;
fi
git clone repo.server.git repo.client.git
cd $BASEDIR/repo.client.git

git filter-branch -f -d /tmp/test_git --tag-name-filter cat --prune-empty --tree-filter "$script_tree_filter" -- --all
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
git reflog expire --expire=now --all
git gc --prune=now

I have 2 questions:

  1. At the end the script shows an error during the process:

    error: Untracked working tree file 'a' would be overwritten by merge.

    If the client clone is done using --mirror:

    git clone --mirror repo.server.git repo.client.git

    the error won't appear. I don't understand why.

  2. When I cd to repo.client.git, the repository has local modifications: the archives are present and the files I wanted to keep are git removed. I don't understand neither. Edit: either the files a, b, c, d are empty or not does not change the result.

Était-ce utile?

La solution

After the remark of DomQ, I upgraded my version of Git (1.8.0 => 1.8.3) and the problem does not appear anymore.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top