# [PATCH 0/1] Tried to fix git-svn's handling of filenames with embedded '@'.

9 messages from 2006-05-28 to 2006-05-30. Participants: Seth Falcon, Junio C Hamano, Eric Wong.
Thread: https://gitlist.dev/t/4316

## Seth Falcon, 2006-05-28 18:15

Subject: [PATCH 0/1] Tried to fix git-svn's handling of filenames with embedded '@'.
Message-ID: <m21wuem2xj.fsf@ziti.fhcrc.org>
URL: https://gitlist.dev/e/m21wuem2xj.fsf%40ziti.fhcrc.org

```
Hi Eric, all,

I decided to give git-svn a try for a large svn project and during my
first git-svn fetch operation, I'm seeing a failure that seems related
to recent changes in the handling of svn keywords.

Here is the traceback:

svn: Syntax error parsing revision '.R'
256 at /home/sfalcon/util/scm/bin/git-svn line 1124
        main::safe_qx('svn', 'propget', 'svn:keywords', 'Biobase/inst/Code/R/get@PKGNAME@.R') called at /home/sfalcon/util/scm/bin/git-svn line 900
        main::do_update_index('ARRAY(0x8395840)', 'add', 'undef')
        called at /home/sfalcon/util/scm/bin/git-svn line 926

Unfortunately, my project has a file named "get@PKGNAME@.R" and svn
thinks the '@.R' part is specifying a revision.  Here comes a patch
that got me going again.  Not sure it is the right fix, nor whether it
covers all places where some action will be needed.

Best,

+ seth

```

## Seth Falcon, 2006-05-28 18:15

Subject: [PATCH 1/1] Tried to fix git-svn's handling of filenames with embedded '@'.
Message-ID: <m2verqkobr.fsf@ziti.fhcrc.org>
URL: https://gitlist.dev/e/m2verqkobr.fsf%40ziti.fhcrc.org
In-Reply-To: <m21wuem2xj.fsf@ziti.fhcrc.org>

```
svn has trouble parsing files with embedded '@' characters.  For
example,

  svn propget svn:keywords foo@bar.c
  svn: Syntax error parsing revision 'bar.c'

I asked about this on #svn and the workaround suggested was to append
an explicit revision specifier:

  svn propget svn:keywords foo@bar.c@BASE

This patch appends '@BASE' to the filename in all calls to 'svn
propget'.
---
 contrib/git-svn/git-svn.perl |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index b3e0684..498ffe0 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -336,7 +336,7 @@ sub show_ignore {
 	my %ign;
 	File::Find::find({wanted=>sub{if(lstat $_ && -d _ && -d "$_/.svn"){
 		s#^\./##;
-		@{$ign{$_}} = safe_qx(qw(svn propget svn:ignore),$_);
+		@{$ign{$_}} = safe_qx(qw(svn propget svn:ignore),$_ . "\@BASE");
 		}}, no_chdir=>1},'.');
 
 	print "\n# /\n";
@@ -860,7 +860,7 @@ sub sys { system(@_) == 0 or croak $? }
 
 sub eol_cp {
 	my ($from, $to) = @_;
-	my $es = safe_qx(qw/svn propget svn:eol-style/, $to);
+	my $es = safe_qx(qw/svn propget svn:eol-style/, $to . "\@BASE");
 	open my $rfd, '<', $from or croak $!;
 	binmode $rfd or croak $!;
 	open my $wfd, '>', $to or croak $!;
@@ -898,7 +898,8 @@ sub do_update_index {
 	while (my $x = <$p>) {
 		chomp $x;
 		if (!$no_text_base && lstat $x && ! -l _ &&
-				safe_qx(qw/svn propget svn:keywords/,$x)) {
+				safe_qx(qw/svn propget svn:keywords/,
+                                        $x . "\@BASE")) {
 			my $mode = -x _ ? 0755 : 0644;
 			my ($v,$d,$f) = File::Spec->splitpath($x);
 			my $tb = File::Spec->catfile($d, '.svn', 'tmp',
-- 
1.3.3.gb931

```

## Junio C Hamano, 2006-05-28 20:42

Subject: Re: [PATCH 1/1] Tried to fix git-svn's handling of filenames with embedded '@'.
Message-ID: <7vlksldgp2.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vlksldgp2.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <m2verqkobr.fsf@ziti.fhcrc.org>

```
Seth Falcon <sethfalcon@gmail.com> writes:

> svn has trouble parsing files with embedded '@' characters.  For
> example,
>
>   svn propget svn:keywords foo@bar.c
>   svn: Syntax error parsing revision 'bar.c'
>
> I asked about this on #svn and the workaround suggested was to append
> an explicit revision specifier:
>
>   svn propget svn:keywords foo@bar.c@BASE
>
> This patch appends '@BASE' to the filename in all calls to 'svn
> propget'.

Eric, this sounds sane to me.  Ack?

```

