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

Re: [PATCH] Proposal for git-svn

From
EWEric Wong <eric@petta-tech.com>
Date
Jul 19, 2007, 04:22 UTC
Message-ID
<20070719042255.GA17433@muzzle>
In-Reply-To
<FAFA899D-EC45-4313-98ED-2D0A3FF37669@lrde.epita.fr>
Benoit SIGOURE <tsuna@lrde.epita.fr> wrote:
Show 31 quoted lines
> Hello,
> 
> I'm importing many SVN repositories in Git and I ran across a problem:
> ufloat.h has mode 120000but is not a link
> 
> I've read the code and checked-out the revision where the problem  
> occured and it turns out that some stupid user commited a broken  
> symlink and I think that's where the problem came from.  I'm  
> proposing the following trivial change to let git-svn clone continue  
> its work:
> 
> diff --git a/git-svn.perl b/git-svn.perl
> index 01c3904..a82baf4 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -2555,8 +2555,8 @@ sub close_file {
>                 sysseek($fh, 0, 0) or croak $!;
>                 if ($fb->{mode_b} == 120000) {
>                         sysread($fh, my $buf, 5) == 5 or croak $!;
> -                       $buf eq 'link ' or die "$path has mode 120000",
> -                                              "but is not a link\n";
> +                       $buf eq 'link ' or warn "$path has mode 120000",
> +                                              " but is not a link\n";
>                 }
>                 defined(my $pid = open my $out,'-|') or die "Can't  
> fork: $!\n";
>                 if (!$pid) {
> 
> (I also added a whitespace because "120000but" does not look good :D)
> I checked out the problematic revision in git and I see the broken  
> symlink just like in SVN so I assume this change is correct.

Very strange. Since $buf didn't have the string "link " in it, did it have a path name in it? If so, the sysread() would've advanced the $fh offset by 5 bytes; causing an even more broken symlink to be added by git.

Would the following be more correct?
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -2552,9 +2552,15 @@ sub close_file {
 		}
 		sysseek($fh, 0, 0) or croak $!;
 		if ($fb->{mode_b} == 120000) {
-			sysread($fh, my $buf, 5) == 5 or croak $!;
-			$buf eq 'link ' or die "$path has mode 120000",
-			                       "but is not a link\n";
+			eval {
+				sysread($fh, my $buf, 5) == 5 or croak $!;
+				$buf eq 'link ' or die "$path has mode 120000",
+						       " but is not a link";
+			};
+			if ($@) {
+				warn "$@\n";
+				sysseek($fh, 0, 0) or croak $!;
+			}
 		}
 		defined(my $pid = open my $out,'-|') or die "Can't fork: $!\n";
 		if (!$pid) {
-- 
Eric Wong
Previous: Benoit SIGOURENext: Benoit SIGOURE
Message 2 of 3 in “Proposal for git-svn”
  1. Proposal for git-svnBenoit SIGOURE, Jul 18, 2007
  2. Eric WongJul 19, 2007
  3. Benoit SIGOUREJul 19, 2007

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.