git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Eric WongNext: Avery Pennarun
Message 3 of 5 in “git-svn sucks when it should not”
  1. Johannes SchindelinJul 7, 2008
  2. Eric WongJul 7, 2008
  3. Johannes SchindelinJul 7, 2008
  4. Avery PennarunJul 7, 2008
  5. Johannes SchindelinJul 7, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.