## Eric Wong, 2006-05-29 05:25

Subject: Re: [PATCH 1/1] Tried to fix git-svn's handling of filenames with embedded '@'.
Message-ID: <20060529052403.GA24077@localdomain>
URL: https://gitlist.dev/e/20060529052403.GA24077%40localdomain
In-Reply-To: <7vlksldgp2.fsf@assigned-by-dhcp.cox.net>

```
Junio C Hamano <junkio@cox.net> wrote:
> Seth Falcon <sethfalcon@gmail.com> writes:
> 
> > svn has trouble parsing files with embedded '@' characters.  For
> > example,
> >
> >   svn propget svn:keywords foo@bar.c
> >   svn: Syntax error parsing revision 'bar.c'
> >
> > I asked about this on #svn and the workaround suggested was to append
> > an explicit revision specifier:
> >
> >   svn propget svn:keywords foo@bar.c@BASE
> >
> > This patch appends '@BASE' to the filename in all calls to 'svn
> > propget'.
> 
> Eric, this sounds sane to me.  Ack?

Doesn't work with svn 1.1 (a requirement of mine, unfortunately).  I'll
have a fix for that in a bit.

-- 
Eric Wong

```

## Eric Wong, 2006-05-29 06:35

Subject: Re: [PATCH 1/1] Tried to fix git-svn's handling of filenames with embedded '@'.
Message-ID: <20060529063543.GA8128@localdomain>
URL: https://gitlist.dev/e/20060529063543.GA8128%40localdomain
In-Reply-To: <m2verqkobr.fsf@ziti.fhcrc.org>

```
Seth: how does this work?

Ick, I just found out keyword killing tests don't pass with
svn 1.1, though...

--- 

svn has trouble parsing files with embedded '@' characters.  For
example,

  svn propget svn:keywords foo@bar.c
  svn: Syntax error parsing revision 'bar.c'

I asked about this on #svn and the workaround suggested was to append
an explicit revision specifier:

  svn propget svn:keywords foo@bar.c@BASE

This patch appends '@BASE' to the filename in all calls to 'svn
propget'.

Patch originally by Seth Falcon <sethfalcon@gmail.com>
Seth: signoff?

[ew: Made to work with older svn that don't support peg revisions]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 contrib/git-svn/git-svn.perl |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index b3e0684..54b93f4 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -34,7 +34,7 @@ my $sha1_short = qr/[a-f\d]{4,40}/;
 my ($_revision,$_stdin,$_no_ignore_ext,$_no_stop_copy,$_help,$_rmdir,$_edit,
 	$_find_copies_harder, $_l, $_version, $_upgrade, $_authors);
 my (@_branch_from, %tree_map, %users);
-my $_svn_co_url_revs;
+my ($_svn_co_url_revs, $_svn_pg_peg_revs);
 
 my %fc_opts = ( 'no-ignore-externals' => \$_no_ignore_ext,
 		'branch|b=s' => \@_branch_from,
@@ -336,7 +336,7 @@ sub show_ignore {
 	my %ign;
 	File::Find::find({wanted=>sub{if(lstat $_ && -d _ && -d "$_/.svn"){
 		s#^\./##;
-		@{$ign{$_}} = safe_qx(qw(svn propget svn:ignore),$_);
+		@{$ign{$_}} = svn_propget_base('svn:ignore', $_);
 		}}, no_chdir=>1},'.');
 
 	print "\n# /\n";
@@ -860,7 +860,7 @@ sub sys { system(@_) == 0 or croak $? }
 
 sub eol_cp {
 	my ($from, $to) = @_;
-	my $es = safe_qx(qw/svn propget svn:eol-style/, $to);
+	my $es = svn_propget_base('svn:eol-style', $to);
 	open my $rfd, '<', $from or croak $!;
 	binmode $rfd or croak $!;
 	open my $wfd, '>', $to or croak $!;
@@ -898,7 +898,7 @@ sub do_update_index {
 	while (my $x = <$p>) {
 		chomp $x;
 		if (!$no_text_base && lstat $x && ! -l _ &&
-				safe_qx(qw/svn propget svn:keywords/,$x)) {
+				svn_propget_base('svn:keywords', $x)) {
 			my $mode = -x _ ? 0755 : 0644;
 			my ($v,$d,$f) = File::Spec->splitpath($x);
 			my $tb = File::Spec->catfile($d, '.svn', 'tmp',
@@ -1136,6 +1136,9 @@ sub svn_compat_check {
 	if (grep /usage: checkout URL\[\@REV\]/,@co_help) {
 		$_svn_co_url_revs = 1;
 	}
+	if (grep /\[TARGET\[\@REV\]\.\.\.\]/, `svn propget -h`) {
+		$_svn_pg_peg_revs = 1;
+	}
 
 	# I really, really hope nobody hits this...
 	unless (grep /stop-on-copy/, (safe_qx(qw(svn log -h)))) {
@@ -1215,6 +1218,12 @@ sub load_authors {
 	close $authors or croak $!;
 }
 
+sub svn_propget_base {
+	my ($p, $f) = @_;
+	$f .= '@BASE' if $_svn_pg_peg_revs;
+	return safe_qx(qw/svn propget/, $p, $f);
+}
+
 __END__
 
 Data structures:
-- 
1.3.3.gef0f

```

