From 7b151f492d4453a9269a74b4d5b6f3ec1a6681e4 Mon Sep 17 00:00:00 2001 From: Frederic Heitzmann Date: Thu, 3 Nov 2011 19:33:30 +0100 Subject: [PATCH 1/6] completion: add --interactive option to git svn dcommit see afd7f1e for more details on git svn dcommit --interactive Signed-off-by: Frederic Heitzmann Acked-by: Eric Wong --- contrib/completion/git-completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 1505cff12d..64be572eed 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2512,7 +2512,7 @@ _git_svn () __gitcomp " --merge --strategy= --verbose --dry-run --fetch-all --no-rebase --commit-url - --revision $cmt_opts $fc_opts + --revision --interactive $cmt_opts $fc_opts " ;; set-tree,--*) From b380e3a79211f59adf6761968ff76c8d6535f72e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sun, 12 Feb 2012 00:23:05 +0000 Subject: [PATCH 2/6] git-svn: remove redundant porcelain option to rev-list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change an invocation of git-rev-list(1) to not use --no-color, git-rev-list(1) will always ignore that option and the --color option, so there's no need to pass it. Signed-off-by: Ævar Arnfjörð Bjarmason Acked-by: Eric Wong --- git-svn.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-svn.perl b/git-svn.perl index eeb83d3759..712eeebe17 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -3920,7 +3920,7 @@ sub rebuild { my ($base_rev, $head) = ($partial ? $self->rev_map_max_norebuild(1) : (undef, undef)); my ($log, $ctx) = - command_output_pipe(qw/rev-list --pretty=raw --no-color --reverse/, + command_output_pipe(qw/rev-list --pretty=raw --reverse/, ($head ? "$head.." : "") . $self->refname, '--'); my $metadata_url = $self->metadata_url; From 83cf21f9852f22f5a46a48e3b636ecc6403a717e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sun, 12 Feb 2012 00:23:06 +0000 Subject: [PATCH 3/6] git-svn: un-break "git svn rebase" when log.abbrevCommit=true MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change git-svn to use git-rev-list(1) instead of git-log(1) since the latter is porcelain that'll cause "git svn rebase" to fail completely if log.abbrevCommit is set to true in the configuration. Without this patch the code will fail to parse a SHA1, and then just spew a bunch of "Use of uninitialized value $hash in string eq" warnings at "if ($c && $c eq $hash) { ..." and never do anything useful. Signed-off-by: Ævar Arnfjörð Bjarmason Helped-by: Jonathan Nieder Acked-by: Eric Wong --- git-svn.perl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/git-svn.perl b/git-svn.perl index 712eeebe17..bebe38b1ab 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -1878,8 +1878,7 @@ sub cmt_sha2rev_batch { sub working_head_info { my ($head, $refs) = @_; - my @args = qw/log --no-color --no-decorate --first-parent - --pretty=medium/; + my @args = qw/rev-list --first-parent --pretty=medium/; my ($fh, $ctx) = command_output_pipe(@args, $head); my $hash; my %max; From 6aa17fc69bce19bcd412cf4b950e797767c87012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wei-Yin=20Chen=20=28=E9=99=B3=E5=A8=81=E5=B0=B9=29?= Date: Mon, 19 Dec 2011 16:11:05 +0800 Subject: [PATCH 4/6] git-svn: Fix time zone in --localtime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use numerical form of time zone to replace alphabetic time zone abbreviation generated by "%Z". "%Z" is not portable and contain ambiguity for many areas. For example, CST could be "Central Standard Time" (GMT-0600) and "China Standard Time" (GMT+0800). Alphabetic time zone abbreviation is meant for human readability, not for specifying a time zone for machines. Failed case can be illustrated like this in linux shell: > echo $TZ Asia/Taipei > date +%Z CST > env TZ=`date +%Z` date Mon Dec 19 06:03:04 CST 2011 > date Mon Dec 19 14:03:04 CST 2011 [ew: fixed bad package reference inside Git::SVN::Log] Signed-off-by: Wei-Yin Chen (陳威尹) Acked-by: Eric Wong --- git-svn.perl | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/git-svn.perl b/git-svn.perl index bebe38b1ab..7a92764c65 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2028,6 +2028,7 @@ package Git::SVN; use File::Path qw/mkpath/; use File::Copy qw/copy/; use IPC::Open3; +use Time::Local; use Memoize; # core since 5.8.0, Jul 2002 use Memoize::Storable; @@ -3286,6 +3287,14 @@ sub get_untracked { \@out; } +sub get_tz { + # some systmes don't handle or mishandle %z, so be creative. + my $t = shift || time; + my $gm = timelocal(gmtime($t)); + my $sign = qw( + + - )[ $t <=> $gm ]; + return sprintf("%s%02d%02d", $sign, (gmtime(abs($t - $gm)))[2,1]); +} + # parse_svn_date(DATE) # -------------------- # Given a date (in UTC) from Subversion, return a string in the format @@ -3318,8 +3327,7 @@ sub parse_svn_date { delete $ENV{TZ}; } - my $our_TZ = - POSIX::strftime('%Z', $S, $M, $H, $d, $m - 1, $Y - 1900); + my $our_TZ = get_tz(); # This converts $epoch_in_UTC into our local timezone. my ($sec, $min, $hour, $mday, $mon, $year, @@ -5993,7 +6001,6 @@ package Git::SVN::Log; use strict; use warnings; use POSIX qw/strftime/; -use Time::Local; use constant commit_log_separator => ('-' x 72) . "\n"; use vars qw/$TZ $limit $color $pager $non_recursive $verbose $oneline %rusers $show_commit $incremental/; @@ -6103,11 +6110,8 @@ sub run_pager { } sub format_svn_date { - # some systmes don't handle or mishandle %z, so be creative. my $t = shift || time; - my $gm = timelocal(gmtime($t)); - my $sign = qw( + + - )[ $t <=> $gm ]; - my $gmoff = sprintf("%s%02d%02d", $sign, (gmtime(abs($t - $gm)))[2,1]); + my $gmoff = Git::SVN::get_tz($t); return strftime("%Y-%m-%d %H:%M:%S $gmoff (%a, %d %b %Y)", localtime($t)); } From 5ec514bd2f9b18463886df372ea1412fc61467de Mon Sep 17 00:00:00 2001 From: Steven Walter Date: Thu, 9 Feb 2012 15:52:22 -0500 Subject: [PATCH 5/6] git-svn.perl: perform deletions before anything else If we delete a file and recreate it as a directory in a single commit, we have to tell the server about the deletion first or else we'll get "RA layer request failed: Server sent unexpected return value (405 Method Not Allowed) in response to MKCOL request" Signed-off-by: Steven Walter Acked-by: Eric Wong --- git-svn.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-svn.perl b/git-svn.perl index 7a92764c65..028f118037 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -5381,7 +5381,7 @@ sub DESTROY { sub apply_diff { my ($self) = @_; my $mods = $self->{mods}; - my %o = ( D => 1, R => 0, C => -1, A => 3, M => 3, T => 3 ); + my %o = ( D => 0, C => 1, R => 2, A => 3, M => 4, T => 5 ); foreach my $m (sort { $o{$a->{chg}} <=> $o{$b->{chg}} } @$mods) { my $f = $m->{chg}; if (defined $o{$f}) { From 379862ec5a413e636d977a6ea3d618f0b3eafceb Mon Sep 17 00:00:00 2001 From: Steven Walter Date: Mon, 20 Feb 2012 09:17:54 -0500 Subject: [PATCH 6/6] git-svn.perl: fix a false-positive in the "already exists" test open_or_add_dir checks to see if the directory already exists or not. If it already exists and is not a directory, then we fail. However, open_or_add_dir did not previously account for the possibility that the path did exist as a file, but is deleted in the current commit. In order to prevent this legitimate case from failing, open_or_add_dir needs to know what files are deleted in the current commit. Unfortunately that information has to be plumbed through a couple of layers. Signed-off-by: Steven Walter Acked-by: Eric Wong --- git-svn.perl | 43 ++++++++++++++++++++++++---------------- t/t9100-git-svn-basic.sh | 33 ++++++++++++++++-------------- 2 files changed, 44 insertions(+), 32 deletions(-) diff --git a/git-svn.perl b/git-svn.perl index 028f118037..4334b95f70 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -5137,7 +5137,7 @@ sub rmdirs { } sub open_or_add_dir { - my ($self, $full_path, $baton) = @_; + my ($self, $full_path, $baton, $deletions) = @_; my $t = $self->{types}->{$full_path}; if (!defined $t) { die "$full_path not known in r$self->{r} or we have a bug!\n"; @@ -5146,7 +5146,7 @@ sub open_or_add_dir { no warnings 'once'; # SVN::Node::none and SVN::Node::file are used only once, # so we're shutting up Perl's warnings about them. - if ($t == $SVN::Node::none) { + if ($t == $SVN::Node::none || defined($deletions->{$full_path})) { return $self->add_directory($full_path, $baton, undef, -1, $self->{pool}); } elsif ($t == $SVN::Node::dir) { @@ -5161,17 +5161,18 @@ sub open_or_add_dir { } sub ensure_path { - my ($self, $path) = @_; + my ($self, $path, $deletions) = @_; my $bat = $self->{bat}; my $repo_path = $self->repo_path($path); return $bat->{''} unless (length $repo_path); + my @p = split m#/+#, $repo_path; my $c = shift @p; - $bat->{$c} ||= $self->open_or_add_dir($c, $bat->{''}); + $bat->{$c} ||= $self->open_or_add_dir($c, $bat->{''}, $deletions); while (@p) { my $c0 = $c; $c .= '/' . shift @p; - $bat->{$c} ||= $self->open_or_add_dir($c, $bat->{$c0}); + $bat->{$c} ||= $self->open_or_add_dir($c, $bat->{$c0}, $deletions); } return $bat->{$c}; } @@ -5228,9 +5229,9 @@ sub apply_autoprops { } sub A { - my ($self, $m) = @_; + my ($self, $m, $deletions) = @_; my ($dir, $file) = split_path($m->{file_b}); - my $pbat = $self->ensure_path($dir); + my $pbat = $self->ensure_path($dir, $deletions); my $fbat = $self->add_file($self->repo_path($m->{file_b}), $pbat, undef, -1); print "\tA\t$m->{file_b}\n" unless $::_q; @@ -5240,9 +5241,9 @@ sub A { } sub C { - my ($self, $m) = @_; + my ($self, $m, $deletions) = @_; my ($dir, $file) = split_path($m->{file_b}); - my $pbat = $self->ensure_path($dir); + my $pbat = $self->ensure_path($dir, $deletions); my $fbat = $self->add_file($self->repo_path($m->{file_b}), $pbat, $self->url_path($m->{file_a}), $self->{r}); print "\tC\t$m->{file_a} => $m->{file_b}\n" unless $::_q; @@ -5259,9 +5260,9 @@ sub delete_entry { } sub R { - my ($self, $m) = @_; + my ($self, $m, $deletions) = @_; my ($dir, $file) = split_path($m->{file_b}); - my $pbat = $self->ensure_path($dir); + my $pbat = $self->ensure_path($dir, $deletions); my $fbat = $self->add_file($self->repo_path($m->{file_b}), $pbat, $self->url_path($m->{file_a}), $self->{r}); print "\tR\t$m->{file_a} => $m->{file_b}\n" unless $::_q; @@ -5270,14 +5271,14 @@ sub R { $self->close_file($fbat,undef,$self->{pool}); ($dir, $file) = split_path($m->{file_a}); - $pbat = $self->ensure_path($dir); + $pbat = $self->ensure_path($dir, $deletions); $self->delete_entry($m->{file_a}, $pbat); } sub M { - my ($self, $m) = @_; + my ($self, $m, $deletions) = @_; my ($dir, $file) = split_path($m->{file_b}); - my $pbat = $self->ensure_path($dir); + my $pbat = $self->ensure_path($dir, $deletions); my $fbat = $self->open_file($self->repo_path($m->{file_b}), $pbat,$self->{r},$self->{pool}); print "\t$m->{chg}\t$m->{file_b}\n" unless $::_q; @@ -5347,9 +5348,9 @@ sub chg_file { } sub D { - my ($self, $m) = @_; + my ($self, $m, $deletions) = @_; my ($dir, $file) = split_path($m->{file_b}); - my $pbat = $self->ensure_path($dir); + my $pbat = $self->ensure_path($dir, $deletions); print "\tD\t$m->{file_b}\n" unless $::_q; $self->delete_entry($m->{file_b}, $pbat); } @@ -5382,10 +5383,18 @@ sub apply_diff { my ($self) = @_; my $mods = $self->{mods}; my %o = ( D => 0, C => 1, R => 2, A => 3, M => 4, T => 5 ); + my %deletions; + + foreach my $m (@$mods) { + if ($m->{chg} eq "D") { + $deletions{$m->{file_b}} = 1; + } + } + foreach my $m (sort { $o{$a->{chg}} <=> $o{$b->{chg}} } @$mods) { my $f = $m->{chg}; if (defined $o{$f}) { - $self->$f($m); + $self->$f($m, \%deletions); } else { fatal("Invalid change type: $f"); } diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh index b041516a1d..4029f844c4 100755 --- a/t/t9100-git-svn-basic.sh +++ b/t/t9100-git-svn-basic.sh @@ -92,9 +92,11 @@ test_expect_success "$name" ' echo yyy > bar/zzz/yyy && git update-index --add bar/zzz/yyy && git commit -m "$name" && - test_must_fail git svn set-tree --find-copies-harder --rmdir \ - ${remotes_git_svn}..mybranch3' || true - + git svn set-tree --find-copies-harder --rmdir \ + ${remotes_git_svn}..mybranch3 && + svn_cmd up "$SVN_TREE" && + test -d "$SVN_TREE"/bar/zzz && + test -e "$SVN_TREE"/bar/zzz/yyy ' || true name='detect node change from directory to file #2' test_expect_success "$name" ' @@ -134,10 +136,10 @@ test_expect_success "$name" ' test -x "$SVN_TREE"/exec.sh' -name='executable file becomes a symlink to bar/zzz (file)' +name='executable file becomes a symlink to file' test_expect_success "$name" ' rm exec.sh && - ln -s bar/zzz exec.sh && + ln -s file exec.sh && git update-index exec.sh && git commit -m "$name" && git svn set-tree --find-copies-harder --rmdir \ @@ -148,14 +150,14 @@ test_expect_success "$name" ' name='new symlink is added to a file that was also just made executable' test_expect_success "$name" ' - chmod +x bar/zzz && - ln -s bar/zzz exec-2.sh && - git update-index --add bar/zzz exec-2.sh && + chmod +x file && + ln -s file exec-2.sh && + git update-index --add file exec-2.sh && git commit -m "$name" && git svn set-tree --find-copies-harder --rmdir \ ${remotes_git_svn}..mybranch5 && svn_cmd up "$SVN_TREE" && - test -x "$SVN_TREE"/bar/zzz && + test -x "$SVN_TREE"/file && test -h "$SVN_TREE"/exec-2.sh' name='modify a symlink to become a file' @@ -195,14 +197,15 @@ name='check imported tree checksums expected tree checksums' rm -f expected if test_have_prereq UTF8 then - echo tree bf522353586b1b883488f2bc73dab0d9f774b9a9 > expected + echo tree dc68b14b733e4ec85b04ab6f712340edc5dc936e > expected fi cat >> expected <<\EOF -tree 83654bb36f019ae4fe77a0171f81075972087624 -tree 031b8d557afc6fea52894eaebb45bec52f1ba6d1 -tree 0b094cbff17168f24c302e297f55bfac65eb8bd3 -tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e -tree 56a30b966619b863674f5978696f4a3594f2fca9 +tree c3322890dcf74901f32d216f05c5044f670ce632 +tree d3ccd5035feafd17b030c5732e7808cc49122853 +tree d03e1630363d4881e68929d532746b20b0986b83 +tree 149d63cd5878155c846e8c55d7d8487de283f89e +tree 312b76e4f64ce14893aeac8591eb3960b065e247 +tree 149d63cd5878155c846e8c55d7d8487de283f89e tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4 EOF