Re: git-svn sucks when it should not
From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:44:54
Hi, On Mon, 7 Jul 2008, Eric Wong wrote:
Johannes Schindelin [off-list ref] wrote:quoted
[...] 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