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

[PATCH] git-svn now work with crlf convertion enabled.

From
ALAlexander Litvinov <litvinov2004@gmail.com>
Date
Jul 31, 2008, 05:43 UTC
Message-ID
<200807311243.35219.litvinov2004@gmail.com>
In-Reply-To
<alpine.DEB.1.00.0807231117290.2830@eeepc-johanness>
Make git-svn works with crlf (or any other) file content convertion enabled.
When we modify file content SVN cant apply its delta to it. To fix this
situation I take full file content from SVN as next revision. This is
dump and slow but it works.
---
 git-svn.perl |   34 +++++++++++++++++++---------------
 1 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index cf6dbbc..606a177 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -28,6 +28,7 @@ sub fatal (@) { print STDERR "@_\n"; exit 1 }
 require SVN::Core; # use()-ing this causes segfaults for me... *shrug*
 require SVN::Ra;
 require SVN::Delta;
+require SVN::Client;
 if ($SVN::Core::VERSION lt '1.1.0') {
 	fatal "Need SVN::Core 1.1.0 or better (got $SVN::Core::VERSION)";
 }
@@ -3075,6 +3076,7 @@ sub new {
 	my $self = SVN::Delta::Editor->new;
 	bless $self, $class;
 	$self->{c} = $git_svn->{last_commit} if exists $git_svn->{last_commit};
+	$self->{url} = $git_svn->{url};
 	$self->{empty} = {};
 	$self->{dir_prop} = {};
 	$self->{file_prop} = {};
@@ -3214,30 +3216,32 @@ sub change_file_prop {
 
 sub apply_textdelta {
 	my ($self, $fb, $exp) = @_;
-	my $fh = IO::File->new_tmpfile;
-	$fh->autoflush(1);
-	# $fh gets auto-closed() by SVN::TxDelta::apply(),
-	# (but $base does not,) so dup() it for reading in close_file
-	open my $dup, '<&', $fh or croak $!;
+
 	my $base = IO::File->new_tmpfile;
 	$base->autoflush(1);
 	if ($fb->{blob}) {
 		print $base 'link ' if ($fb->{mode_a} == 120000);
 		my $size = $::_repository->cat_blob($fb->{blob}, $base);
 		die "Failed to read object $fb->{blob}" if ($size < 0);
-
-		if (defined $exp) {
-			seek $base, 0, 0 or croak $!;
-			my $got = ::md5sum($base);
-			die "Checksum mismatch: $fb->{path} $fb->{blob}\n",
-			    "expected: $exp\n",
-			    "     got: $got\n" if ($got ne $exp);
-		}
 	}
 	seek $base, 0, 0 or croak $!;
-	$fb->{fh} = $dup;
+
+	my $fh = IO::File->new_tmpfile;
+	$fh->autoflush(1);
+
+	$fb->{fh} = $fh;
 	$fb->{base} = $base;
-	[ SVN::TxDelta::apply($base, $fh, undef, $fb->{path}, $fb->{pool}) ];
+
+	my $url = $self->{url};
+	$url =~ s/\/$//;
+	$url .= '/';
+	$url .= $fb->{path};
+
+	my $rev = $self->{file_prop}->{$fb->{path}}->{'svn:entry:committed-rev'};
+	die ("Can't find $fb->{path} revision") unless defined $rev;
+
+	my $ctx = SVN::Client->new();
+	$ctx->cat($fh, $url, $rev);
 }
 
 sub close_file {
-- 
1.5.6.2
Previous: Alexander LitvinovNext: Alexander Litvinov
Message 18 of 45 in “git-svn does not seems to work with crlf convertion enabled.”
  1. Alexander LitvinovJul 23, 2008
  2. Johannes SchindelinJul 23, 2008
  3. Alexander LitvinovJul 23, 2008
  4. Johannes SchindelinJul 23, 2008
  5. Avery PennarunJul 23, 2008
  6. Johannes SchindelinJul 23, 2008
  7. Alexander LitvinovJul 24, 2008
  8. Petr BaudisAug 6, 2008
  9. Peter HarrisAug 6, 2008
  10. Johannes SchindelinAug 6, 2008
  11. git-svn on MSysGit and why is it (going to be?) unsupportedPetr Baudis, Aug 6, 2008
  12. Avery PennarunAug 6, 2008
  13. Dmitry PotapovAug 6, 2008
  14. Dmitry PotapovJul 24, 2008
  15. Johannes SchindelinJul 24, 2008
  16. Avery PennarunJul 24, 2008
  17. Alexander LitvinovJul 30, 2008
  18. git-svn now work with crlf convertion enabled.Alexander Litvinov, Jul 31, 2008
  19. Alexander LitvinovJul 31, 2008
  20. Dmitry PotapovJul 31, 2008
  21. [RFC] hash-object --no-filtersDmitry Potapov, Jul 31, 2008
  22. Alexander LitvinovAug 1, 2008
  23. Junio C HamanoAug 1, 2008
  24. Dmitry PotapovAug 1, 2008
  25. Alexander LitvinovAug 1, 2008
  26. Dmitry PotapovAug 1, 2008
  27. Junio C HamanoAug 1, 2008
  28. Dmitry PotapovAug 1, 2008
  29. Junio C HamanoAug 1, 2008
  30. Dmitry PotapovAug 1, 2008
  31. Junio C HamanoAug 1, 2008
  32. Dmitry PotapovAug 1, 2008
  33. Junio C HamanoAug 2, 2008
  34. Dmitry PotapovAug 3, 2008
  35. Dmitry PotapovAug 3, 2008
  36. 1/5 correct argument checking test for git hash-objectDmitry Potapov, Aug 3, 2008
  37. 2/5 correct usage help string for git-hash-objectDmitry Potapov, Aug 3, 2008
  38. 3/5 use parse_options() in git hash-objectDmitry Potapov, Aug 3, 2008
  39. 4/5 add --path option to git hash-objectDmitry Potapov, Aug 3, 2008
  40. 5/5 add --no-filters option to git hash-objectDmitry Potapov, Aug 3, 2008
  41. Junio C HamanoAug 3, 2008
  42. Alexander LitvinovAug 1, 2008
  43. Dmitry PotapovAug 1, 2008
  44. Alexander LitvinovAug 4, 2008
  45. Eric WongAug 4, 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.