From 63de84ad60984105b1cd60fb888968b352539313 Mon Sep 17 00:00:00 2001 From: Adam Brewster Date: Mon, 3 Aug 2009 21:40:38 -0400 Subject: svn: Honor --prefix option in init without --stdlayout Most users who type git svn init file:///tmp/repo --prefix=my-svn/ would expect the root of the svn repository to be tracked by refs/remotes/my-svn/git-svn. Acked-by: Eric Wong --- git-svn.perl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index d075810724..fa8583963b 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -3317,7 +3317,8 @@ sub _new { $repo_id = $Git::SVN::default_repo_id; } unless (defined $ref_id && length $ref_id) { - $_[2] = $ref_id = $Git::SVN::default_ref_id; + $_prefix = '' unless defined($_prefix); + $_[2] = $ref_id = $_prefix . $Git::SVN::default_ref_id; } $_[1] = $repo_id; my $dir = "$ENV{GIT_DIR}/svn/$ref_id"; -- cgit v1.2.1 From a7d72544b112f093b6189a86d05b198b2be73828 Mon Sep 17 00:00:00 2001 From: Michael Haggerty Date: Fri, 7 Aug 2009 21:21:21 +0200 Subject: git-svn: ignore leading blank lines in svn:ignore Subversion ignores all blank lines in svn:ignore properties. The old git-svn code ignored blank lines everywhere except for the first line of the svn:ignore property. This patch makes the "git svn show-ignore" and "git svn create-ignore" commands ignore leading blank lines, too. Also include leading blank lines in the test suite. Signed-off-by: Michael Haggerty Acked-by: Eric Wong --- git-svn.perl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index fa8583963b..b0bfb74792 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -764,6 +764,7 @@ sub cmd_show_ignore { print STDOUT "\n# $path\n"; my $s = $props->{'svn:ignore'} or return; $s =~ s/[\r\n]+/\n/g; + $s =~ s/^\n+//; chomp $s; $s =~ s#^#$path#gm; print STDOUT "$s\n"; @@ -801,6 +802,7 @@ sub cmd_create_ignore { open(GITIGNORE, '>', $ignore) or fatal("Failed to open `$ignore' for writing: $!"); $s =~ s/[\r\n]+/\n/g; + $s =~ s/^\n+//; chomp $s; # Prefix all patterns so that the ignore doesn't apply # to sub-directories. -- cgit v1.2.1 From b186a261b1f7ec1fbda8c5f6d84595f3a7716d92 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 12 Aug 2009 16:01:59 -0700 Subject: svn: initial "master" points to trunk if possible Since "trunk" is a convention for the main development branch in the SVN world, try to make that the master branch upon initial checkout if it exists. This is probably less surprising based on user requests. t9135 was the only test which relied on the previous behavior and thus needed to be modified. Signed-off-by: Eric Wong --- git-svn.perl | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index b0bfb74792..fad29605db 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -1156,6 +1156,17 @@ sub post_fetch_checkout { my $gs = $Git::SVN::_head or return; return if verify_ref('refs/heads/master^0'); + # look for "trunk" ref if it exists + my $remote = Git::SVN::read_all_remotes()->{$gs->{repo_id}}; + my $fetch = $remote->{fetch}; + if ($fetch) { + foreach my $p (keys %$fetch) { + basename($fetch->{$p}) eq 'trunk' or next; + $gs = Git::SVN->new($fetch->{$p}, $gs->{repo_id}, $p); + last; + } + } + my $valid_head = verify_ref('HEAD^0'); command_noisy(qw(update-ref refs/heads/master), $gs->refname); return if ($valid_head || !verify_ref('HEAD^0')); -- cgit v1.2.1 From 6f5748e14cc5bb0a836b649fb8e2d6a5eb166f1d Mon Sep 17 00:00:00 2001 From: Adam Brewster Date: Tue, 11 Aug 2009 23:14:27 -0400 Subject: svn: allow branches outside of refs/remotes It may be convenient for some users to store svn remote tracking branches outside of the refs/remotes/ heirarchy. To accomplish this feat, this patch includes the entire path to the ref in $r->{'refname'} in &read_all_remotes and tries to change references to this entry so the new value makes sense. [ew: fixed backwards compatibility, long lines] Signed-off-by: Adam Brewster Signed-off-by: Eric Wong --- git-svn.perl | 83 +++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 35 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index fad29605db..a2934e8651 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -909,7 +909,7 @@ sub cmd_multi_init { } do_git_init_db(); if (defined $_trunk) { - my $trunk_ref = $_prefix . 'trunk'; + my $trunk_ref = 'refs/remotes/' . $_prefix . 'trunk'; # try both old-style and new-style lookups: my $gs_trunk = eval { Git::SVN->new($trunk_ref) }; unless ($gs_trunk) { @@ -1654,23 +1654,23 @@ sub resolve_local_globs { return unless defined $glob_spec; my $ref = $glob_spec->{ref}; my $path = $glob_spec->{path}; - foreach (command(qw#for-each-ref --format=%(refname) refs/remotes#)) { - next unless m#^refs/remotes/$ref->{regex}$#; + foreach (command(qw#for-each-ref --format=%(refname) refs/#)) { + next unless m#^$ref->{regex}$#; my $p = $1; my $pathname = desanitize_refname($path->full_path($p)); my $refname = desanitize_refname($ref->full_path($p)); if (my $existing = $fetch->{$pathname}) { if ($existing ne $refname) { die "Refspec conflict:\n", - "existing: refs/remotes/$existing\n", - " globbed: refs/remotes/$refname\n"; + "existing: $existing\n", + " globbed: $refname\n"; } - my $u = (::cmt_metadata("refs/remotes/$refname"))[0]; + my $u = (::cmt_metadata("$refname"))[0]; $u =~ s!^\Q$url\E(/|$)!! or die - "refs/remotes/$refname: '$url' not found in '$u'\n"; + "$refname: '$url' not found in '$u'\n"; if ($pathname ne $u) { warn "W: Refspec glob conflict ", - "(ref: refs/remotes/$refname):\n", + "(ref: $refname):\n", "expected path: $pathname\n", " real path: $u\n", "Continuing ahead with $u\n"; @@ -1748,33 +1748,35 @@ sub read_all_remotes { my $use_svm_props = eval { command_oneline(qw/config --bool svn.useSvmProps/) }; $use_svm_props = $use_svm_props eq 'true' if $use_svm_props; + my $svn_refspec = qr{\s*/?(.*?)\s*:\s*(.+?)\s*}; foreach (grep { s/^svn-remote\.// } command(qw/config -l/)) { - if (m!^(.+)\.fetch=\s*(.*)\s*:\s*(.+)\s*$!) { - my ($remote, $local_ref, $_remote_ref) = ($1, $2, $3); - die("svn-remote.$remote: remote ref '$_remote_ref' " - . "must start with 'refs/remotes/'\n") - unless $_remote_ref =~ m{^refs/remotes/(.+)}; - my $remote_ref = $1; - $local_ref =~ s{^/}{}; + if (m!^(.+)\.fetch=$svn_refspec$!) { + my ($remote, $local_ref, $remote_ref) = ($1, $2, $3); + die("svn-remote.$remote: remote ref '$remote_ref' " + . "must start with 'refs/'\n") + unless $remote_ref =~ m{^refs/}; $r->{$remote}->{fetch}->{$local_ref} = $remote_ref; $r->{$remote}->{svm} = {} if $use_svm_props; } elsif (m!^(.+)\.usesvmprops=\s*(.*)\s*$!) { $r->{$1}->{svm} = {}; } elsif (m!^(.+)\.url=\s*(.*)\s*$!) { $r->{$1}->{url} = $2; - } elsif (m!^(.+)\.(branches|tags)= - (.*):refs/remotes/(.+)\s*$/!x) { - my ($p, $g) = ($3, $4); + } elsif (m!^(.+)\.(branches|tags)=$svn_refspec$!) { + my ($remote, $t, $local_ref, $remote_ref) = + ($1, $2, $3, $4); + die("svn-remote.$remote: remote ref '$remote_ref' ($t) " + . "must start with 'refs/'\n") + unless $remote_ref =~ m{^refs/}; my $rs = { - t => $2, - remote => $1, - path => Git::SVN::GlobSpec->new($p), - ref => Git::SVN::GlobSpec->new($g) }; + t => $t, + remote => $remote, + path => Git::SVN::GlobSpec->new($local_ref), + ref => Git::SVN::GlobSpec->new($remote_ref) }; if (length($rs->{ref}->{right}) != 0) { die "The '*' glob character must be the last ", - "character of '$g'\n"; + "character of '$remote_ref'\n"; } - push @{ $r->{$1}->{$2} }, $rs; + push @{ $r->{$remote}->{$t} }, $rs; } } @@ -1882,9 +1884,9 @@ sub init_remote_config { } } my ($xrepo_id, $xpath) = find_ref($self->refname); - if (defined $xpath) { + if (!$no_write && defined $xpath) { die "svn-remote.$xrepo_id.fetch already set to track ", - "$xpath:refs/remotes/", $self->refname, "\n"; + "$xpath:", $self->refname, "\n"; } unless ($no_write) { command_noisy('config', @@ -1959,7 +1961,7 @@ sub find_ref { my ($ref_id) = @_; foreach (command(qw/config -l/)) { next unless m!^svn-remote\.(.+)\.fetch= - \s*(.*)\s*:\s*refs/remotes/(.+)\s*$!x; + \s*/?(.*?)\s*:\s*(.+?)\s*$!x; my ($repo_id, $path, $ref) = ($1, $2, $3); if ($ref eq $ref_id) { $path = '' if ($path =~ m#^\./?#); @@ -1976,16 +1978,16 @@ sub new { if (!defined $repo_id) { die "Could not find a \"svn-remote.*.fetch\" key ", "in the repository configuration matching: ", - "refs/remotes/$ref_id\n"; + "$ref_id\n"; } } my $self = _new($class, $repo_id, $ref_id, $path); if (!defined $self->{path} || !length $self->{path}) { my $fetch = command_oneline('config', '--get', "svn-remote.$repo_id.fetch", - ":refs/remotes/$ref_id\$") or + ":$ref_id\$") or die "Failed to read \"svn-remote.$repo_id.fetch\" ", - "\":refs/remotes/$ref_id\$\" in config\n"; + "\":$ref_id\$\" in config\n"; ($self->{path}, undef) = split(/\s*:\s*/, $fetch); } $self->{url} = command_oneline('config', '--get', @@ -1996,7 +1998,7 @@ sub new { } sub refname { - my ($refname) = "refs/remotes/$_[0]->{ref_id}" ; + my ($refname) = $_[0]->{ref_id} ; # It cannot end with a slash /, we'll throw up on this because # SVN can't have directories with a slash in their name, either: @@ -3331,12 +3333,23 @@ sub _new { } unless (defined $ref_id && length $ref_id) { $_prefix = '' unless defined($_prefix); - $_[2] = $ref_id = $_prefix . $Git::SVN::default_ref_id; + $_[2] = $ref_id = + "refs/remotes/$_prefix$Git::SVN::default_ref_id"; } $_[1] = $repo_id; my $dir = "$ENV{GIT_DIR}/svn/$ref_id"; + + # Older repos imported by us used $GIT_DIR/svn/foo instead of + # $GIT_DIR/svn/refs/remotes/foo when tracking refs/remotes/foo + if ($ref_id =~ m{^refs/remotes/(.*)}) { + my $old_dir = "$ENV{GIT_DIR}/svn/$1"; + if (-d $old_dir && ! -d $dir) { + $dir = $old_dir; + } + } + $_[3] = $path = '' unless (defined $path); - mkpath(["$ENV{GIT_DIR}/svn"]); + mkpath([$dir]); bless { ref_id => $ref_id, dir => $dir, index => "$dir/index", path => $path, config => "$ENV{GIT_DIR}/svn/config", @@ -5509,7 +5522,7 @@ sub minimize_connections { my $pfx = "svn-remote.$x->{old_repo_id}"; my $old_fetch = quotemeta("$x->{old_path}:". - "refs/remotes/$x->{ref_id}"); + "$x->{ref_id}"); command_noisy(qw/config --unset/, "$pfx.fetch", '^'. $old_fetch . '$'); delete $r->{$x->{old_repo_id}}-> @@ -5578,7 +5591,7 @@ sub new { my ($class, $glob) = @_; my $re = $glob; $re =~ s!/+$!!g; # no need for trailing slashes - $re =~ m!^([^*]*)(\*(?:/\*)*)([^*]*)$!; + $re =~ m!^([^*]*)(\*(?:/\*)*)(.*)$!; my $temp = $re; my ($left, $right) = ($1, $3); $re = $2; -- cgit v1.2.1 From c83f4e686445c83edbe9c1d3055c0c43921e1ab8 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 12 Aug 2009 22:20:02 -0700 Subject: svn: (cleanup) use predefined constant for rev_map_fmt This makes life easier in case we ever need to change the internal format of the rev_maps. Signed-off-by: Eric Wong --- git-svn.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index a2934e8651..1da9f0781c 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -3277,7 +3277,7 @@ sub _rev_map_get { my $i = int(($l/24 + $u/24) / 2) * 24; sysseek($fh, $i, SEEK_SET) or croak "seek: $!"; sysread($fh, my $buf, 24) == 24 or croak "read: $!"; - my ($r, $c) = unpack('NH40', $buf); + my ($r, $c) = unpack(rev_map_fmt, $buf); if ($r < $rev) { $l = $i + 24; -- cgit v1.2.1 From 5268f9edc3c86b07a64fcc2679e5ffe39be28d97 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 16 Aug 2009 14:22:12 -0700 Subject: svn: assume URLs from the command-line are URI-encoded MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit And then unescape them when writing to $GIT_CONFIG. SVN has different rules for repository URLs (usually the root) and for paths within that repository (below the HTTP layer). Thus, for the request URI path at the HTTP level, the URI needs to be encoded. However, in the body of the HTTP request (the with underlying SVN XML protocol), those paths should not be URI-encoded[1]. For non-HTTP(S) requests, SVN appears to be more flexible and will except weird characters in the URL as well as URI-encoded ones. Since users are used to using URLs being entirely URI-encoded, git svn will now attempt to unescape the path portion of URLs while leaving the actual repository URL untouched. This change will be reflected in newly-created $GIT_CONFIG files only. This allows users to switch between svn(+ssh)://, file:// and http(s):// urls without changing the fetch/branches/tags config keys. This won't affect existing imports at all (since things didn't work before this commit anyways), and will allow users to force escaping into repository paths that look like they're escaped (but are not). Thanks to Mike Smullin for the original bug report and Björn Steinbrink for summarizing it into testable cases for me. [1] Except when committing copies/renames, see commit 29633bb91c7bcff31ff3bb59378709e3e3ef627d Signed-off-by: Eric Wong --- git-svn.perl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 1da9f0781c..5515e3ea54 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -1222,6 +1222,7 @@ sub complete_url_ls_init { } command_oneline('config', $k, $gs->{url}) unless $orig_url; my $remote_path = "$gs->{path}/$repo_path"; + $remote_path =~ s{%([0-9A-F]{2})}{chr hex($1)}ieg; $remote_path =~ s#/+#/#g; $remote_path =~ s#^/##g; $remote_path .= "/*" if $remote_path !~ /\*/; @@ -1892,6 +1893,7 @@ sub init_remote_config { command_noisy('config', "svn-remote.$self->{repo_id}.url", $url); $self->{path} =~ s{^/}{}; + $self->{path} =~ s{%([0-9A-F]{2})}{chr hex($1)}ieg; command_noisy('config', '--add', "svn-remote.$self->{repo_id}.fetch", "$self->{path}:".$self->refname); -- cgit v1.2.1 From f3a87d922a0333a56b5a912440aa324883019d81 Mon Sep 17 00:00:00 2001 From: Karthik R Date: Tue, 18 Aug 2009 18:54:40 -0500 Subject: git-svn: Use GIT_SSH setting if SVN_SSH is not set If SVN_SSH is defined, it will be used. Else value in GIT_SSH is copied to SVN_SSH & then, only on Windows, the \s are escaped. On Windows, the shell-variables must be set as follows GIT_SSH="C:\Program Files\PuTTY\plink.exe" SVN_SSH="C:\\Program Files\\PuTTY\\plink.exe" See http://code.google.com/p/msysgit/issues/detail?id=305 [ew: fixed indentation to use tabs] Acked-by: Eric Wong Signed-off-by: Karthik Rajagopalan --- git-svn.perl | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 5515e3ea54..ce4fef9d34 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -21,6 +21,15 @@ $Git::SVN::default_ref_id = $ENV{GIT_SVN_ID} || 'git-svn'; $Git::SVN::Ra::_log_window_size = 100; $Git::SVN::_minimize_url = 'unset'; +if (! exists $ENV{SVN_SSH}) { + if (exists $ENV{GIT_SSH}) { + $ENV{SVN_SSH} = $ENV{GIT_SSH}; + if ($^O eq 'msys') { + $ENV{SVN_SSH} =~ s/\\/\\\\/g; + } + } +} + $Git::SVN::Log::TZ = $ENV{TZ}; $ENV{TZ} = 'UTC'; $| = 1; # unbuffer STDOUT -- cgit v1.2.1 From d3d7d47e6e0c3077fa39ffcca2b7f5f48ea97812 Mon Sep 17 00:00:00 2001 From: Mark Lodato Date: Sat, 12 Sep 2009 20:33:23 -0400 Subject: svn: properly escape arguments for authors-prog Previously, the call to authors-prog was not properly escaped, so any special characters in the Subversion username, such as spaces and semi-colons, would be interpreted by the shell rather than being passed in as the first argument. Now all unsafe characters are escaped using "git rev-parse --sq-quote" [ew: switched from "\Q..\E" to "rev-parse --sq-quote"] Signed-off-by: Mark Lodato Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- git-svn.perl | 1 + 1 file changed, 1 insertion(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index d075810724..24bdbf5b81 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2810,6 +2810,7 @@ sub other_gs { sub call_authors_prog { my ($orig_author) = @_; + $orig_author = command_oneline('rev-parse', '--sq-quote', $orig_author); my $author = `$::_authors_prog $orig_author`; if ($? != 0) { die "$::_authors_prog failed with exit code $?\n" -- cgit v1.2.1 From c03c1f798d5f865331428e88c7d19b15471d25a8 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Fri, 9 Oct 2009 11:01:04 +0400 Subject: git-svn: Avoid spurious errors when rewriteRoot is used. After doing a rebase, git-svn checks that the SVN URL is what it expects. However, it does not account for rewriteRoot, which is a legitimate way for the URL to change. This produces a lot of spurious errors. [ew: fixed line wrapping] Signed-off-by: Alexander Gavrilov Acked-by: Eric Wong --- git-svn.perl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index e0ec258e33..ab65d688fe 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -603,8 +603,15 @@ sub cmd_dcommit { "\nBefore dcommitting"; } if ($url_ ne $expect_url) { - fatal "URL mismatch after rebase: ", - "$url_ != $expect_url"; + if ($url_ eq $gs->metadata_url) { + print + "Accepting rewritten URL:", + " $url_\n"; + } else { + fatal + "URL mismatch after rebase:", + " $url_ != $expect_url"; + } } if ($uuid_ ne $uuid) { fatal "uuid mismatch after rebase: ", -- cgit v1.2.1 From 85886162f1149bb1db48e6a4c8e1c4a4a726173f Mon Sep 17 00:00:00 2001 From: Simon Arlott Date: Fri, 9 Oct 2009 13:21:13 +0100 Subject: git-svn: hide find_parent_branch output in double quiet mode Hide find_parent_branch logging when -qq is specified. This eliminates more unnecessary output when run from cron, e.g.: Found possible branch point: http://undernet-ircu.svn.sourceforge.net/svnroot/undernet-ircu/ircu2/trunk => http://undernet-ircu.svn.sourceforge.net/svnroot/undernet-ircu/ircu2/branches/authz, 1919 Found branch parent: (authz) ea061d76aea985dc0208d36fa5e0b2249b698557 Following parent with do_switch Successfully followed parent Acked-by: Eric Wong Signed-off-by: Simon Arlott Signed-off-by: Junio C Hamano --- git-svn.perl | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index ab65d688fe..eb4b75aff3 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2633,7 +2633,8 @@ sub find_parent_branch { my $url = $self->ra->{url}; my $new_url = $url . $branch_from; print STDERR "Found possible branch point: ", - "$new_url => ", $self->full_url, ", $r\n"; + "$new_url => ", $self->full_url, ", $r\n" + unless $::_q > 1; $branch_from =~ s#^/##; my $gs = $self->other_gs($new_url, $url, $branch_from, $r, $self->{ref_id}); @@ -2654,11 +2655,13 @@ sub find_parent_branch { ($r0, $parent) = $gs->find_rev_before($r, 1); } if (defined $r0 && defined $parent) { - print STDERR "Found branch parent: ($self->{ref_id}) $parent\n"; + print STDERR "Found branch parent: ($self->{ref_id}) $parent\n" + unless $::_q > 1; my $ed; if ($self->ra->can_do_switch) { $self->assert_index_clean($parent); - print STDERR "Following parent with do_switch\n"; + print STDERR "Following parent with do_switch\n" + unless $::_q > 1; # do_switch works with svn/trunk >= r22312, but that # is not included with SVN 1.4.3 (the latest version # at the moment), so we can't rely on it @@ -2673,18 +2676,20 @@ sub find_parent_branch { print STDERR "Trees match:\n", " $new_url\@$r0\n", " ${\$self->full_url}\@$rev\n", - "Following parent with no changes\n"; + "Following parent with no changes\n" + unless $::_q > 1; $self->tmp_index_do(sub { command_noisy('read-tree', $parent); }); $self->{last_commit} = $parent; } else { - print STDERR "Following parent with do_update\n"; + print STDERR "Following parent with do_update\n" + unless $::_q > 1; $ed = SVN::Git::Fetcher->new($self); $self->ra->gs_do_update($rev, $rev, $self, $ed) or die "SVN connection failed somewhere...\n"; } - print STDERR "Successfully followed parent\n"; + print STDERR "Successfully followed parent\n" unless $::_q > 1; return $self->make_log_entry($rev, [$parent], $ed); } return undef; @@ -2829,7 +2834,7 @@ sub other_gs { $ref_id .= "\@$r"; # just grow a tail if we're not unique enough :x $ref_id .= '-' while find_ref($ref_id); - print STDERR "Initializing parent: $ref_id\n"; + print STDERR "Initializing parent: $ref_id\n" unless $::_q > 1; my ($u, $p, $repo_id) = ($new_url, '', $ref_id); if ($u =~ s#^\Q$url\E(/|$)##) { $p = $u; -- cgit v1.2.1 From ffd5c8e457f8139ee89006083d97d47e17a066b8 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 22 Oct 2009 23:39:04 -0700 Subject: git svn: fix fetch where glob is on the top-level URL In cases where the top-level URL we're tracking is the path we glob against, we can once again track odd repositories that keep branches/tags at the top level. This regression was introduced in commit 6f5748e14cc5bb0a836b649fb8e2d6a5eb166f1d. Thanks to Daniel Cordero for the original bug report and bisection. Signed-off-by: Eric Wong --- git-svn.perl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index eb4b75aff3..56af2216a9 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -1765,7 +1765,7 @@ sub read_all_remotes { my $use_svm_props = eval { command_oneline(qw/config --bool svn.useSvmProps/) }; $use_svm_props = $use_svm_props eq 'true' if $use_svm_props; - my $svn_refspec = qr{\s*/?(.*?)\s*:\s*(.+?)\s*}; + my $svn_refspec = qr{\s*(.*?)\s*:\s*(.+?)\s*}; foreach (grep { s/^svn-remote\.// } command(qw/config -l/)) { if (m!^(.+)\.fetch=$svn_refspec$!) { my ($remote, $local_ref, $remote_ref) = ($1, $2, $3); @@ -1979,7 +1979,7 @@ sub find_ref { my ($ref_id) = @_; foreach (command(qw/config -l/)) { next unless m!^svn-remote\.(.+)\.fetch= - \s*/?(.*?)\s*:\s*(.+?)\s*$!x; + \s*(.*?)\s*:\s*(.+?)\s*$!x; my ($repo_id, $path, $ref) = ($1, $2, $3); if ($ref eq $ref_id) { $path = '' if ($path =~ m#^\./?#); -- cgit v1.2.1 From f1264bd65451a68e87e0f99c9601cfa1b3244db6 Mon Sep 17 00:00:00 2001 From: Sam Vilain Date: Tue, 20 Oct 2009 15:42:01 +1300 Subject: git-svn: convert SVK merge tickets to extra parents SVK is a simple case to start with, as its idea of merge parents matches git's one. When a svk:merge ticket is encountered, check each of the listed merged revisions to see if they are in the history of this commit; if not, then we have encountered a merge - record it. [ew: minor formatting cleanups] Signed-off-by: Sam Vilain Acked-by: Eric Wong --- git-svn.perl | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 56af2216a9..1b918aef71 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2878,14 +2878,64 @@ sub check_author { $author; } +sub find_extra_svk_parents { + my ($self, $ed, $tickets, $parents) = @_; + # aha! svk:merge property changed... + my @tickets = split "\n", $tickets; + my @known_parents; + for my $ticket ( @tickets ) { + my ($uuid, $path, $rev) = split /:/, $ticket; + if ( $uuid eq $self->ra_uuid ) { + my $url = $self->rewrite_root || $self->{url}; + my $repos_root = $url; + my $branch_from = $path; + $branch_from =~ s{^/}{}; + my $gs = $self->other_gs($repos_root."/".$branch_from, + $url, + $branch_from, + $rev, + $self->{ref_id}); + if ( my $commit = $gs->rev_map_get($rev, $uuid) ) { + # wahey! we found it, but it might be + # an old one (!) + push @known_parents, $commit; + } + } + } + for my $parent ( @known_parents ) { + my @cmd = ('rev-list', $parent, map { "^$_" } @$parents ); + my ($msg_fh, $ctx) = command_output_pipe(@cmd); + my $new; + while ( <$msg_fh> ) { + $new=1;last; + } + command_close_pipe($msg_fh, $ctx); + if ( $new ) { + print STDERR + "Found merge parent (svk:merge ticket): $parent\n"; + push @$parents, $parent; + } + } +} + sub make_log_entry { my ($self, $rev, $parents, $ed) = @_; my $untracked = $self->get_untracked($ed); + my @parents = @$parents; + my $ps = $ed->{path_strip} || ""; + for my $path ( grep { m/$ps/ } %{$ed->{dir_prop}} ) { + my $props = $ed->{dir_prop}{$path}; + if ( $props->{"svk:merge"} ) { + $self->find_extra_svk_parents + ($ed, $props->{"svk:merge"}, \@parents); + } + } + open my $un, '>>', "$self->{dir}/unhandled.log" or croak $!; print $un "r$rev\n" or croak $!; print $un $_, "\n" foreach @$untracked; - my %log_entry = ( parents => $parents || [], revision => $rev, + my %log_entry = ( parents => \@parents, revision => $rev, log => ''); my $headrev; -- cgit v1.2.1 From dff589ef949e97cbec5363b105ba27f6e85594fb Mon Sep 17 00:00:00 2001 From: Sam Vilain Date: Tue, 20 Oct 2009 15:42:03 +1300 Subject: git-svn: convert SVN 1.5+ / svnmerge.py svn:mergeinfo props to parents This feature is long overdue; convert SVN's merge representation to git's as revisions are imported. This works by converting the list of revisions in each line of the svn:mergeinfo into git revision ranges, and then checking the latest of each of these revision ranges for A) being new and B) now being completely merged. Signed-off-by: Sam Vilain Acked-by: Eric Wong --- git-svn.perl | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 1b918aef71..6a3b501d24 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2918,6 +2918,93 @@ sub find_extra_svk_parents { } } +# note: this function should only be called if the various dirprops +# have actually changed +sub find_extra_svn_parents { + my ($self, $ed, $mergeinfo, $parents) = @_; + # aha! svk:merge property changed... + + # We first search for merged tips which are not in our + # history. Then, we figure out which git revisions are in + # that tip, but not this revision. If all of those revisions + # are now marked as merge, we can add the tip as a parent. + my @merges = split "\n", $mergeinfo; + my @merge_tips; + my @merged_commit_ranges; + my $url = $self->rewrite_root || $self->{url}; + for my $merge ( @merges ) { + my ($source, $revs) = split ":", $merge; + my $path = $source; + $path =~ s{^/}{}; + my $gs = Git::SVN->find_by_url($url.$source, $url, $path); + if ( !$gs ) { + warn "Couldn't find revmap for $url$source\n"; + next; + } + my @ranges = split ",", $revs; + my ($tip, $tip_commit); + # find the tip + for my $range ( @ranges ) { + my ($bottom, $top) = split "-", $range; + $top ||= $bottom; + my $bottom_commit = + $gs->rev_map_get($bottom, $self->ra_uuid) || + $gs->rev_map_get($bottom+1, $self->ra_uuid); + my $top_commit = + $gs->rev_map_get($top, $self->ra_uuid); + + unless ($top_commit and $bottom_commit) { + warn "W:unknown path/rev in svn:mergeinfo " + ."dirprop: $source:$range\n"; + next; + } + + push @merged_commit_ranges, + "$bottom_commit..$top_commit"; + + if ( !defined $tip or $top > $tip ) { + $tip = $top; + $tip_commit = $top_commit; + } + } + unless (!$tip_commit or + grep { $_ eq $tip_commit } @$parents ) { + push @merge_tips, $tip_commit; + } else { + push @merge_tips, undef; + } + } + for my $merge_tip ( @merge_tips ) { + my $spec = shift @merges; + next unless $merge_tip; + my @cmd = ('rev-list', "-1", $merge_tip, + "--not", @$parents ); + my ($msg_fh, $ctx) = command_output_pipe(@cmd); + my $new; + while ( <$msg_fh> ) { + $new=1;last; + } + command_close_pipe($msg_fh, $ctx); + if ( $new ) { + push @cmd, @merged_commit_ranges; + my ($msg_fh, $ctx) = command_output_pipe(@cmd); + my $unmerged; + while ( <$msg_fh> ) { + $unmerged=1;last; + } + command_close_pipe($msg_fh, $ctx); + if ( $unmerged ) { + warn "W:svn cherry-pick ignored ($spec)\n"; + } else { + warn + "Found merge parent (svn:mergeinfo prop): ", + $merge_tip, "\n"; + push @$parents, $merge_tip; + } + } + } +} + sub make_log_entry { my ($self, $rev, $parents, $ed) = @_; my $untracked = $self->get_untracked($ed); @@ -2930,6 +3017,12 @@ sub make_log_entry { $self->find_extra_svk_parents ($ed, $props->{"svk:merge"}, \@parents); } + if ( $props->{"svn:mergeinfo"} ) { + $self->find_extra_svn_parents + ($ed, + $props->{"svn:mergeinfo"}, + \@parents); + } } open my $un, '>>', "$self->{dir}/unhandled.log" or croak $!; -- cgit v1.2.1 From b4479f074760a788dd4e353b8c86a7d735afc53e Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Fri, 30 Oct 2009 20:42:34 -0500 Subject: add -i, send-email, svn, p4, etc: use "git var GIT_EDITOR" Use the new "git var GIT_EDITOR" feature to decide what editor to use, instead of duplicating its logic elsewhere. This should make the behavior of commands in edge cases (e.g., editor names with spaces) a little more consistent. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- git-svn.perl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 6a3b501d24..42c9a728ad 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -1321,9 +1321,8 @@ sub get_commit_entry { close $log_fh or croak $!; if ($_edit || ($type eq 'tree')) { - my $editor = $ENV{VISUAL} || $ENV{EDITOR} || 'vi'; - # TODO: strip out spaces, comments, like git-commit.sh - system($editor, $commit_editmsg); + chomp(my $editor = command_oneline(qw(var GIT_EDITOR))); + system('sh', '-c', $editor.' "$@"', $editor, $commit_editmsg); } rename $commit_editmsg, $commit_msg or croak $!; { -- cgit v1.2.1 From dec543e62dbc47be0c06805330a20f7fa9f699a3 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Fri, 30 Oct 2009 20:43:19 -0500 Subject: am -i, git-svn: use "git var GIT_PAGER" Use the new "git var GIT_PAGER" command to ask what pager to use. Without this change, the core.pager configuration is ignored by these commands. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- git-svn.perl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 42c9a728ad..c4ca5487f3 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -5171,10 +5171,8 @@ sub git_svn_log_cmd { # adapted from pager.c sub config_pager { - $pager ||= $ENV{GIT_PAGER} || $ENV{PAGER}; - if (!defined $pager) { - $pager = 'less'; - } elsif (length $pager == 0 || $pager eq 'cat') { + chomp(my $pager = command_oneline(qw(var GIT_PAGER))); + if ($pager eq 'cat') { $pager = undef; } $ENV{GIT_PAGER_IN_USE} = defined($pager); -- cgit v1.2.1 From 753dc384dc2c4ab3e1049f695425cebf41ff7e6b Mon Sep 17 00:00:00 2001 From: Toby Allsopp Date: Sat, 14 Nov 2009 13:26:47 -0800 Subject: git svn: handle SVN merges from revisions past the tip of the branch When recording the revisions that it has merged, SVN sets the top revision to be the latest revision in the repository, which is not necessarily a revision on the branch that is being merged from. When it is not on the branch, git-svn fails to add the extra parent to represent the merge because it relies on finding the commit on the branch that corresponds to the top of the SVN merge range. In order to correctly handle this case, we look for the maximum revision less than or equal to the top of the SVN merge range that is actually on the branch being merged from. [ew: This includes the following (squashed) commit to prevent errors during bisect:] Author: Toby Allsopp Date: Fri Nov 13 09:48:39 2009 +1300 git-svn: add (failing) test for SVN 1.5+ merge with intervening commit This test exposes a bug in git-svn's handling of SVN 1.5+ mergeinfo properties. The problematic case is when there is some commit on an unrelated branch after the last commit on the merged-from branch. When SVN records the mergeinfo property, it records the latest revision in the whole repository, which, in the problematic case, is not on the branch it is merging from. To trigger the git-svn bug, we modify t9151 to include two SVN merges, the second of which has an intervening commit. The SVN dump was generated using SVN 1.6.6 (on Debian squeeze amd64). Signed-off-by: Toby Allsopp Acked-by: Eric Wong --- git-svn.perl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 6a3b501d24..27fbe3063b 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2950,8 +2950,11 @@ sub find_extra_svn_parents { my $bottom_commit = $gs->rev_map_get($bottom, $self->ra_uuid) || $gs->rev_map_get($bottom+1, $self->ra_uuid); - my $top_commit = - $gs->rev_map_get($top, $self->ra_uuid); + my $top_commit; + for (; !$top_commit && $top >= $bottom; --$top) { + $top_commit = + $gs->rev_map_get($top, $self->ra_uuid); + } unless ($top_commit and $bottom_commit) { warn "W:unknown path/rev in svn:mergeinfo " -- cgit v1.2.1 From 1a30582b43e137e16b3486d83bb86b0eb090e13d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 14 Nov 2009 14:25:11 -0800 Subject: git svn: read global+system config for clone+init Since $GIT_DIR does not exist when initializing new repositories, we can follow back to the global and system config files for git. The logic for this was originally introduced when $GIT_DIR/config was the only config file git could read (back when "git config" was "git repo-config"), so the function is renamed to "read_git_config" instead of "read_repo_config". Signed-off-by: Eric Wong --- git-svn.perl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 27fbe3063b..ea922ace1d 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -274,7 +274,7 @@ unless ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) { my %opts = %{$cmd{$cmd}->[2]} if (defined $cmd); -read_repo_config(\%opts); +read_git_config(\%opts); if ($cmd && ($cmd eq 'log' || $cmd eq 'blame')) { Getopt::Long::Configure('pass_through'); } @@ -1390,8 +1390,7 @@ sub load_authors { } # convert GetOpt::Long specs for use by git-config -sub read_repo_config { - return unless -d $ENV{GIT_DIR}; +sub read_git_config { my $opts = shift; my @config_only; foreach my $o (keys %$opts) { -- cgit v1.2.1 From 6111b934991f3ea670ac2442806c976defc7b61c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 15 Nov 2009 18:57:16 -0800 Subject: git svn: attempt to create empty dirs on clone+rebase We parse unhandled.log files for empty_dir statements and make a best effort attempt to recreate empty directories on fresh clones and rebase. This should cover the majority of cases where users work off a single branch or for projects where branches do not differ in empty directories. Since this cannot affect "normal" git commands like "checkout" or "reset", so users switching between branches in a single working directory should use the new "git svn mkdirs" command after switching branches. Signed-off-by: Eric Wong --- git-svn.perl | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index ea922ace1d..ab0a8dd099 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -168,6 +168,9 @@ my %cmd = ( 'Create a .gitignore per svn:ignore', { 'revision|r=i' => \$_revision } ], + 'mkdirs' => [ \&cmd_mkdirs , + "recreate empty directories after a checkout", + { 'revision|r=i' => \$_revision } ], 'propget' => [ \&cmd_propget, 'Print the value of a property on a file or directory', { 'revision|r=i' => \$_revision } ], @@ -769,6 +772,7 @@ sub cmd_rebase { $_fetch_all ? $gs->fetch_all : $gs->fetch; } command_noisy(rebase_cmd(), $gs->refname); + $gs->mkemptydirs; } sub cmd_show_ignore { @@ -830,6 +834,12 @@ sub cmd_create_ignore { }); } +sub cmd_mkdirs { + my ($url, $rev, $uuid, $gs) = working_head_info('HEAD'); + $gs ||= Git::SVN->new; + $gs->mkemptydirs($_revision); +} + sub canonicalize_path { my ($path) = @_; my $dot_slash_added = 0; @@ -1196,6 +1206,7 @@ sub post_fetch_checkout { command_noisy(qw/read-tree -m -u -v HEAD HEAD/); print STDERR "Checked out HEAD:\n ", $gs->full_url, " r", $gs->last_rev, "\n"; + $gs->mkemptydirs($gs->last_rev); } sub complete_svn_url { @@ -2724,6 +2735,34 @@ sub do_fetch { $self->make_log_entry($rev, \@parents, $ed); } +sub mkemptydirs { + my ($self, $r) = @_; + my %empty_dirs = (); + + open my $fh, '<', "$self->{dir}/unhandled.log" or return; + binmode $fh or croak "binmode: $!"; + while (<$fh>) { + if (defined $r && /^r(\d+)$/) { + last if $1 > $r; + } elsif (/^ \+empty_dir: (.+)$/) { + $empty_dirs{$1} = 1; + } elsif (/^ \-empty_dir: (.+)$/) { + delete $empty_dirs{$1}; + } + } + close $fh; + foreach my $d (sort keys %empty_dirs) { + $d = uri_decode($d); + next if -d $d; + if (-e _) { + warn "$d exists but is not a directory\n"; + } else { + print "creating empty directory: $d\n"; + mkpath([$d]); + } + } +} + sub get_untracked { my ($self, $ed) = @_; my @out; @@ -3556,6 +3595,12 @@ sub uri_encode { $f } +sub uri_decode { + my ($f) = @_; + $f =~ s#%([0-9a-fA-F]{2})#chr(hex($1))#eg; + $f +} + sub remove_username { $_[0] =~ s{^([^:]*://)[^@]+@}{$1}; } -- cgit v1.2.1 From 4d0157d6995925ea55ff181ea94d058583333f90 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 22 Nov 2009 12:37:06 -0800 Subject: git svn: always reuse existing remotes on fetch The internal no_reuse_existing flag is set to allow initializing multiple remotes with the same URL, common with SVM users. Unfortunately, this flag caused misbehavior when used with the -R command-line flag for fetching. Signed-off-by: Eric Wong --- git-svn.perl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 2746895ae6..7f7a56fbea 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -428,6 +428,7 @@ sub cmd_fetch { if (@_ > 1) { die "Usage: $0 fetch [--all] [--parent] [svn-remote]\n"; } + $Git::SVN::no_reuse_existing = undef; if ($_fetch_parent) { my ($url, $rev, $uuid, $gs) = working_head_info('HEAD'); unless ($gs) { @@ -956,6 +957,7 @@ sub cmd_multi_init { } sub cmd_multi_fetch { + $Git::SVN::no_reuse_existing = undef; my $remotes = Git::SVN::read_all_remotes(); foreach my $repo_id (sort keys %$remotes) { if ($remotes->{$repo_id}->{url}) { -- cgit v1.2.1 From 9be30eed61993a6f2d04a1609723e64e7632a64e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 22 Nov 2009 18:11:32 -0800 Subject: git svn: strip leading path when making empty dirs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since unhandled.log stores paths relative to the repository root, we need to strip out leading path components if the directories we're tracking are not the repository root. Reported-by: Björn Steinbrink Signed-off-by: Eric Wong --- git-svn.perl | 3 +++ 1 file changed, 3 insertions(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 7f7a56fbea..957d44e630 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2752,8 +2752,11 @@ sub mkemptydirs { } } close $fh; + + my $strip = qr/\A\Q$self->{path}\E(?:\/|$)/; foreach my $d (sort keys %empty_dirs) { $d = uri_decode($d); + $d =~ s/$strip//; next if -d $d; if (-e _) { warn "$d exists but is not a directory\n"; -- cgit v1.2.1 From e9e4c8b7473f6ee21f452c66430a0763681243d7 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Sun, 29 Nov 2009 02:20:21 -0500 Subject: git-svn: sort svk merge tickets to account for minimal parents When merging branches based on svk:merge properties, a single merge can have updated or added multiple svk:merge lines. Attempt to include the minimal set of parents by sorting the merge properties in order of revision, highest to lowest. Signed-off-by: Alex Vandiver Acked-by: Sam Vilain Acked-by: Eric Wong --- git-svn.perl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 957d44e630..51f03adb9b 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2940,10 +2940,14 @@ sub find_extra_svk_parents { if ( my $commit = $gs->rev_map_get($rev, $uuid) ) { # wahey! we found it, but it might be # an old one (!) - push @known_parents, $commit; + push @known_parents, [ $rev, $commit ]; } } } + # Ordering matters; highest-numbered commit merge tickets + # first, as they may account for later merge ticket additions + # or changes. + @known_parents = map {$_->[1]} sort {$b->[0] <=> $a->[0]} @known_parents; for my $parent ( @known_parents ) { my @cmd = ('rev-list', $parent, map { "^$_" } @$parents ); my ($msg_fh, $ctx) = command_output_pipe(@cmd); -- cgit v1.2.1 From 33f2a3108eeacbd937021470aa6e67c01ceec960 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Mon, 7 Dec 2009 22:28:32 -0500 Subject: git svn: Don't create empty directories whose parents were deleted Commit 6111b93 "git svn: attempt to create empty dirs on clone+rebase" will create empty directories 'a/b' and 'a/c' if they were previously created in SVN, even if their parent directory 'a' was deleted. For example, unhandled.log may contain lines like this: r32 +empty_dir: packages/sipb-xen-remctl-auto/sipb-xen-remctl-auto/files/etc/remctl/sipb-xen-auto/acl +empty_dir: packages/sipb-xen-remctl-auto/sipb-xen-remctl-auto/files/etc/remctl/sipb-xen-auto/machine.d +empty_dir: packages/sipb-xen-remctl-auto/sipb-xen-remctl-auto/files/etc/remctl/sipb-xen-auto/moira-acl [...] r314 -empty_dir: packages/sipb-xen-remctl-auto [ew: rewrote to be line-wrapped at <= 80-columns] Reported-by: Evan Broder Signed-off-by: Greg Price Acked-by: Eric Wong --- git-svn.perl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 51f03adb9b..bdd1f966c3 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2748,7 +2748,8 @@ sub mkemptydirs { } elsif (/^ \+empty_dir: (.+)$/) { $empty_dirs{$1} = 1; } elsif (/^ \-empty_dir: (.+)$/) { - delete $empty_dirs{$1}; + my @d = grep {m[^\Q$1\E(/|$)]} (keys %empty_dirs); + delete @empty_dirs{@d}; } } close $fh; -- cgit v1.2.1 From f9ad77a739c0d012ee58b64eda2d7ec0d4e1df9d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 7 Dec 2009 20:49:38 -0800 Subject: git svn: log removals of empty directories This also adds a test case for: "git svn: Don't create empty directories whose parents were deleted" which was the reason we found this bug in the first place. Signed-off-by: Eric Wong --- git-svn.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index bdd1f966c3..5a52068b12 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -3891,11 +3891,11 @@ sub delete_entry { } print "\tD\t$gpath/\n" unless $::_q; command_close_pipe($ls, $ctx); - $self->{empty}->{$path} = 0 } else { $self->{gii}->remove($gpath); print "\tD\t$gpath\n" unless $::_q; } + $self->{empty}->{$path} = 0; undef; } -- cgit v1.2.1 From 2bc35dcbf7ed702e92b925f8e50afe3632dd211b Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Tue, 8 Dec 2009 15:54:10 -0500 Subject: git-svn: Set svn.authorsfile to an absolute path when cloning If --authors-file is passed a relative path, cloning will work, but future `git svn fetch`es will fail to locate the authors file correctly. Thus, use File::Spec->rel2abs to determine an absolute path for the authors file before setting it. Signed-off-by: Alex Vandiver Acked-by: Eric Wong --- git-svn.perl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 5a52068b12..dc0e711593 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -392,9 +392,11 @@ sub cmd_clone { $path = $url; } $path = basename($url) if !defined $path || !length $path; + my $authors_absolute = $_authors ? File::Spec->rel2abs($_authors) : ""; cmd_init($url, $path); Git::SVN::fetch_all($Git::SVN::default_repo_id); - command_oneline('config', 'svn.authorsfile', $_authors) if $_authors; + command_oneline('config', 'svn.authorsfile', $authors_absolute) + if $_authors; } sub cmd_init { -- cgit v1.2.1 From f58415096632946b723fa73216ec1d49b4c6bb55 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Tue, 8 Dec 2009 15:54:11 -0500 Subject: git-svn: set svn.authorsfile earlier when cloning If a clone errors out because of a missing author, or user interrupt, this allows `git svn fetch` to resume seamlessly, rather than forcing the user to re-provide the path to the authors file. [ew: shortened subject] Signed-off-by: Alex Vandiver Acked-by: Eric Wong --- git-svn.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index dc0e711593..a4b052c71e 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -394,9 +394,9 @@ sub cmd_clone { $path = basename($url) if !defined $path || !length $path; my $authors_absolute = $_authors ? File::Spec->rel2abs($_authors) : ""; cmd_init($url, $path); - Git::SVN::fetch_all($Git::SVN::default_repo_id); command_oneline('config', 'svn.authorsfile', $authors_absolute) if $_authors; + Git::SVN::fetch_all($Git::SVN::default_repo_id); } sub cmd_init { -- cgit v1.2.1 From a5b80d92632a2d76325d4b6e6161022171a9fee4 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 19 Dec 2009 13:49:00 -0800 Subject: git svn: make empty directory creation gc-aware The "git svn gc" command creates and appends to unhandled.log.gz files which should be parsed before the uncompressed unhandled.log files. Reported-by: Robert Zeh Signed-off-by: Eric Wong --- git-svn.perl | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index a4b052c71e..d362de7364 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2740,21 +2740,44 @@ sub do_fetch { sub mkemptydirs { my ($self, $r) = @_; + + sub scan { + my ($r, $empty_dirs, $line) = @_; + if (defined $r && $line =~ /^r(\d+)$/) { + return 0 if $1 > $r; + } elsif ($line =~ /^ \+empty_dir: (.+)$/) { + $empty_dirs->{$1} = 1; + } elsif ($line =~ /^ \-empty_dir: (.+)$/) { + my @d = grep {m[^\Q$1\E(/|$)]} (keys %$empty_dirs); + delete @$empty_dirs{@d}; + } + 1; # continue + }; + my %empty_dirs = (); + my $gz_file = "$self->{dir}/unhandled.log.gz"; + if (-f $gz_file) { + if (!$can_compress) { + warn "Compress::Zlib could not be found; ", + "empty directories in $gz_file will not be read\n"; + } else { + my $gz = Compress::Zlib::gzopen($gz_file, "rb") or + die "Unable to open $gz_file: $!\n"; + my $line; + while ($gz->gzreadline($line) > 0) { + scan($r, \%empty_dirs, $line) or last; + } + $gz->gzclose; + } + } - open my $fh, '<', "$self->{dir}/unhandled.log" or return; - binmode $fh or croak "binmode: $!"; - while (<$fh>) { - if (defined $r && /^r(\d+)$/) { - last if $1 > $r; - } elsif (/^ \+empty_dir: (.+)$/) { - $empty_dirs{$1} = 1; - } elsif (/^ \-empty_dir: (.+)$/) { - my @d = grep {m[^\Q$1\E(/|$)]} (keys %empty_dirs); - delete @empty_dirs{@d}; + if (open my $fh, '<', "$self->{dir}/unhandled.log") { + binmode $fh or croak "binmode: $!"; + while (<$fh>) { + scan($r, \%empty_dirs, $_) or last; } + close $fh; } - close $fh; my $strip = qr/\A\Q$self->{path}\E(?:\/|$)/; foreach my $d (sort keys %empty_dirs) { -- cgit v1.2.1 From 577e9fcad2c8968846b365226b89778050496a78 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 21 Dec 2009 02:06:04 -0800 Subject: git svn: fix --revision when fetching deleted paths When using the -r/--revision argument to fetch deleted history, calling SVN::Ra::get_log() from an SVN::Ra object initialized to track the deleted URL will fail. This regression was introduced in: commit 4aacaeb3dc82bb6479e70e120053dc27a399460e "fix shallow clone when upstream revision is too new" We now ignore errors from SVN::Ra::get_log() here because using --revision will always override the value of $head here if (and only if) we're tracking deleted directories. Signed-off-by: Eric Wong --- git-svn.perl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index d362de7364..a6f5061c3c 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -1741,7 +1741,11 @@ sub fetch_all { my $ra = Git::SVN::Ra->new($url); my $uuid = $ra->get_uuid; my $head = $ra->get_latest_revnum; - $ra->get_log("", $head, 0, 1, 0, 1, sub { $head = $_[1] }); + + # ignore errors, $head revision may not even exist anymore + eval { $ra->get_log("", $head, 0, 1, 0, 1, sub { $head = $_[1] }) }; + warn "W: $@\n" if $@; + my $base = defined $fetch ? $head : 0; # read the max revs for wildcard expansion (branches/*, tags/*) -- cgit v1.2.1 From 7d944c3399c4145293d599e1ddc76d1ac0c1e118 Mon Sep 17 00:00:00 2001 From: Sam Vilain Date: Sun, 20 Dec 2009 00:55:13 +1300 Subject: git-svn: memoize conversion of SVN merge ticket info to git commit ranges Each time the svn mergeinfo ticket changes, we look it up in the rev_map; when there are a lot of merged branches, this will result in many repeated lookups of the same information for subsequent commits. Arrange the slow part of the function so that it may be memoized, and memoize it. The more expensive revision walking operation can be memoized separately. [ew: changed "next" to "return" for function exit] Signed-off-by: Sam Vilain Acked-by: Eric Wong --- git-svn.perl | 91 ++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 54 insertions(+), 37 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index a6f5061c3c..1e106f064b 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -1634,6 +1634,7 @@ use Carp qw/croak/; use File::Path qw/mkpath/; use File::Copy qw/copy/; use IPC::Open3; +use Memoize; # core since 5.8.0, Jul 2002 my ($_gc_nr, $_gc_period); @@ -2994,6 +2995,55 @@ sub find_extra_svk_parents { } } +sub lookup_svn_merge { + my $uuid = shift; + my $url = shift; + my $merge = shift; + + my ($source, $revs) = split ":", $merge; + my $path = $source; + $path =~ s{^/}{}; + my $gs = Git::SVN->find_by_url($url.$source, $url, $path); + if ( !$gs ) { + warn "Couldn't find revmap for $url$source\n"; + return; + } + my @ranges = split ",", $revs; + my ($tip, $tip_commit); + my @merged_commit_ranges; + # find the tip + for my $range ( @ranges ) { + my ($bottom, $top) = split "-", $range; + $top ||= $bottom; + my $bottom_commit = + $gs->rev_map_get($bottom, $uuid) || + $gs->rev_map_get($bottom+1, $uuid); + my $top_commit; + for (; !$top_commit && $top >= $bottom; --$top) { + $top_commit = + $gs->rev_map_get($top, $uuid); + } + + unless ($top_commit and $bottom_commit) { + warn "W:unknown path/rev in svn:mergeinfo " + ."dirprop: $source:$range\n"; + next; + } + + push @merged_commit_ranges, + "$bottom_commit..$top_commit"; + + if ( !defined $tip or $top > $tip ) { + $tip = $top; + $tip_commit = $top_commit; + } + } + return ($tip_commit, @merged_commit_ranges); +} +BEGIN { + memoize 'lookup_svn_merge'; +} + # note: this function should only be called if the various dirprops # have actually changed sub find_extra_svn_parents { @@ -3008,44 +3058,11 @@ sub find_extra_svn_parents { my @merge_tips; my @merged_commit_ranges; my $url = $self->rewrite_root || $self->{url}; + my $uuid = $self->ra_uuid; for my $merge ( @merges ) { - my ($source, $revs) = split ":", $merge; - my $path = $source; - $path =~ s{^/}{}; - my $gs = Git::SVN->find_by_url($url.$source, $url, $path); - if ( !$gs ) { - warn "Couldn't find revmap for $url$source\n"; - next; - } - my @ranges = split ",", $revs; - my ($tip, $tip_commit); - # find the tip - for my $range ( @ranges ) { - my ($bottom, $top) = split "-", $range; - $top ||= $bottom; - my $bottom_commit = - $gs->rev_map_get($bottom, $self->ra_uuid) || - $gs->rev_map_get($bottom+1, $self->ra_uuid); - my $top_commit; - for (; !$top_commit && $top >= $bottom; --$top) { - $top_commit = - $gs->rev_map_get($top, $self->ra_uuid); - } - - unless ($top_commit and $bottom_commit) { - warn "W:unknown path/rev in svn:mergeinfo " - ."dirprop: $source:$range\n"; - next; - } - - push @merged_commit_ranges, - "$bottom_commit..$top_commit"; - - if ( !defined $tip or $top > $tip ) { - $tip = $top; - $tip_commit = $top_commit; - } - } + my ($tip_commit, @ranges) = + lookup_svn_merge( $uuid, $url, $merge ); + push @merged_commit_ranges, @ranges; unless (!$tip_commit or grep { $_ eq $tip_commit } @$parents ) { push @merge_tips, $tip_commit; -- cgit v1.2.1 From 33973a5b179278c563624fcb45c223f03031b242 Mon Sep 17 00:00:00 2001 From: Sam Vilain Date: Sun, 20 Dec 2009 05:22:42 +1300 Subject: git-svn: fix some mistakes with interpreting SVN mergeinfo commit ranges SVN's list of commit ranges in mergeinfo tickets is inclusive, whereas git commit ranges are exclusive on the left hand side. Also, the end points of the commit ranges may not exist; they simply delineate ranges of commits which may or may not exist. Fix these two mistakes. Signed-off-by: Sam Vilain Acked-by: Eric Wong --- git-svn.perl | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 1e106f064b..a4a45ef398 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -3015,14 +3015,8 @@ sub lookup_svn_merge { for my $range ( @ranges ) { my ($bottom, $top) = split "-", $range; $top ||= $bottom; - my $bottom_commit = - $gs->rev_map_get($bottom, $uuid) || - $gs->rev_map_get($bottom+1, $uuid); - my $top_commit; - for (; !$top_commit && $top >= $bottom; --$top) { - $top_commit = - $gs->rev_map_get($top, $uuid); - } + my $bottom_commit = $gs->find_rev_after( $bottom, 1, $top ); + my $top_commit = $gs->find_rev_before( $top, 1, $bottom ); unless ($top_commit and $bottom_commit) { warn "W:unknown path/rev in svn:mergeinfo " @@ -3031,7 +3025,7 @@ sub lookup_svn_merge { } push @merged_commit_ranges, - "$bottom_commit..$top_commit"; + "$bottom_commit^..$top_commit"; if ( !defined $tip or $top > $tip ) { $tip = $top; -- cgit v1.2.1 From ea020cbd6aeb769d95e5c2dbffee4c81d6f92796 Mon Sep 17 00:00:00 2001 From: Sam Vilain Date: Sun, 20 Dec 2009 05:25:31 +1300 Subject: git-svn: exclude already merged tips using one rev-list call The old function would have to check all mentioned merge tips, every time that the mergeinfo ticket changed. This involved 1-2 rev-list operation for each listed mergeinfo line. If there are a lot of feature branches being merged into a trunk, this makes for a very expensive operation for detecting the new parents on every merge. This new version first uses a single 'rev-list' to figure out which commit ranges are already reachable from the parents. This is used to eliminate the already merged branches from the list. Signed-off-by: Sam Vilain Acked-by: Eric Wong --- git-svn.perl | 52 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 4 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index a4a45ef398..07d40ba81f 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -3038,6 +3038,41 @@ BEGIN { memoize 'lookup_svn_merge'; } +sub parents_exclude { + my $parents = shift; + my @commits = @_; + return unless @commits; + + my @excluded; + my $excluded; + do { + my @cmd = ('rev-list', "-1", @commits, "--not", @$parents ); + $excluded = command_oneline(@cmd); + if ( $excluded ) { + my @new; + my $found; + for my $commit ( @commits ) { + if ( $commit eq $excluded ) { + push @excluded, $commit; + $found++; + last; + } + else { + push @new, $commit; + } + } + die "saw commit '$excluded' in rev-list output, " + ."but we didn't ask for that commit (wanted: @commits --not @$parents)" + unless $found; + @commits = @new; + } + } + while ($excluded and @commits); + + return @excluded; +} + + # note: this function should only be called if the various dirprops # have actually changed sub find_extra_svn_parents { @@ -3050,23 +3085,32 @@ sub find_extra_svn_parents { # are now marked as merge, we can add the tip as a parent. my @merges = split "\n", $mergeinfo; my @merge_tips; - my @merged_commit_ranges; my $url = $self->rewrite_root || $self->{url}; my $uuid = $self->ra_uuid; + my %ranges; for my $merge ( @merges ) { my ($tip_commit, @ranges) = lookup_svn_merge( $uuid, $url, $merge ); - push @merged_commit_ranges, @ranges; unless (!$tip_commit or grep { $_ eq $tip_commit } @$parents ) { push @merge_tips, $tip_commit; + $ranges{$tip_commit} = \@ranges; } else { push @merge_tips, undef; } } + + my %excluded = map { $_ => 1 } + parents_exclude($parents, grep { defined } @merge_tips); + + # check merge tips for new parents + my @new_parents; for my $merge_tip ( @merge_tips ) { my $spec = shift @merges; - next unless $merge_tip; + next unless $merge_tip and $excluded{$merge_tip}; + + my $ranges = $ranges{$merge_tip}; + my @cmd = ('rev-list', "-1", $merge_tip, "--not", @$parents ); my ($msg_fh, $ctx) = command_output_pipe(@cmd); @@ -3076,7 +3120,7 @@ sub find_extra_svn_parents { } command_close_pipe($msg_fh, $ctx); if ( $new ) { - push @cmd, @merged_commit_ranges; + push @cmd, @$ranges; my ($msg_fh, $ctx) = command_output_pipe(@cmd); my $unmerged; while ( <$msg_fh> ) { -- cgit v1.2.1 From 7a955a5365d9ebd5e12c12ed926b2b51b61c02ee Mon Sep 17 00:00:00 2001 From: Sam Vilain Date: Sun, 20 Dec 2009 05:26:26 +1300 Subject: git-svn: detect cherry-picks correctly. The old function was incorrect; in some instances it marks a cherry picked range as a merged branch (because of an incorrect assumption that 'rev-list COMMIT --not RANGE' would work). This is replaced with a function which should detect them correctly, memoized to limit the expense of dealing with branches with many cherry picks to one 'merge-base' call per merge, per branch which used cherry picking. Signed-off-by: Sam Vilain Acked-by: Eric Wong --- git-svn.perl | 87 ++++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 64 insertions(+), 23 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 07d40ba81f..4ea3ac63da 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -3034,8 +3034,35 @@ sub lookup_svn_merge { } return ($tip_commit, @merged_commit_ranges); } + +sub _rev_list { + my ($msg_fh, $ctx) = command_output_pipe( + "rev-list", @_, + ); + my @rv; + while ( <$msg_fh> ) { + chomp; + push @rv, $_; + } + command_close_pipe($msg_fh, $ctx); + @rv; +} + +sub check_cherry_pick { + my $base = shift; + my $tip = shift; + my @ranges = @_; + my %commits = map { $_ => 1 } + _rev_list("--no-merges", $tip, "--not", $base); + for my $range ( @ranges ) { + delete @commits{_rev_list($range)}; + } + return (keys %commits); +} + BEGIN { memoize 'lookup_svn_merge'; + memoize 'check_cherry_pick'; } sub parents_exclude { @@ -3111,32 +3138,46 @@ sub find_extra_svn_parents { my $ranges = $ranges{$merge_tip}; - my @cmd = ('rev-list', "-1", $merge_tip, - "--not", @$parents ); - my ($msg_fh, $ctx) = command_output_pipe(@cmd); - my $new; - while ( <$msg_fh> ) { - $new=1;last; - } - command_close_pipe($msg_fh, $ctx); - if ( $new ) { - push @cmd, @$ranges; - my ($msg_fh, $ctx) = command_output_pipe(@cmd); - my $unmerged; - while ( <$msg_fh> ) { - $unmerged=1;last; - } - command_close_pipe($msg_fh, $ctx); - if ( $unmerged ) { - warn "W:svn cherry-pick ignored ($spec)\n"; - } else { - warn - "Found merge parent (svn:mergeinfo prop): ", - $merge_tip, "\n"; - push @$parents, $merge_tip; + # check out 'new' tips + my $merge_base = command_oneline( + "merge-base", + @$parents, $merge_tip, + ); + + # double check that there are no missing non-merge commits + my (@incomplete) = check_cherry_pick( + $merge_base, $merge_tip, + @$ranges, + ); + + if ( @incomplete ) { + warn "W:svn cherry-pick ignored ($spec) - missing " + .@incomplete." commit(s) (eg $incomplete[0])\n"; + } else { + warn + "Found merge parent (svn:mergeinfo prop): ", + $merge_tip, "\n"; + push @new_parents, $merge_tip; + } + } + + # cater for merges which merge commits from multiple branches + if ( @new_parents > 1 ) { + for ( my $i = 0; $i <= $#new_parents; $i++ ) { + for ( my $j = 0; $j <= $#new_parents; $j++ ) { + next if $i == $j; + next unless $new_parents[$i]; + next unless $new_parents[$j]; + my $revs = command_oneline( + "rev-list", "-1", "$i..$j", + ); + if ( !$revs ) { + undef($new_parents[$i]); + } } } } + push @$parents, grep { defined } @new_parents; } sub make_log_entry { -- cgit v1.2.1 From 063681d72e60e80cd14576037728b395ed42e330 Mon Sep 17 00:00:00 2001 From: Andrew Myrick Date: Mon, 21 Dec 2009 14:22:54 -0800 Subject: git-svn: Remove obsolete MAXPARENT check Change git-svn not to impose a limit of 16 parents on a merge. This limit in git-svn artificially prevents cloning svn repositories that contain commits with more than 16 merge parents. The limit was removed from builtin-commit-tree.c for git v1.6.0 in commit ef98c5cafb3e799b1568bb843fcd45920dc62f16, so there is no need to check for it it in git-svn. Signed-off-by: Andrew Myrick Acked-by: Eric Wong --- git-svn.perl | 6 ------ 1 file changed, 6 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 4ea3ac63da..36709607f2 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2451,12 +2451,6 @@ sub get_commit_parents { next if $seen{$p}; $seen{$p} = 1; push @ret, $p; - # MAXPARENT is defined to 16 in commit-tree.c: - last if @ret >= 16; - } - if (@tmp) { - die "r$log_entry->{revision}: No room for parents:\n\t", - join("\n\t", @tmp), "\n"; } @ret; } -- cgit v1.2.1 From 0fe19753f26e2747f48d1ec6a1761006d75c2d71 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 22 Dec 2009 12:15:40 -0800 Subject: git svn: lookup new parents correctly from svn:mergeinfo This appears to be a trivial case where array indices were being passed to git rev-list, instead of the contents stored in the array itself. Signed-off-by: Eric Wong --- git-svn.perl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 36709607f2..dba0d12b00 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -3163,7 +3163,8 @@ sub find_extra_svn_parents { next unless $new_parents[$i]; next unless $new_parents[$j]; my $revs = command_oneline( - "rev-list", "-1", "$i..$j", + "rev-list", "-1", + "$new_parents[$i]..$new_parents[$j]", ); if ( !$revs ) { undef($new_parents[$i]); -- cgit v1.2.1 From 150d38c4f3733b38c2c212469afa162a55e0e99d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 22 Dec 2009 22:40:18 -0800 Subject: git svn: branch/tag commands detect username in URLs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit svn+ssh:// repositories often have userinfo embedded in the URL which were stripped out of the "git-svn-id:" trailers. Since the SVN::Client::copy function takes userinfo into account when matching URLs for SVN repositories, we need to retrieve the full URL with embedded userinfo in it to avoid mismatched URLs. Tested-by: Florian Köberle Signed-off-by: Eric Wong --- git-svn.perl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index dba0d12b00..650c9e5f02 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -663,7 +663,8 @@ sub cmd_branch { } $head ||= 'HEAD'; - my ($src, $rev, undef, $gs) = working_head_info($head); + my (undef, $rev, undef, $gs) = working_head_info($head); + my $src = $gs->full_url; my $remote = Git::SVN::read_all_remotes()->{$gs->{repo_id}}; my $allglobs = $remote->{ $_tag ? 'tags' : 'branches' }; -- cgit v1.2.1 From 1cef6500a9edc7997bd0aa4cd1f739f5106ab0a9 Mon Sep 17 00:00:00 2001 From: Andrew Myrick Date: Wed, 6 Jan 2010 16:25:21 -0800 Subject: git-svn: ignore changeless commits when checking for a cherry-pick Update git-svn to ignore commits that do not change the tree when it is deciding if an svn merge ticket represents a real branch merge or just a cherry-pick. Consider the following integration model in the svn repository: F---G branch1 / \ D tag1 \ E tag2 / \ / A---B C trunk branch1 is merged to trunk in commit C. With this patch, git-svn will correctly identify branch1 as a proper merge parent, instead of incorrectly ignoring it as a cherry-pick. Signed-off-by: Andrew Myrick Acked-by: Sam Vilain Acked-by: Eric Wong --- git-svn.perl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 650c9e5f02..947184afcf 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -3052,12 +3052,36 @@ sub check_cherry_pick { for my $range ( @ranges ) { delete @commits{_rev_list($range)}; } + for my $commit (keys %commits) { + if (has_no_changes($commit)) { + delete $commits{$commit}; + } + } return (keys %commits); } +sub has_no_changes { + my $commit = shift; + + my @revs = split / /, command_oneline( + qw(rev-list --parents -1 -m), $commit); + + # Commits with no parents, e.g. the start of a partial branch, + # have changes by definition. + return 1 if (@revs < 2); + + # Commits with multiple parents, e.g a merge, have no changes + # by definition. + return 0 if (@revs > 2); + + return (command_oneline("rev-parse", "$commit^{tree}") eq + command_oneline("rev-parse", "$commit~1^{tree}")); +} + BEGIN { memoize 'lookup_svn_merge'; memoize 'check_cherry_pick'; + memoize 'has_no_changes'; } sub parents_exclude { -- cgit v1.2.1 From 41c01693ac13846c73a31c8f5c3a60206e1643be Mon Sep 17 00:00:00 2001 From: Andrew Myrick Date: Wed, 6 Jan 2010 16:25:22 -0800 Subject: git-svn: handle merge-base failures Change git-svn to warn and continue when merge-base fails while processing svn merge tickets. merge-base can fail when a partial branch is created and merged back to trunk in svn, because it cannot find a common ancestor between the partial branch and trunk. Signed-off-by: Andrew Myrick Acked-by: Sam Vilain Acked-by: Eric Wong --- git-svn.perl | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 947184afcf..e0773eff4e 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -3158,10 +3158,21 @@ sub find_extra_svn_parents { my $ranges = $ranges{$merge_tip}; # check out 'new' tips - my $merge_base = command_oneline( - "merge-base", - @$parents, $merge_tip, - ); + my $merge_base; + eval { + $merge_base = command_oneline( + "merge-base", + @$parents, $merge_tip, + ); + }; + if ($@) { + die "An error occurred during merge-base" + unless $@->isa("Git::Error::Command"); + + warn "W: Cannot find common ancestor between ". + "@$parents and $merge_tip. Ignoring merge info.\n"; + next; + } # double check that there are no missing non-merge commits my (@incomplete) = check_cherry_pick( -- cgit v1.2.1 From a83b91e7246fed3df5686c29a3c64eed8670fd98 Mon Sep 17 00:00:00 2001 From: Igor Mironov Date: Tue, 12 Jan 2010 03:20:43 +1100 Subject: git-svn: fix mismatched src/dst errors for branch/tag This fixes the following issue: $ git svn branch -t --username=svnuser \ --commit-url=https://myproj.domain.com/svn mytag Copying http://myproj.domain.com/svn/trunk at r26 to https://myproj.domain.com/svn/tags/mytag... Trying to use an unsupported feature: Source and dest appear not to be in the same repository (src: 'http://myproj.domain.com/svn/trunk'; dst: 'https://myproj.domain.com/svn/tags/mytag') [ew: shortened subject] Signed-off-by: Igor Mironov Acked-by: Eric Wong --- git-svn.perl | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index e0773eff4e..e05bf366cc 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -710,6 +710,10 @@ sub cmd_branch { my ($lft, $rgt) = @{ $glob->{path} }{qw/left right/}; my $dst = join '/', $remote->{url}, $lft, $branch_name, ($rgt || ()); + if ($dst =~ /^https:/ && $src =~ /^http:/) { + $src=~s/^http:/https:/; + } + my $ctx = SVN::Client->new( auth => Git::SVN::Ra::_auth_providers(), log_msg => sub { -- cgit v1.2.1 From 99bacd6c25d30766921468d09323b2c34cf62cb8 Mon Sep 17 00:00:00 2001 From: Igor Mironov Date: Tue, 12 Jan 2010 03:21:23 +1100 Subject: git-svn: respect commiturl option for branch/tag When constructing a destination URL, use the property 'commiturl' if it is specified in the configuration file; otherwise take 'url' as usual. This accommodates the scenario where a user only wants to involve the writable repository in operations performing a commit and defaults everything else to a read-only URL. [ew: shortened subject] Signed-off-by: Igor Mironov Acked-by: Eric Wong --- git-svn.perl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index e05bf366cc..2e14b22c89 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -708,7 +708,17 @@ sub cmd_branch { } } my ($lft, $rgt) = @{ $glob->{path} }{qw/left right/}; - my $dst = join '/', $remote->{url}, $lft, $branch_name, ($rgt || ()); + my $url; + if (defined $_commit_url) { + $url = $_commit_url; + } else { + $url = eval { command_oneline('config', '--get', + "svn-remote.$gs->{repo_id}.commiturl") }; + if (!$url) { + $url = $remote->{url}; + } + } + my $dst = join '/', $url, $lft, $branch_name, ($rgt || ()); if ($dst =~ /^https:/ && $src =~ /^http:/) { $src=~s/^http:/https:/; -- cgit v1.2.1 From 6594f0b793507a1e00f79c9884b8911c6d047c1c Mon Sep 17 00:00:00 2001 From: Igor Mironov Date: Tue, 12 Jan 2010 03:21:51 +1100 Subject: git-svn: add --username/commit-url options for branch/tag Add ability to specify on the command line the username to perform the operation as and the writable URL of the repository to perform it on. [ew: shortened subject] Signed-off-by: Igor Mironov Acked-by: Eric Wong --- git-svn.perl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 2e14b22c89..0fca1be224 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -155,12 +155,16 @@ my %cmd = ( { 'message|m=s' => \$_message, 'destination|d=s' => \$_branch_dest, 'dry-run|n' => \$_dry_run, - 'tag|t' => \$_tag } ], + 'tag|t' => \$_tag, + 'username=s' => \$Git::SVN::Prompt::_username, + 'commit-url=s' => \$_commit_url } ], tag => [ sub { $_tag = 1; cmd_branch(@_) }, 'Create a tag in the SVN repository', { 'message|m=s' => \$_message, 'destination|d=s' => \$_branch_dest, - 'dry-run|n' => \$_dry_run } ], + 'dry-run|n' => \$_dry_run, + 'username=s' => \$Git::SVN::Prompt::_username, + 'commit-url=s' => \$_commit_url } ], 'set-tree' => [ \&cmd_set_tree, "Set an SVN repository to a git tree-ish", { 'stdin' => \$_stdin, %cmt_opts, %fc_opts, } ], -- cgit v1.2.1 From 3e18ce1ac3034b1562ec748523aa7636e1b58b52 Mon Sep 17 00:00:00 2001 From: Jay Soffian Date: Sat, 23 Jan 2010 03:30:00 -0500 Subject: git-svn: allow UUID to be manually remapped via rewriteUUID In certain situations it may be necessary to manually remap an svn repostitory UUID. For example: o--- [git-svn clone] / [origin svn repo] \ o--- [svnsync clone] Imagine that only "git-svn clone" and "svnsync clone" are made available to external users. Furthur, "git-svn clone" contains only trunk, and for reasons unknown, "svnsync clone" is missing the revision properties that normally provide the origin svn repo's UUID. A git user who has cloned the "git-svn clone" repo now wishes to use git-svn to pull in the missing branches from the "synsync clone" repo. In order for git-svn to get the history correct for those branches, it needs to know the origin svn repo's UUID. Hence rewriteUUID. Signed-off-by: Jay Soffian Acked-by: Eric Wong --- git-svn.perl | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 0fca1be224..f7226714fa 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -115,6 +115,7 @@ my %init_opts = ( 'template=s' => \$_template, 'shared:s' => \$_shared, 'use-svm-props' => sub { $icv{useSvmProps} = 1 }, 'use-svnsync-props' => sub { $icv{useSvnsyncProps} = 1 }, 'rewrite-root=s' => sub { $icv{rewriteRoot} = $_[1] }, + 'rewrite-uuid=s' => sub { $icv{rewriteUUID} = $_[1] }, %remote_opts ); my %cmt_opts = ( 'edit|e' => \$_edit, 'rmdir' => \$SVN::Git::Editor::_rmdir, @@ -2207,6 +2208,10 @@ sub svnsync { die "Can't have both 'useSvnsyncProps' and 'rewriteRoot' ", "options set!\n"; } + if ($self->rewrite_uuid) { + die "Can't have both 'useSvnsyncProps' and 'rewriteUUID' ", + "options set!\n"; + } my $svnsync; # see if we have it in our config, first: @@ -2488,6 +2493,20 @@ sub rewrite_root { $self->{-rewrite_root} = $rwr; } +sub rewrite_uuid { + my ($self) = @_; + return $self->{-rewrite_uuid} if exists $self->{-rewrite_uuid}; + my $k = "svn-remote.$self->{repo_id}.rewriteUUID"; + my $rwid = eval { command_oneline(qw/config --get/, $k) }; + if ($rwid) { + $rwid =~ s#/+$##; + if ($rwid !~ m#^[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}$#) { + die "$rwid is not a valid UUID (key: $k)\n"; + } + } + $self->{-rewrite_uuid} = $rwid; +} + sub metadata_url { my ($self) = @_; ($self->rewrite_root || $self->{url}) . @@ -3306,6 +3325,10 @@ sub make_log_entry { die "Can't have both 'useSvmProps' and 'rewriteRoot' ", "options set!\n"; } + if ($self->rewrite_uuid) { + die "Can't have both 'useSvmProps' and 'rewriteUUID' ", + "options set!\n"; + } my ($uuid, $r) = $headrev =~ m{^([a-f\d\-]{30,}):(\d+)$}i; # we don't want "SVM: initializing mirror for junk" ... return undef if $r == 0; @@ -3336,10 +3359,10 @@ sub make_log_entry { } else { my $url = $self->metadata_url; remove_username($url); - $log_entry{metadata} = "$url\@$rev " . - $self->ra->get_uuid; - $email ||= "$author\@" . $self->ra->get_uuid; - $commit_email ||= "$author\@" . $self->ra->get_uuid; + my $uuid = $self->rewrite_uuid || $self->ra->get_uuid; + $log_entry{metadata} = "$url\@$rev " . $uuid; + $email ||= "$author\@" . $uuid; + $commit_email ||= "$author\@" . $uuid; } $log_entry{name} = $name; $log_entry{email} = $email; @@ -3421,7 +3444,7 @@ sub rebuild { '--'); my $metadata_url = $self->metadata_url; remove_username($metadata_url); - my $svn_uuid = $self->ra_uuid; + my $svn_uuid = $self->rewrite_uuid || $self->ra_uuid; my $c; while (<$log>) { if ( m{^commit ($::sha1)$} ) { -- cgit v1.2.1 From 075762085c6668f11c4ea165ecec17f69245ef09 Mon Sep 17 00:00:00 2001 From: Jay Soffian Date: Sat, 23 Jan 2010 03:30:01 -0500 Subject: git-svn: allow subset of branches/tags to be specified in glob spec For very large projects it is useful to be able to clone a subset of the upstream SVN repo's branches. Allow for this by letting the left-side of the branches and tags glob specs contain a brace-delineated comma-separated list of names. e.g.: branches = branches/{red,green}/src:refs/remotes/branches/* Signed-off-by: Jay Soffian Acked-by: Eric Wong --- git-svn.perl | 60 ++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 20 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index f7226714fa..b321c968af 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -1825,8 +1825,8 @@ sub read_all_remotes { my $rs = { t => $t, remote => $remote, - path => Git::SVN::GlobSpec->new($local_ref), - ref => Git::SVN::GlobSpec->new($remote_ref) }; + path => Git::SVN::GlobSpec->new($local_ref, 1), + ref => Git::SVN::GlobSpec->new($remote_ref, 0) }; if (length($rs->{ref}->{right}) != 0) { die "The '*' glob character must be the last ", "character of '$remote_ref'\n"; @@ -5233,6 +5233,7 @@ sub match_globs { next if (length $g->{path}->{right} && ($self->check_path($p, $r) != $SVN::Node::dir)); + next unless $p =~ /$g->{path}->{regex}/; $exists->{$p} = Git::SVN->init($self->{url}, $p, undef, $g->{ref}->full_path($de), 1); } @@ -6006,29 +6007,48 @@ use strict; use warnings; sub new { - my ($class, $glob) = @_; + my ($class, $glob, $pattern_ok) = @_; my $re = $glob; $re =~ s!/+$!!g; # no need for trailing slashes - $re =~ m!^([^*]*)(\*(?:/\*)*)(.*)$!; - my $temp = $re; - my ($left, $right) = ($1, $3); - $re = $2; - my $depth = $re =~ tr/*/*/; - if ($depth != $temp =~ tr/*/*/) { - die "Only one set of wildcard directories " . - "(e.g. '*' or '*/*/*') is supported: '$glob'\n"; + my (@left, @right, @patterns); + my $state = "left"; + my $die_msg = "Only one set of wildcard directories " . + "(e.g. '*' or '*/*/*') is supported: '$glob'\n"; + for my $part (split(m|/|, $glob)) { + if ($part =~ /\*/ && $part ne "*") { + die "Invalid pattern in '$glob': $part\n"; + } elsif ($pattern_ok && $part =~ /[{}]/ && + $part !~ /^\{[^{}]+\}/) { + die "Invalid pattern in '$glob': $part\n"; + } + if ($part eq "*") { + die $die_msg if $state eq "right"; + $state = "pattern"; + push(@patterns, "[^/]*"); + } elsif ($pattern_ok && $part =~ /^\{(.*)\}$/) { + die $die_msg if $state eq "right"; + $state = "pattern"; + my $p = quotemeta($1); + $p =~ s/\\,/|/g; + push(@patterns, "(?:$p)"); + } else { + if ($state eq "left") { + push(@left, $part); + } else { + push(@right, $part); + $state = "right"; + } + } } + my $depth = @patterns; if ($depth == 0) { - die "One '*' is needed for glob: '$glob'\n"; - } - $re =~ s!\*!\[^/\]*!g; - $re = quotemeta($left) . "($re)" . quotemeta($right); - if (length $left && !($left =~ s!/+$!!g)) { - die "Missing trailing '/' on left side of: '$glob' ($left)\n"; - } - if (length $right && !($right =~ s!^/+!!g)) { - die "Missing leading '/' on right side of: '$glob' ($right)\n"; + die "One '*' is needed in glob: '$glob'\n"; } + my $left = join('/', @left); + my $right = join('/', @right); + $re = join('/', @patterns); + $re = join('\/', + grep(length, quotemeta($left), "($re)", quotemeta($right))); my $left_re = qr/^\/\Q$left\E(\/|$)/; bless { left => $left, right => $right, left_regex => $left_re, regex => qr/$re/, glob => $glob, depth => $depth }, $class; -- cgit v1.2.1 From a004fb923d74c1d5500d493506b1462eb04cf017 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Sat, 23 Jan 2010 15:20:28 +0100 Subject: If deriving SVN_SSH from GIT_SSH on msys, also add quotes In contrast to GIT_SSH, SVN_SSH requires quotes for paths that contain spaces. As GIT_SSH will not work if it contains quotes, it is safe to assume it never contains quotes. Also, adding quotes to SVN_SSH for paths that do not contain spaces does no harm. So we always add quotes when deriving SVN_SSH from GIT_SSH on msys. This fixes msysGit issue 385, see http://code.google.com/p/msysgit/issues/detail?id=385 Signed-off-by: Sebastian Schuberth Signed-off-by: Junio C Hamano --- git-svn.perl | 1 + 1 file changed, 1 insertion(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index b321c968af..4f7dc2b73b 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -26,6 +26,7 @@ if (! exists $ENV{SVN_SSH}) { $ENV{SVN_SSH} = $ENV{GIT_SSH}; if ($^O eq 'msys') { $ENV{SVN_SSH} =~ s/\\/\\\\/g; + $ENV{SVN_SSH} =~ s/(.*)/"$1"/; } } } -- cgit v1.2.1 From 8bff7c5383ed833bd1df9c8d85c00a27af3e5b02 Mon Sep 17 00:00:00 2001 From: Andrew Myrick Date: Sat, 30 Jan 2010 03:14:22 +0000 Subject: git-svn: persistent memoization Make memoization of the svn:mergeinfo processing functions persistent with Memoize::Storable so that the memoization tables don't need to be regenerated every time the user runs git-svn fetch. The Memoize::Storable hashes are stored in ENV{GIT_DIR}/svn/.caches. [ew: changed caches path to avoid conflicts with old repos] [ew: File::Path::{make_path => mkpath} for compatibility] [ew: line-wrapped at 80 chars] Acked-by: Eric Wong Signed-off-by: Andrew Myrick --- git-svn.perl | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 4f7dc2b73b..265852f459 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -1656,6 +1656,7 @@ use File::Path qw/mkpath/; use File::Copy qw/copy/; use IPC::Open3; use Memoize; # core since 5.8.0, Jul 2002 +use Memoize::Storable; my ($_gc_nr, $_gc_period); @@ -3116,10 +3117,39 @@ sub has_no_changes { command_oneline("rev-parse", "$commit~1^{tree}")); } -BEGIN { - memoize 'lookup_svn_merge'; - memoize 'check_cherry_pick'; - memoize 'has_no_changes'; +# The GIT_DIR environment variable is not always set until after the command +# line arguments are processed, so we can't memoize in a BEGIN block. +{ + my $memoized = 0; + + sub memoize_svn_mergeinfo_functions { + return if $memoized; + $memoized = 1; + + my $cache_path = "$ENV{GIT_DIR}/svn/.caches/"; + mkpath([$cache_path]) unless -d $cache_path; + + tie my %lookup_svn_merge_cache => 'Memoize::Storable', + "$cache_path/lookup_svn_merge.db", 'nstore'; + memoize 'lookup_svn_merge', + SCALAR_CACHE => 'FAULT', + LIST_CACHE => ['HASH' => \%lookup_svn_merge_cache], + ; + + tie my %check_cherry_pick_cache => 'Memoize::Storable', + "$cache_path/check_cherry_pick.db", 'nstore'; + memoize 'check_cherry_pick', + SCALAR_CACHE => 'FAULT', + LIST_CACHE => ['HASH' => \%check_cherry_pick_cache], + ; + + tie my %has_no_changes_cache => 'Memoize::Storable', + "$cache_path/has_no_changes.db", 'nstore'; + memoize 'has_no_changes', + SCALAR_CACHE => ['HASH' => \%has_no_changes_cache], + LIST_CACHE => 'FAULT', + ; + } } sub parents_exclude { @@ -3163,6 +3193,8 @@ sub find_extra_svn_parents { my ($self, $ed, $mergeinfo, $parents) = @_; # aha! svk:merge property changed... + memoize_svn_mergeinfo_functions(); + # We first search for merged tips which are not in our # history. Then, we figure out which git revisions are in # that tip, but not this revision. If all of those revisions -- cgit v1.2.1 From 190c1cda7eb6dc03be80f45d3d174c313d23da2c Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Sun, 14 Feb 2010 06:06:10 -0600 Subject: git svn: Fix launching of pager MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In commit dec543e (am -i, git-svn: use "git var GIT_PAGER"), I tried to teach git svn to defer to git var on what pager to use. In the process, I introduced two bugs: - The value set for $pager in config_pager has local scope, so run_pager never sees it; - git var cannot tell whether git svn’s output is going to a terminal, so the value chosen for $pager does not reflect that information. Fix them. Reported-by: Sebastian Celis Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- git-svn.perl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 265852f459..473a0b9d55 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -5459,7 +5459,12 @@ sub git_svn_log_cmd { # adapted from pager.c sub config_pager { - chomp(my $pager = command_oneline(qw(var GIT_PAGER))); + if (! -t *STDOUT) { + $ENV{GIT_PAGER_IN_USE} = 'false'; + $pager = undef; + return; + } + chomp($pager = command_oneline(qw(var GIT_PAGER))); if ($pager eq 'cat') { $pager = undef; } @@ -5467,7 +5472,7 @@ sub config_pager { } sub run_pager { - return unless -t *STDOUT && defined $pager; + return unless defined $pager; pipe my ($rfd, $wfd) or return; defined(my $pid = fork) or ::fatal "Can't fork: $!"; if (!$pid) { -- cgit v1.2.1 From 6a2009e7f34148a737d8832887dcd491905017be Mon Sep 17 00:00:00 2001 From: Tuomas Suutari Date: Mon, 22 Feb 2010 20:12:53 +0200 Subject: git-svn: Fix discarding of extra parents from svn:mergeinfo If parent J is an ancestor of parent I, then parent J should be discarded, not I. Note that J is an ancestor of I if and only if rev-list I..J is emtpy, which is what we are testing here. Signed-off-by: Tuomas Suutari Acked-by: Eric Wong --- git-svn.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 265852f459..ed96a03059 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -3273,7 +3273,7 @@ sub find_extra_svn_parents { "$new_parents[$i]..$new_parents[$j]", ); if ( !$revs ) { - undef($new_parents[$i]); + undef($new_parents[$j]); } } } -- cgit v1.2.1 From d32fad2b89c81ca29128722e0e2f5985426e5e7a Mon Sep 17 00:00:00 2001 From: josh robb Date: Wed, 24 Feb 2010 16:13:50 +1300 Subject: git svn: delay importing SVN::Base until it is needed Importing functions from a .dll into Git for Windows' perl is pretty slow, so let's avoid importing if it is not necessary. This seems particularly slow in virtualized enviroments. Before this change (on my machine): $ time perl /libexec/git-core/git-svn rebase Current branch master is up to date. real 2m56.750s user 0m3.129s sys 2m39.232s Afterwards: $ time perl /libexec/git-core/git-svn rebase Current branch master is up to date. real 0m33.407s user 0m1.409s sys 0m23.054s git svn rebase -n goes from 3m7.046s to 0m10.312s. Signed-off-by: Josh Robb Acked-by: Eric Wong --- git-svn.perl | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index ed96a03059..49dd649bc5 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -36,11 +36,13 @@ $ENV{TZ} = 'UTC'; $| = 1; # unbuffer STDOUT sub fatal (@) { print STDERR "@_\n"; exit 1 } -require SVN::Core; # use()-ing this causes segfaults for me... *shrug* -require SVN::Ra; -require SVN::Delta; -if ($SVN::Core::VERSION lt '1.1.0') { - fatal "Need SVN::Core 1.1.0 or better (got $SVN::Core::VERSION)"; +sub _req_svn { + require SVN::Core; # use()-ing this causes segfaults for me... *shrug* + require SVN::Ra; + require SVN::Delta; + if ($SVN::Core::VERSION lt '1.1.0') { + fatal "Need SVN::Core 1.1.0 or better (got $SVN::Core::VERSION)"; + } } my $can_compress = eval { require Compress::Zlib; 1}; push @Git::SVN::Ra::ISA, 'SVN::Ra'; @@ -730,6 +732,8 @@ sub cmd_branch { $src=~s/^http:/https:/; } + ::_req_svn(); + my $ctx = SVN::Client->new( auth => Git::SVN::Ra::_auth_providers(), log_msg => sub { @@ -4859,6 +4863,8 @@ sub new { $url =~ s!/+$!!; return $RA if ($RA && $RA->{url} eq $url); + ::_req_svn(); + SVN::_Core::svn_config_ensure($config_dir, undef); my ($baton, $callbacks) = SVN::Core::auth_open_helper(_auth_providers); my $config = SVN::Core::config_get_config($config_dir); -- cgit v1.2.1 From 56a853b62c0ae7ebaad0a7a0a704f5ef561eb795 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Tue, 2 Mar 2010 19:47:52 +0800 Subject: git-svn: Support retrieving passwords with GIT_ASKPASS git-svn reads passwords from an interactive terminal. This behavior cause GUIs to hang waiting for git-svn to complete Fix this problem by allowing a password-retrieving command to be specified in GIT_ASKPASS. SSH_ASKPASS is supported as a fallback when GIT_ASKPASS is not provided. Signed-off-by: Frank Li Signed-off-by: Junio C Hamano --- git-svn.perl | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 49dd649bc5..07e95ad449 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -3970,18 +3970,25 @@ sub username { sub _read_password { my ($prompt, $realm) = @_; - print STDERR $prompt; - STDERR->flush; - require Term::ReadKey; - Term::ReadKey::ReadMode('noecho'); my $password = ''; - while (defined(my $key = Term::ReadKey::ReadKey(0))) { - last if $key =~ /[\012\015]/; # \n\r - $password .= $key; + if (exists $ENV{GIT_ASKPASS}) { + open(PH, "-|", $ENV{GIT_ASKPASS}, $prompt); + $password = ; + $password =~ s/[\012\015]//; # \n\r + close(PH); + } else { + print STDERR $prompt; + STDERR->flush; + require Term::ReadKey; + Term::ReadKey::ReadMode('noecho'); + while (defined(my $key = Term::ReadKey::ReadKey(0))) { + last if $key =~ /[\012\015]/; # \n\r + $password .= $key; + } + Term::ReadKey::ReadMode('restore'); + print STDERR "\n"; + STDERR->flush; } - Term::ReadKey::ReadMode('restore'); - print STDERR "\n"; - STDERR->flush; $password; } -- cgit v1.2.1 From b91a8a3ee17629ca7b9806fede2937232a05116c Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Wed, 3 Mar 2010 21:34:31 +0100 Subject: git-svn: req_svn when needed The delayed loading of SVN missed a place where SVN::Core is used. Make sure to load the package before trying to use it. Signed-off-by: Michael J Gruber Acked-by: Eric Wong --- git-svn.perl | 1 + 1 file changed, 1 insertion(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index b7c03b641c..bae7231096 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -1102,6 +1102,7 @@ sub cmd_info { if ($@) { $result .= "Repository Root: (offline)\n"; } + ::_req_svn(); $result .= "Repository UUID: $uuid\n" unless $diff_status eq "A" && ($SVN::Core::VERSION le '1.5.4' || $file_type ne "dir"); $result .= "Revision: " . ($diff_status eq "A" ? 0 : $rev) . "\n"; -- cgit v1.2.1 From 942c9aad4f3b69f6f53af77321662d9d69a1bdeb Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Wed, 3 Mar 2010 21:10:23 +0100 Subject: Revert "git-svn: always initialize with core.autocrlf=false" git-svn rebase used to have issues with CRLF conversion. Since these issues have been fixed, we can safely revert the work-around that disables CRLF conversion. This reverts commit d3c9634eacdcaa71cbd69a160e6f4e80ddb7ab63. Signed-off-by: Erik Faye-Lund Acked-by: Eric Wong --- git-svn.perl | 1 - 1 file changed, 1 deletion(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index bae7231096..7bca381c4b 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -369,7 +369,6 @@ sub do_git_init_db { command_noisy(@init_db); $_repository = Git->repository(Repository => ".git"); } - command_noisy('config', 'core.autocrlf', 'false'); my $set; my $pfx = "svn-remote.$Git::SVN::default_repo_id"; foreach my $i (keys %icv) { -- cgit v1.2.1 From b0779246a11d4213c4d9d8af8d3f6e39649c9b4a Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Thu, 4 Mar 2010 11:23:53 +0100 Subject: git-svn: make git svn --version work again by requesting SVN::Core which is needed for the svn version. Signed-off-by: Michael J Gruber Acked-by: Eric Wong --- git-svn.perl | 1 + 1 file changed, 1 insertion(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 7bca381c4b..1a26843f44 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -351,6 +351,7 @@ information. } sub version { + ::_req_svn(); print "git-svn version $VERSION (svn $SVN::Core::VERSION)\n"; exit 0; } -- cgit v1.2.1 From bf60fff8f1e814e1603328141b68686337a5a0b5 Mon Sep 17 00:00:00 2001 From: Tuomas Suutari Date: Wed, 24 Feb 2010 20:09:01 +0200 Subject: git-svn: Fix merge detecting with rewrite-root Detecting of merges from svn:mergeinfo or svk merge tickets failed with rewrite-root option. This fixes it. Signed-off-by: Tuomas Suutari Acked-by: Eric Wong --- git-svn.perl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 1a26843f44..aceeca5a94 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2998,7 +2998,7 @@ sub find_extra_svk_parents { for my $ticket ( @tickets ) { my ($uuid, $path, $rev) = split /:/, $ticket; if ( $uuid eq $self->ra_uuid ) { - my $url = $self->rewrite_root || $self->{url}; + my $url = $self->{url}; my $repos_root = $url; my $branch_from = $path; $branch_from =~ s{^/}{}; @@ -3206,7 +3206,7 @@ sub find_extra_svn_parents { # are now marked as merge, we can add the tip as a parent. my @merges = split "\n", $mergeinfo; my @merge_tips; - my $url = $self->rewrite_root || $self->{url}; + my $url = $self->{url}; my $uuid = $self->ra_uuid; my %ranges; for my $merge ( @merges ) { -- cgit v1.2.1 From 70ee0b7797041621b22c448726f4f88102b5a4f5 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Tue, 4 May 2010 16:36:47 -0700 Subject: git svn: avoid uninitialized var in 'reset' When "git svn reset" is called with an invalid revision, we bail out and show the user a proper error message instead of giving them a cryptic one related to git-svn internals. ref: http://bugs.debian.org/578908 Signed-off-by: Jonathan Nieder Reported-by: Jens Seidel Acked-by: Eric Wong --- git-svn.perl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 2c86ea2e38..dc668034d0 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -1185,6 +1185,7 @@ sub cmd_reset { "history\n"; } my ($r, $c) = $gs->find_rev_before($target, not $_fetch_parent); + die "Cannot find SVN revision $target\n" unless defined($c); $gs->rev_map_set($r, $c, 'reset', $uuid); print "r$r = $c ($gs->{ref_id})\n"; } @@ -3605,6 +3606,7 @@ sub mkfile { sub rev_map_set { my ($self, $rev, $commit, $update_ref, $uuid) = @_; + defined $commit or die "missing arg3\n"; length $commit == 40 or die "arg3 must be a full SHA1 hexsum\n"; my $db = $self->map_path($uuid); my $db_lock = "$db.lock"; -- cgit v1.2.1 From 1174768b460a5f24ef0323783ab69c578e5aa44a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sat, 8 May 2010 16:40:41 +0000 Subject: git-svn: Remove unused use of File::Temp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The use line was added in ffe256f9. File::Temp calls were later moved to Git.pm in 0b19138b, but that commit neglected to remove the now-redundant import. Signed-off-by: Ævar Arnfjörð Bjarmason Acked-by: Eric Wong --- git-svn.perl | 1 - 1 file changed, 1 deletion(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index dc668034d0..74d86128cc 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -4000,7 +4000,6 @@ use vars qw/@ISA/; use strict; use warnings; use Carp qw/croak/; -use File::Temp qw/tempfile/; use IO::File qw//; use vars qw/$_ignore_regex/; -- cgit v1.2.1 From 73d419558d9fa4de3be28bd58158636bc739808e Mon Sep 17 00:00:00 2001 From: Torsten Schmutzler Date: Thu, 6 May 2010 22:20:43 +0200 Subject: git-svn: mangle refnames forbidden in git git-check-ref-format(1) describes names which cannot be used as refnames for git. Some are legal branchnames in subversion however. Mangle the not yet handled cases. Signed-off-by: Torsten Schmutzler Acked-by: Eric Wong --- git-svn.perl | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 74d86128cc..b3b6964f95 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2087,6 +2087,14 @@ sub refname { # .. becomes %2E%2E $refname =~ s{\.\.}{%2E%2E}g; + # trailing dots and .lock are not allowed + # .$ becomes %2E and .lock becomes %2Elock + $refname =~ s{\.(?=$|lock$)}{%2E}; + + # the sequence @{ is used to access the reflog + # @{ becomes %40{ + $refname =~ s{\@\{}{%40\{}g; + return $refname; } -- cgit v1.2.1 From 7c42e390a37a11b1f7a77f5f07c261a8f930663a Mon Sep 17 00:00:00 2001 From: "Michael J. Kiwala" Date: Tue, 1 Jun 2010 16:24:57 -0500 Subject: git svn: fix empty directory creation Avoid attempts to stat() the contents of '', which could happen when the root directory is empty. Additionally, remove the unnecessary '_' stat optimization since it was confusing and possibly throwing off the non-existent case. [ew: fixed indentation, rewrote commit message] Acked-by: Eric Wong Signed-off-by: Michael J. Kiwala --- git-svn.perl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index b3b6964f95..09c4ca56f0 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2836,8 +2836,9 @@ sub mkemptydirs { foreach my $d (sort keys %empty_dirs) { $d = uri_decode($d); $d =~ s/$strip//; + next unless length($d); next if -d $d; - if (-e _) { + if (-e $d) { warn "$d exists but is not a directory\n"; } else { print "creating empty directory: $d\n"; -- cgit v1.2.1 From b4b3360078e758221db3f7b496e35ccb43364151 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Sun, 13 Jun 2010 06:27:43 -0500 Subject: git-svn: strip off leading slashes on --trunk argument The following command git svn clone \ -r9500:10006 \ svn://svn.debian.org/svn/pkg-games/packages \ --trunk=/trunk/freedoom \ --branches=/branches/freedoom \ --tags=/tags/freedoom \ freedoom.git.2009091 produces strange results: With v1.6.3.3 (and perhaps earlier versions), this would fetch up to and including r9978 (the last revision of the no_iwad_alternatives branch before it was deleted), check it out, and prematurely declare success, leaving out some commits to the trunk (r9984, r9985, r10006) from after the branch was merged. With v1.6.5-rc0~74 (svn: allow branches outside of refs/remotes, 2009-08-11) and later, this fetches up to and including r9978 and then attempts a post-fetch checkout and fails. r9978 = 25f0920175c395f0f22f54ae7a2318147f745274 (refs/remotes/no_iwad_alternatives) fatal: refs/remotes/trunk: not a valid SHA1 update-ref refs/heads/master refs/remotes/trunk: command returned error: 128 Checking .git/config reveals fetch = packages//trunk/freedoom:refs/remotes/trunk And with both 1.6.3.3 and 1.7.1, using --trunk=trunk/freedom without the leading slash (/) works fine. Moral: git-svn needs to scrub an initial / from $_trunk and related arguments it receives. Make it so. Reported-by: Jon Dowland Signed-off-by: Jonathan Nieder Acked-by: Eric Wong --- git-svn.perl | 1 + 1 file changed, 1 insertion(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 09c4ca56f0..80ab45065e 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -963,6 +963,7 @@ sub cmd_multi_init { } do_git_init_db(); if (defined $_trunk) { + $_trunk =~ s#^/+##; my $trunk_ref = 'refs/remotes/' . $_prefix . 'trunk'; # try both old-style and new-style lookups: my $gs_trunk = eval { Git::SVN->new($trunk_ref) }; -- cgit v1.2.1 From b1a954a37cea7d5a0a123758f6c2ad9005d4481e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 14 Jun 2010 04:31:10 +0000 Subject: git svn: avoid unnecessary '/' in paths for SVN svn:// servers are more picky regarding redundant slashes than file:// and http(s)://-backed respositories. Since the last commit, we avoid putting unnecessary slashes in $GIT_CONFIG, but this doesn't help users who are already set up that way. Signed-off-by: Eric Wong --- git-svn.perl | 3 +++ 1 file changed, 3 insertions(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 80ab45065e..19d6848d0e 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2055,6 +2055,9 @@ sub new { "\":$ref_id\$\" in config\n"; ($self->{path}, undef) = split(/\s*:\s*/, $fetch); } + $self->{path} =~ s{/+}{/}g; + $self->{path} =~ s{\A/}{}; + $self->{path} =~ s{/\z}{}; $self->{url} = command_oneline('config', '--get', "svn-remote.$repo_id.url") or die "Failed to read \"svn-remote.$repo_id.url\" in config\n"; -- cgit v1.2.1 From 8ac3a66702c43386eb580b7a1a8b1a31cd675327 Mon Sep 17 00:00:00 2001 From: Sergey Vlasov Date: Sun, 18 Jul 2010 16:17:49 +0400 Subject: git-svn: write memoized data explicitly to avoid Storable bug Apparently using the Storable module during global destruction is unsafe - there is a bug which can cause segmentation faults: http://rt.cpan.org/Public/Bug/Display.html?id=36087 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=482355 The persistent memoization support introduced in commit 8bff7c538 relied on global destruction to write cached data, which was leading to segfaults in some Perl configurations. Calling Memoize::unmemoize in the END block forces the cache writeout to be performed earlier, thus avoiding the bug. Signed-off-by: Sergey Vlasov Acked-by: Eric Wong --- git-svn.perl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 19d6848d0e..c4163584a9 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -3169,6 +3169,22 @@ sub has_no_changes { LIST_CACHE => 'FAULT', ; } + + sub unmemoize_svn_mergeinfo_functions { + return if not $memoized; + $memoized = 0; + + Memoize::unmemoize 'lookup_svn_merge'; + Memoize::unmemoize 'check_cherry_pick'; + Memoize::unmemoize 'has_no_changes'; + } +} + +END { + # Force cache writeout explicitly instead of waiting for + # global destruction to avoid segfault in Storable: + # http://rt.cpan.org/Public/Bug/Display.html?id=36087 + unmemoize_svn_mergeinfo_functions(); } sub parents_exclude { -- cgit v1.2.1 From 3713e2226bcda64513efd537f370ce4d7f767a1e Mon Sep 17 00:00:00 2001 From: Dmitry Statyvka Date: Fri, 30 Jul 2010 04:30:13 +0200 Subject: git svn: add an option to recode pathnames Introduce a new option 'svn.pathnameencoding' that instructs git svn to recode pathnames to a given encoding. It can be used by windows users and by those who work in non-utf8 locales to avoid corrupted file names with non-ascii characters. [rp: renamed the option and added manpage documentation] Signed-off-by: Dmitry Statyvka Signed-off-by: Robert Pollak Acked-by: Eric Wong --- git-svn.perl | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index c4163584a9..c92238ece2 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -4050,6 +4050,7 @@ sub new { $self->{absent_dir} = {}; $self->{absent_file} = {}; $self->{gii} = $git_svn->tmp_index_do(sub { Git::IndexInfo->new }); + $self->{pathnameencoding} = Git::config('svn.pathnameencoding'); $self; } @@ -4133,6 +4134,10 @@ sub open_directory { sub git_path { my ($self, $path) = @_; + if (my $enc = $self->{pathnameencoding}) { + require Encode; + Encode::from_to($path, 'UTF-8', $enc); + } if ($self->{path_strip}) { $path =~ s!$self->{path_strip}!! or die "Failed to strip path '$path' ($self->{path_strip})\n"; @@ -4521,6 +4526,10 @@ sub split_path { sub repo_path { my ($self, $path) = @_; + if (my $enc = $self->{pathnameencoding}) { + require Encode; + Encode::from_to($path, $enc, 'UTF-8'); + } $self->{path_prefix}.(defined $path ? $path : ''); } -- cgit v1.2.1 From 181264ad590ffef9d956fdd023369869c2d0a55f Mon Sep 17 00:00:00 2001 From: "David D. Kilzer" Date: Mon, 2 Aug 2010 12:58:19 -0700 Subject: git svn: fix dcommit to work with touched files The dcommit command fails if an otherwise unmodified file has been touched in the working directory: Cannot dcommit with a dirty index. Commit your changes first, or stash them with `git stash'. This happens because "git diff-index" reports a difference between the index and the filesystem: :100644 100644 d00491...... 000000...... M file The fix is to run "git update-index --refresh" before "git diff-index" as is done in git-rebase and git-rebase--interactive before "git diff-files". This changes dcommit to display a list of modified files before exiting. Also add a similar test case for "git svn rebase". [ew: rearranged commit message subject] Signed-off-by: David D. Kilzer Acked-by: Eric Wong --- git-svn.perl | 1 + 1 file changed, 1 insertion(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index c92238ece2..8d2ef3d16f 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -494,6 +494,7 @@ sub cmd_set_tree { sub cmd_dcommit { my $head = shift; + command_noisy(qw/update-index --refresh/); git_cmd_try { command_oneline(qw/diff-index --quiet HEAD/) } 'Cannot dcommit with a dirty index. Commit your changes first, ' . "or stash them with `git stash'.\n"; -- cgit v1.2.1 From 46cb16fb599451f417e7cd668e77866f5aa03fc0 Mon Sep 17 00:00:00 2001 From: Steven Walter Date: Tue, 3 Aug 2010 19:21:25 -0400 Subject: git svn: URL-decode left-hand side of svn refspec This change allows git-svn to handle an URL with colons in the path [ew: rewritten to use uri_decode() function] Signed-off-by: Eric Wong --- git-svn.perl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 8d2ef3d16f..34884b8fce 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -1820,6 +1820,7 @@ sub read_all_remotes { die("svn-remote.$remote: remote ref '$remote_ref' " . "must start with 'refs/'\n") unless $remote_ref =~ m{^refs/}; + $local_ref = uri_decode($local_ref); $r->{$remote}->{fetch}->{$local_ref} = $remote_ref; $r->{$remote}->{svm} = {} if $use_svm_props; } elsif (m!^(.+)\.usesvmprops=\s*(.*)\s*$!) { @@ -1832,6 +1833,7 @@ sub read_all_remotes { die("svn-remote.$remote: remote ref '$remote_ref' ($t) " . "must start with 'refs/'\n") unless $remote_ref =~ m{^refs/}; + $local_ref = uri_decode($local_ref); my $rs = { t => $t, remote => $remote, -- cgit v1.2.1 From 54fb7f9b08270873b0646d84164e1cebe2deb857 Mon Sep 17 00:00:00 2001 From: "David D. Kilzer" Date: Sun, 15 Aug 2010 06:15:54 -0700 Subject: git-svn: fix regex to remove "tail" from svn tags Fix a regular expression used to remove the revision from the end of an svn tag or branch name. The regex did not account for any "tail" (dashes) that may have been added to the end of the tag name (which first appeared in v1.4.1-rc2~11). If not fixed, tags with names like "tags/mytag@5--@2" may be created. Signed-off-by: David D. Kilzer Acked-by: Eric Wong --- git-svn.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 34884b8fce..39bcb45593 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2959,7 +2959,7 @@ sub other_gs { my $gs = Git::SVN->find_by_url($new_url, $url, $branch_from); unless ($gs) { my $ref_id = $old_ref_id; - $ref_id =~ s/\@\d+$//; + $ref_id =~ s/\@\d+-*$//; $ref_id .= "\@$r"; # just grow a tail if we're not unique enough :x $ref_id .= '-' while find_ref($ref_id); -- cgit v1.2.1 From 3235b7053c45a734c1cdf9b117bda68b7ced29c9 Mon Sep 17 00:00:00 2001 From: "David D. Kilzer" Date: Sun, 15 Aug 2010 06:15:55 -0700 Subject: git-svn: fix fetch with deleted tag Currently git-svn assumes that two tags created from the same revision will have the same repo url, so it uses a ref to the tag without checking that its url matches the current url. This causes issues when fetching an svn repo where a tag was created, deleted, and then recreated under the following circumstances: - Both tags were copied from the same revision. - Both tags had the same name. - Both tags had different repository paths. - [Optional] Both tags have a file with the same name but different content. When all four conditions are met, a checksum mismatch error occurs because the content of two files with the same path differs (see t/t9155--git-svn-fetch-deleted-tag.sh): Checksum mismatch: ChangeLog 065854.... expected: ce771b.... got: 9563fd.... When only the first three conditions are met, no error occurs but the tag in git matches the first (deleted) tag instead of the last (most recent) tag (see t/t9156-git-svn-fetch-deleted-tag-2.sh). The fix is to verify that the repo url for the ref matches the current url. If the urls do not match, then a "tail" is grown on the tag name by appending a dash and rechecking the new ref's repo url until either a matching repo url is found or a new tag is created. Signed-off-by: David D. Kilzer Acked-by: Eric Wong --- git-svn.perl | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 39bcb45593..9b046b693f 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2963,14 +2963,25 @@ sub other_gs { $ref_id .= "\@$r"; # just grow a tail if we're not unique enough :x $ref_id .= '-' while find_ref($ref_id); - print STDERR "Initializing parent: $ref_id\n" unless $::_q > 1; my ($u, $p, $repo_id) = ($new_url, '', $ref_id); if ($u =~ s#^\Q$url\E(/|$)##) { $p = $u; $u = $url; $repo_id = $self->{repo_id}; } - $gs = Git::SVN->init($u, $p, $repo_id, $ref_id, 1); + while (1) { + # It is possible to tag two different subdirectories at + # the same revision. If the url for an existing ref + # does not match, we must either find a ref with a + # matching url or create a new ref by growing a tail. + $gs = Git::SVN->init($u, $p, $repo_id, $ref_id, 1); + my (undef, $max_commit) = $gs->rev_map_max(1); + last if (!$max_commit); + my ($url) = ::cmt_metadata($max_commit); + last if ($url eq $gs->full_url); + $ref_id .= '-'; + } + print STDERR "Initializing parent: $ref_id\n" unless $::_q > 1; } $gs } -- cgit v1.2.1 From a3c75056dc73661a6cdab180659f52cdb03b357c Mon Sep 17 00:00:00 2001 From: Steven Walter Date: Thu, 2 Sep 2010 18:32:06 -0400 Subject: git-svn: check_cherry_pick should exclude commits already in our history The merge-base between @$parents and $merge_tip may have been reached through a merge commit. This means that some commits that are ancestors of @$parents will not be ancestors of $merge_base. The mergeinfo property will not list commits that are ancestors of @$parents, so we need to explicitly exclude them. [ew: squashed and cleaned up test case from Steven] Signed-off-by: Steven Walter Acked-by: Eric Wong --- git-svn.perl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 9b046b693f..c7c4dcdba5 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -3118,9 +3118,10 @@ sub _rev_list { sub check_cherry_pick { my $base = shift; my $tip = shift; + my $parents = shift; my @ranges = @_; my %commits = map { $_ => 1 } - _rev_list("--no-merges", $tip, "--not", $base); + _rev_list("--no-merges", $tip, "--not", $base, @$parents); for my $range ( @ranges ) { delete @commits{_rev_list($range)}; } @@ -3296,6 +3297,7 @@ sub find_extra_svn_parents { # double check that there are no missing non-merge commits my (@incomplete) = check_cherry_pick( $merge_base, $merge_tip, + $parents, @$ranges, ); -- cgit v1.2.1 From 8565a568cdd8604d4b5a00e52c64064a8aebf690 Mon Sep 17 00:00:00 2001 From: Mathias Lafeldt Date: Fri, 24 Sep 2010 00:05:03 +0200 Subject: git-svn: fix processing of decorated commit hashes The function working_head_info() fails to parse commit hashes if they are decorated (i.e. log.decorate is true), causing dcommit, rebase, and other vital git-svn commands to malfunction. This patch disables decorated log output with --no-decorate. [ew: wrapped long line] Signed-off-by: Mathias Lafeldt Acked-by: Eric Wong --- git-svn.perl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index c7c4dcdba5..18cfb2466d 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -1513,7 +1513,8 @@ sub cmt_sha2rev_batch { sub working_head_info { my ($head, $refs) = @_; - my @args = ('log', '--no-color', '--first-parent', '--pretty=medium'); + my @args = qw/log --no-color --no-decorate --first-parent + --pretty=medium/; my ($fh, $ctx) = command_output_pipe(@args, $head); my $hash; my %max; -- cgit v1.2.1 From d48b28418355ef41a9501eb28a82ec0b69e62a17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Fri, 24 Sep 2010 20:00:52 +0000 Subject: perl: bump the required Perl version to 5.8 from 5.6.[21] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Formalize our dependency on perl 5.8, bumped from 5.6.[12]. We already used the three-arg form of open() which was introduced in 5.6.1, but t/t9700/test.pl explicitly depended on 5.6.2. However git-add--interactive.pl has been failing on the 5.6 line since it was introduced in v1.5.0-rc0~12^2~2 back in 2006 due to this open syntax: sub run_cmd_pipe { my $fh = undef; open($fh, '-|', @_) or die; return <$fh>; } Which when executed dies on "Can't use an undefined value as filehandle reference". Several of our tests also fail on 5.6 (even more when compiled with NO_PERL_MAKEMAKER=1): t2016-checkout-patch.sh t3904-stash-patch.sh t3701-add-interactive.sh t7105-reset-patch.sh t7501-commit.sh t9700-perl-git.sh Our code is bitrotting on 5.6 with no-one interested in fixing it, and pinning us to such an ancient release of Perl is keeping us from using useful features introduced in the 5.8 release. The 5.6 series is now over 10 years old, and the 5.6.2 maintenance release almost 7. 5.8 on the other hand is more than 8 years old. All the modern Unix-like operating systems have now upgraded to it or a later version, and 5.8 packages are available for old IRIX, AIX Solaris and Tru64 systems. Signed-off-by: Ævar Arnfjörð Bjarmason Acked-by: Tor Arntsen Acked-by: Randal L. Schwartz Signed-off-by: Junio C Hamano --- git-svn.perl | 1 + 1 file changed, 1 insertion(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 9b046b693f..d2922245aa 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -1,6 +1,7 @@ #!/usr/bin/env perl # Copyright (C) 2006, Eric Wong # License: GPL v2 or later +use 5.008; use warnings; use strict; use vars qw/ $AUTHOR $VERSION -- cgit v1.2.1 From 6abd9332f97441a568421ba233ad8929b50a7efc Mon Sep 17 00:00:00 2001 From: Steven Walter Date: Fri, 24 Sep 2010 23:51:50 -0400 Subject: git-svn: allow the mergeinfo property to be set As a first step towards preserving merges across dcommit, we need a mechanism to update the svn:mergeinfo property. [ew: fixed bashism and style issues in test case] Signed-off-by: Steven Walter Acked-by: Eric Wong --- git-svn.perl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 757de82161..177dd259cd 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -84,7 +84,7 @@ my ($_stdin, $_help, $_edit, $_version, $_fetch_all, $_no_rebase, $_fetch_parent, $_merge, $_strategy, $_dry_run, $_local, $_prefix, $_no_checkout, $_url, $_verbose, - $_git_format, $_commit_url, $_tag); + $_git_format, $_commit_url, $_tag, $_merge_info); $Git::SVN::_follow_parent = 1; $_q ||= 0; my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username, @@ -154,6 +154,7 @@ my %cmd = ( 'commit-url=s' => \$_commit_url, 'revision|r=i' => \$_revision, 'no-rebase' => \$_no_rebase, + 'mergeinfo=s' => \$_merge_info, %cmt_opts, %fc_opts } ], branch => [ \&cmd_branch, 'Create a branch in the SVN repository', @@ -569,6 +570,7 @@ sub cmd_dcommit { print "Committed r$_[0]\n"; $cmt_rev = $_[0]; }, + mergeinfo => $_merge_info, svn_path => ''); if (!SVN::Git::Editor->new(\%ed_opts)->apply_diff) { print "No changes\n$d~1 == $d\n"; @@ -4451,6 +4453,7 @@ sub new { $self->{path_prefix} = length $self->{svn_path} ? "$self->{svn_path}/" : ''; $self->{config} = $opts->{config}; + $self->{mergeinfo} = $opts->{mergeinfo}; return $self; } @@ -4760,6 +4763,11 @@ sub change_file_prop { $self->SUPER::change_file_prop($fbat, $pname, $pval, $self->{pool}); } +sub change_dir_prop { + my ($self, $pbat, $pname, $pval) = @_; + $self->SUPER::change_dir_prop($pbat, $pname, $pval, $self->{pool}); +} + sub _chg_file_get_blob ($$$$) { my ($self, $fbat, $m, $which) = @_; my $fh = $::_repository->temp_acquire("git_blob_$which"); @@ -4853,6 +4861,11 @@ sub apply_diff { fatal("Invalid change type: $f"); } } + + if (defined($self->{mergeinfo})) { + $self->change_dir_prop($self->{bat}{''}, "svn:mergeinfo", + $self->{mergeinfo}); + } $self->rmdirs if $_rmdir; if (@$mods == 0) { $self->abort_edit; -- cgit v1.2.1 From b1b47554ae889ca76b66349819c9b95a8be5f646 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Thu, 10 Mar 2011 15:45:03 +0100 Subject: git-log: put space after commit mark Currently, commit marks (left, right, boundary, cherry) are output right before the commit sha1, which makes it difficult to copy sha1s. Sample output for "git log --oneline --cherry": =049c269 t6007: test rev-list --cherry Change this to = 049c269 t6007: test rev-list --cherry which matches exactly the current output of "git log --graph". Leave "git rev-list" output as is (no space) so that they do not break. Adjust "git-svn" which uses "git log --pretty=raw --boundary". Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- git-svn.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index 177dd259cd..a5857c1ad4 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -5734,7 +5734,7 @@ sub cmd_show_log { my (@k, $c, $d, $stat); my $esc_color = qr/(?:\033\[(?:(?:\d+;)*\d*)?m)*/; while (<$log>) { - if (/^${esc_color}commit -?($::sha1_short)/o) { + if (/^${esc_color}commit (- )?($::sha1_short)/o) { my $cmt = $1; if ($c && cmt_showable($c) && $c->{r} != $r_last) { $r_last = $c->{r}; -- cgit v1.2.1 From 12a296bca3d07875d4c3db0e8e24fbaa86ca97b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20R=2E=20Sede=C3=B1o?= Date: Fri, 8 Apr 2011 10:57:54 -0400 Subject: git-svn: Add a svn-remote..pushurl config key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Similar to the 'remote..pushurl' config key for git remotes, 'pushurl' is designed to be used in cases where 'url' points to an SVN repository via a read-only transport, to provide an alternate read/write transport. It is assumed that both keys point to the same repository. The 'pushurl' key is distinct from the 'commiturl' key in that 'commiturl' is a full svn path while 'pushurl' (like 'url') is a base path. 'commiturl' takes precendece over 'pushurl' in cases where either might be used. The 'pushurl' is used by git-svn's dcommit and branch commands. Signed-off-by: Alejandro R. Sedeño Reviewed-by: James Y Knight Acked-by: Eric Wong --- git-svn.perl | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index a5857c1ad4..e5a553f007 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -528,7 +528,7 @@ sub cmd_dcommit { $url = eval { command_oneline('config', '--get', "svn-remote.$gs->{repo_id}.commiturl") }; if (!$url) { - $url = $gs->full_url + $url = $gs->full_pushurl } } @@ -676,7 +676,7 @@ sub cmd_branch { $head ||= 'HEAD'; my (undef, $rev, undef, $gs) = working_head_info($head); - my $src = $gs->full_url; + my $src = $gs->full_pushurl; my $remote = Git::SVN::read_all_remotes()->{$gs->{repo_id}}; my $allglobs = $remote->{ $_tag ? 'tags' : 'branches' }; @@ -727,7 +727,7 @@ sub cmd_branch { $url = eval { command_oneline('config', '--get', "svn-remote.$gs->{repo_id}.commiturl") }; if (!$url) { - $url = $remote->{url}; + $url = $remote->{pushurl} || $remote->{url}; } } my $dst = join '/', $url, $lft, $branch_name, ($rgt || ()); @@ -1831,6 +1831,8 @@ sub read_all_remotes { $r->{$1}->{svm} = {}; } elsif (m!^(.+)\.url=\s*(.*)\s*$!) { $r->{$1}->{url} = $2; + } elsif (m!^(.+)\.pushurl=\s*(.*)\s*$!) { + $r->{$1}->{pushurl} = $2; } elsif (m!^(.+)\.(branches|tags)=$svn_refspec$!) { my ($remote, $t, $local_ref, $remote_ref) = ($1, $2, $3, $4); @@ -2068,6 +2070,8 @@ sub new { $self->{url} = command_oneline('config', '--get', "svn-remote.$repo_id.url") or die "Failed to read \"svn-remote.$repo_id.url\" in config\n"; + $self->{pushurl} = eval { command_oneline('config', '--get', + "svn-remote.$repo_id.pushurl") }; $self->rebuild; $self; } @@ -2545,6 +2549,15 @@ sub full_url { $self->{url} . (length $self->{path} ? '/' . $self->{path} : ''); } +sub full_pushurl { + my ($self) = @_; + if ($self->{pushurl}) { + return $self->{pushurl} . (length $self->{path} ? '/' . + $self->{path} : ''); + } else { + return $self->full_url; + } +} sub set_commit_header_env { my ($log_entry) = @_; -- cgit v1.2.1 From f5549afd5d6c5492176b6fa21769c59bfe8e1d70 Mon Sep 17 00:00:00 2001 From: James Y Knight Date: Mon, 4 Apr 2011 15:09:08 -0400 Subject: git-svn: Cache results of running the executable "git config" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Running programs is not cheap! Signed-off-by: James Y Knight Signed-off-by: Alejandro R. Sedeño Acked-by: Eric Wong --- git-svn.perl | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index e5a553f007..bf0451b468 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -59,6 +59,7 @@ use File::Find; use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/; use IPC::Open3; use Git; +use Memoize; # core since 5.8.0, Jul 2002 BEGIN { # import functions from Git into our packages, en masse @@ -72,6 +73,8 @@ BEGIN { *{"${package}::$_"} = \&{"Git::$_"}; } } + Memoize::memoize 'Git::config'; + Memoize::memoize 'Git::config_bool'; } my ($SVN); @@ -3210,6 +3213,8 @@ sub has_no_changes { Memoize::unmemoize 'check_cherry_pick'; Memoize::unmemoize 'has_no_changes'; } + + Memoize::memoize 'Git::SVN::repos_root'; } END { -- cgit v1.2.1 From 9963e025e88f134cf07ef348d80a5821c69a7eb0 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Fri, 20 May 2011 13:16:34 +0200 Subject: git-svn: Fix git svn log --show-commit git svn log --show-commit had no tests and, consequently, no attention by the author of b1b4755 (git-log: put space after commit mark, 2011-03-10) who kept git svn log working only without --show-commit. Introduce a test and fix it. Reported-by: Bernt Hansen Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- git-svn.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-svn.perl') diff --git a/git-svn.perl b/git-svn.perl index bf0451b468..da3fea8bd2 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -5752,7 +5752,7 @@ sub cmd_show_log { my (@k, $c, $d, $stat); my $esc_color = qr/(?:\033\[(?:(?:\d+;)*\d*)?m)*/; while (<$log>) { - if (/^${esc_color}commit (- )?($::sha1_short)/o) { + if (/^${esc_color}commit (?:- )?($::sha1_short)/o) { my $cmt = $1; if ($c && cmt_showable($c) && $c->{r} != $r_last) { $r_last = $c->{r}; -- cgit v1.2.1