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

Re: [PATCH 1/3] Accept root <tree-ish> in 'git-svn commit-diff'

From
EWEric Wong <normalperson@yhbt.net>
Date
Jun 20, 2007, 06:25 UTC
Message-ID
<20070620062548.GA25840@muzzle>
In-Reply-To
<cff8d32813e43d9e1c75ad50824d95dbcd6f669c.1182235491.git.ynvich@gmail.com>
Sergey Yanovich <ynvich@gmail.com> wrote:
Show 8 quoted lines
> Experiments with Subversion (my version is 1.4.2) show that it is
> not necessary to call 'svn import' before the first commit. Contrarily
> to the Subversion documentation, first commit may be done even when
> Subversion repository is at revision 0.
> 
> This allow export the whole git branch to a Subversion repo using only
> 'git-svn commit-diff'. Before this patch, however, 'git-svn' had
> no means to operate on root commits.
Cool.
Show 15 quoted lines
> Signed-off-by: Sergey Yanovich <ynvich@gmail.com>
> ---
>  git-svn.perl |    9 ++++++++-
>  1 files changed, 8 insertions(+), 1 deletions(-)
> 
> diff --git a/git-svn.perl b/git-svn.perl
> index 50128d7..8ad291b 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -2572,7 +2572,12 @@ sub generate_diff {
>  	}
>  	push @diff_tree, '--find-copies-harder' if $_find_copies_harder;
>  	push @diff_tree, "-l$_rename_limit" if defined $_rename_limit;
> -	push @diff_tree, $tree_a, $tree_b;
> +	if ($tree_a eq '0000000000000000000000000000000000000000') {

You can make this more legible by using '0' x40 instead of repeating 40 '0' characters. Also, it might be a good idea to support --root directly for git-svn so the user won't have to type 40 zeroes in the command-line :)

Show 14 quoted lines
> +		push @diff_tree, '--root';
> +	} else {
> +		push @diff_tree, $tree_a;
> +	}
> +	push @diff_tree, $tree_b;
>  	my ($diff_fh, $ctx) = command_output_pipe(@diff_tree);
>  	local $/ = "\0";
>  	my $state = 'meta';
> @@ -2606,6 +2611,8 @@ sub generate_diff {
>  			}
>  			$x->{file_b} = $_;
>  			$state = 'meta';
> +		} elsif ($state eq 'meta' && $_ eq $tree_b &&
> +			$tree_a eq '0000000000000000000000000000000000000000') {
Same here with '0' x40
Show 6 quoted lines
>  		} else {
>  			croak "Error parsing $_\n";
>  		}
> -- 
> 1.5.2.1
> 
-- 
Eric Wong
Previous: Johannes SixtNext: Sergey Yanovich
Message 8 of 11 in “git tool to keep a subversion mirror”
  1. Sergey YanovichJun 18, 2007
  2. 1/3 Accept root <tree-ish> in 'git-svn commit-diff'Sergey Yanovich, Jun 18, 2007
  3. 2/3 'git-svndump'Sergey Yanovich, Jun 18, 2007
  4. 3/3 Fix large-scale exports by 'git-svndump'Sergey Yanovich, Jun 18, 2007
  5. Johannes SixtJun 18, 2007
  6. Charlie ShepherdJun 18, 2007
  7. Johannes SixtJun 18, 2007
  8. Eric WongJun 20, 2007
  9. Sergey YanovichJun 20, 2007
  10. Eric WongJun 20, 2007
  11. Sergey YanovichJun 20, 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.