Re: git-svn sucks when it should not
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jul 7, 2008, 11:49 UTC
- Message-ID
- <alpine.DEB.1.00.0807071242180.18205@racer>
- In-Reply-To
- <20080707094438.GA5964@untitled>
Hi,
On Mon, 7 Jul 2008, Eric Wong wrote:
Show 8 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote: > > > [...] a shell script that uses curl to find out what refs are new, and > > clones each ref individually, then pushes all the results together > > into one repository. > > It might be helpful to publish your script so other people can see/use > it.
-- snipsnap -- #!/bin/sh
# This script looks for the config variable svn-manual.url, and if it # is set, will traverse the url and its subdirectories with curl, and # install different svn-remotes for all found refs. # # It heavily relies on curl being able to screen-scrape the directories, # in other words, it wants an HTTP on the other side that has directory # listings enabled. # # The quick and dirty heuristics to find out what makes a ref is that # a ref's subdirectory contains files, while a subdirectory containing # only subdirectories is supposed to contain refs (or subdirectories # of refs).
list_contains_files () {
while test $# -gt 0
do
case "$1" in
*/) ;;
*) echo "$1";;
esac
shift
done
}svn_manually_fetch_one_dir () {
contents="$(curl --silent -k "$1"/ |
sed -n "s/.*a href=\"\([^\"]*\).*/\1/p" |
grep -ve '^\.\./$' -e '^http:' -e '^/')"
test -z "$contents" && return
test -z "$(list_contains_files $contents)" || {
test -z "$(git config svn-remote."$2".url)" && {
git config svn-remote."$2".url "$1" &&
git config svn-remote."$2".fetch :"$2" ||
return
}
git svn fetch -R "$2"
return
}
for dir in $contents
do
dir=${dir%%/}
svn_manually_fetch_one_dir "$1/$dir" "$2/$dir" || break
done
}svn_fetch_semi_manually () {
url="$(git config svn-manual.url)"
test -z "$url" && return 1
svn_manually_fetch_one_dir "$url" refs/remotes
}svn_fetch_semi_manually || git svn fetch