Created
September 21, 2013 17:46
-
-
Save c00kiemon5ter/6652617 to your computer and use it in GitHub Desktop.
convert a git repo to svn and backwards
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# convert a git repo to svn or, an svn repo to git | |
# - git-core/git, subversion/svn and subgit ver 2.x.x should be installed | |
# - when converting from git to svn, a git-bare repo will be created | |
# | |
# HOW TO USE | |
# invoke make giving the appropriate target for the conversion and | |
# also definig the REPO variable that represents the repository name. | |
# do _not_ insert a leading / when specifying the repository name! | |
# example #1: make REPO=/path/to/some/git/repo svn | |
# example #2: make REPO=/path/to/some/svn/repo git | |
# | |
GIT_REPO := $(notdir $(REPO))-git | |
SVN_REPO := $(notdir $(REPO))-svn | |
all: | |
@echo "available targets are 'svn' and 'git'" | |
REPO: | |
ifndef REPO | |
@echo "error: specify the repository name by defining the REPO var when invoking make" | |
@echo "NOTICE: do _not_ insert a leading / when specifying the repository name" | |
@false | |
endif | |
subgit: | |
@subgit --version | grep -q -F "SubGit version 2." | |
svn: REPO subgit | |
@printf "creating svn repo '%s' using git repo '%s'\n" $(SVN_REPO) $(REPO) | |
@git clone --bare $(REPO) $(GIT_REPO) | |
@svnadmin create $(SVN_REPO) | |
@subgit configure $(SVN_REPO) | |
@printf '%s\n' "/^\[git[[:blank:]]/" \ | |
"/^[[:blank:]]*repository[[:blank:]]*=/" \ | |
"s/=.*/= ..\/$(GIT_REPO)/" \ | |
"wq" | ed -s $(SVN_REPO)/conf/subgit.conf | |
@subgit install $(SVN_REPO) | |
git: REPO subgit | |
@echo " --=-- TODO --=-- " | |
@printf "creating git repo '%s' using svn repo '%s'\n" $(GIT_REPO) $(REPO) | |
@subgit import $(REPO) | |
.PHONY: all REPO subgit svn git |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dependencies: