git-svn: several house-keeping fixes
cover git-svn: several house-keeping fixes
[PATCH 1/3] git-svn: cleanup: factor out longest_common_path() function
- readability
[PATCH 2/3] git-svn: test for creating new directories over svn://
- The bug is already long fixed, but I'd like to add it for documentation/regression testing purposes in case it breaks again.
[PATCH 3/3] git-svn: reduce stat() calls for a backwards compatibility check
- There's actually a small bugfix in there, too. This should go to maint.
Signature · 1 line
Eric Wong
PATCH 1/3 git-svn: cleanup: factor out longest_common_path() function
I hadn't looked at this code in a while and had to read this again to figure out what it did. To avoid having to do this again in the future, I just gave gave the hunk a descriptive name.
--- git-svn.perl | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-)
git-svn.perl +11 -5
@@ -3072,11 +3072,8 @@ sub gs_do_switch { $editor->{git_commit_ok}; } -sub gs_fetch_loop_common { - my ($self, $base, $head, $gsv, $globs) = @_; - return if ($base > $head); - my $inc = $_log_window_size; - my ($min, $max) = ($base, $head < $base + $inc ? $head : $base + $inc); +sub longest_common_path { + my ($gsv, $globs) = @_; my %common; my $common_max = scalar @$gsv;
@@ -3108,6 +3105,15 @@ sub gs_fetch_loop_common { last; } } + $longest_path; +} + +sub gs_fetch_loop_common { + my ($self, $base, $head, $gsv, $globs) = @_; + return if ($base > $head); + my $inc = $_log_window_size; + my ($min, $max) = ($base, $head < $base + $inc ? $head : $base + $inc); + my $longest_path = longest_common_path($gsv, $globs); while (1) { my %revs; my $err;
Signature · 1 line
1.5.2.1.243.gbe00
PATCH 2/3 git-svn: test for creating new directories over svn://
In reply to Eric WongAs reported by Matthieu Moy, this is causing svnserve to terminate connections (because it segfaults) segfault.
This test is disabled by default and can be enabled by setting SVNSERVE_PORT to an unbound (for 127.0.0.1) TCP port in the environment (in addition to SVN_TESTS=1). I'm not comfortable with having a test start a daemon by default and take up a port that could potentially stay running if the test failed.
--- t/t9113-git-svn-dcommit-new-file.sh | 40 +++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-) create mode 100755 t/t9113-git-svn-dcommit-new-file.sh
t/t9113-git-svn-dcommit-new-file.sh new file +40 -0
@@ -0,0 +1,40 @@ +#!/bin/sh +# +# Copyright (c) 2007 Eric Wong +# + +# Don't run this test by default unless the user really wants it +# I don't like the idea of taking a port and possibly leaving a +# daemon running on a users system if the test fails. +# Not all git users will need to interact with SVN. +test -z "$SVNSERVE_PORT" && exit 0 + +test_description='git-svn dcommit new files over svn:// test' + +. ./lib-git-svn.sh + +start_svnserve () { + svnserve --listen-port $SVNSERVE_PORT \ + --root $rawsvnrepo \ + --listen-once \ + --listen-host 127.0.0.1 & +} + +test_expect_success 'start tracking an empty repo' " + svn mkdir -m 'empty dir' $svnrepo/empty-dir && + echo anon-access = write >> $rawsvnrepo/conf/svnserve.conf && + start_svnserve && + git svn init svn://127.0.0.1:$SVNSERVE_PORT && + git svn fetch + " + +test_expect_success 'create files in new directory with dcommit' " + mkdir git-new-dir && + echo hello > git-new-dir/world && + git update-index --add git-new-dir/world && + git commit -m hello && + start_svnserve && + git svn dcommit + " + +test_done
Signature · 1 line
1.5.2.1.243.gbe00
PATCH 3/3 git-svn: reduce stat() calls for a backwards compatibility check
In reply to Eric WongAlso, this fixes a bug where in an odd case a remote named "config" could get renamed to ".metadata".
--- git-svn.perl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
git-svn.perl +1 -1
@@ -1457,7 +1457,7 @@ sub tmp_config { my (@args) = @_; my $old_def_config = "$ENV{GIT_DIR}/svn/config"; my $config = "$ENV{GIT_DIR}/svn/.metadata"; - if (-e $old_def_config && ! -e $config) { + if (! -f $config && -f $old_def_config) { rename $old_def_config, $config or die "Failed rename $old_def_config => $config: $!\n"; }
Signature · 1 line
1.5.2.1.243.gbe00