## Seth Falcon, 2006-05-29 17:47

Subject: Re: [PATCH 1/1] Tried to fix git-svn's handling of filenames with embedded '@'.
Message-ID: <m24pz8lo4o.fsf@ziti.fhcrc.org>
URL: https://gitlist.dev/e/m24pz8lo4o.fsf%40ziti.fhcrc.org
In-Reply-To: <20060529063543.GA8128@localdomain>

```
Eric Wong <normalperson@yhbt.net> writes:

> Seth: how does this work?

Your revised patch works for me, thanks.

+ seth

```

## Eric Wong, 2006-05-30 02:03

Subject: [PATCH] git-svn: compat fixes for older svn and dash
Message-ID: <1148954626387-git-send-email-normalperson@yhbt.net>
URL: https://gitlist.dev/e/1148954626387-git-send-email-normalperson%40yhbt.net
In-Reply-To: <20060529063543.GA8128@localdomain>

```

The following patches work around problems I had with testing
git-svn on my Debian Sarge box.

```

## Eric Wong, 2006-05-30 02:03

Subject: [PATCH] git-svn: t0001: workaround a heredoc bug in old versions of dash
Message-ID: <11489546262736-git-send-email-normalperson@yhbt.net>
URL: https://gitlist.dev/e/11489546262736-git-send-email-normalperson%40yhbt.net
In-Reply-To: <20060529063543.GA8128@localdomain>

```
The dash installed on my Debian Sarge boxes don't seem to like
<<'' as a heredoc starter.  Recent versions of dash do not need
this fix.

Signed-off-by: Eric Wong <normalperson@yhbt.net>

---

 contrib/git-svn/t/t0001-contrib-git-svn-props.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

edbca3e1b96747330a4b1459e914b07105b3bc44
diff --git a/contrib/git-svn/t/t0001-contrib-git-svn-props.sh b/contrib/git-svn/t/t0001-contrib-git-svn-props.sh
index 6fa7889..23a5a2a 100644
--- a/contrib/git-svn/t/t0001-contrib-git-svn-props.sh
+++ b/contrib/git-svn/t/t0001-contrib-git-svn-props.sh
@@ -20,9 +20,10 @@ a_empty_cr=
 a_empty_crlf=
 
 cd import
-	cat >> kw.c <<''
+	cat >> kw.c <<\EOF
 /* Make it look like somebody copied a file from CVS into SVN: */
 /* $Id: kw.c,v 1.1.1.1 1994/03/06 00:00:00 eric Exp $ */
+EOF
 
 	printf "Hello\r\nWorld\r\n" > crlf
 	a_crlf=`git-hash-object -w crlf`
-- 
1.3.2.g7d11

```

## Eric Wong, 2006-05-30 02:03

Subject: [PATCH] git-svn: remove assertion that broke with older versions of svn
Message-ID: <1148954626357-git-send-email-normalperson@yhbt.net>
URL: https://gitlist.dev/e/1148954626357-git-send-email-normalperson%40yhbt.net
In-Reply-To: <20060529063543.GA8128@localdomain>

```
svn < 1.3.x would display changes to keywords lines as modified
if they aren't expanded in the working copy.  We already check
for changes against the git tree here, so checking against the
svn one is probably excessive.

Signed-off-by: Eric Wong <normalperson@yhbt.net>

---

 contrib/git-svn/git-svn.perl |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

b430de64cb228512b9a817499203827c0ef645aa
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index b3e0684..aac8779 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -567,7 +567,6 @@ sub precommit_check {
 sub svn_checkout_tree {
 	my ($svn_rev, $treeish) = @_;
 	my $from = file_to_s("$REV_DIR/$svn_rev");
-	assert_svn_wc_clean($svn_rev);
 	assert_tree($from);
 	print "diff-tree $from $treeish\n";
 	my $pid = open my $diff_fh, '-|';
-- 
1.3.2.g7d11

```
