[PATCH 1/2] git-svn: Add test for git-svn repositories with a gitdir link

2013-01-20 Thread Barry Wardell
Signed-off-by: Barry Wardell 
---
 t/t9100-git-svn-basic.sh | 8 
 1 file changed, 8 insertions(+)

diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh
index 749b75e..4fea8d9 100755
--- a/t/t9100-git-svn-basic.sh
+++ b/t/t9100-git-svn-basic.sh
@@ -306,5 +306,13 @@ test_expect_success 'git-svn works in a bare repository' '
git svn fetch ) &&
rm -rf bare-repo
'
+test_expect_success 'git-svn works in in a repository with a gitdir: link' '
+   mkdir worktree gitdir &&
+   ( cd worktree &&
+   git svn init "$svnrepo" &&
+   git init --separate-git-dir ../gitdir &&
+   git svn fetch ) &&
+   rm -rf worktree gitdir
+   '
 
 test_done
-- 
1.8.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] git-svn: Simplify calculation of GIT_DIR

2013-01-20 Thread Barry Wardell
Since git-rev-parse already checks for the $GIT_DIR environment
variable and that it returns an actual git repository, there is no
need to repeat the checks again here.

This also fixes a problem where git-svn did not work in cases where
.git was a file with a gitdir: link.

Signed-off-by: Barry Wardell 
---
 git-svn.perl | 36 +---
 1 file changed, 13 insertions(+), 23 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index bd5266c..3bcd769 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -61,8 +61,6 @@ my $cmd_dir_prefix = eval {
command_oneline([qw/rev-parse --show-prefix/], STDERR => 0)
 } || '';
 
-my $git_dir_user_set = 1 if defined $ENV{GIT_DIR};
-$ENV{GIT_DIR} ||= '.git';
 $Git::SVN::Ra::_log_window_size = 100;
 
 if (! exists $ENV{SVN_SSH} && exists $ENV{GIT_SSH}) {
@@ -325,27 +323,19 @@ for (my $i = 0; $i < @ARGV; $i++) {
 };
 
 # make sure we're always running at the top-level working directory
-unless ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
-   unless (-d $ENV{GIT_DIR}) {
-   if ($git_dir_user_set) {
-   die "GIT_DIR=$ENV{GIT_DIR} explicitly set, ",
-   "but it is not a directory\n";
-   }
-   my $git_dir = delete $ENV{GIT_DIR};
-   my $cdup = undef;
-   git_cmd_try {
-   $cdup = command_oneline(qw/rev-parse --show-cdup/);
-   $git_dir = '.' unless ($cdup);
-   chomp $cdup if ($cdup);
-   $cdup = "." unless ($cdup && length $cdup);
-   } "Already at toplevel, but $git_dir not found\n";
-   chdir $cdup or die "Unable to chdir up to '$cdup'\n";
-   unless (-d $git_dir) {
-   die "$git_dir still not found after going to ",
-   "'$cdup'\n";
-   }
-   $ENV{GIT_DIR} = $git_dir;
-   }
+if ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
+   $ENV{GIT_DIR} ||= ".git";
+} else {
+   git_cmd_try {
+   $ENV{GIT_DIR} = command_oneline([qw/rev-parse --git-dir/]);
+   } "Unable to find .git directory\n";
+   my $cdup = undef;
+   git_cmd_try {
+   $cdup = command_oneline(qw/rev-parse --show-cdup/);
+   chomp $cdup if ($cdup);
+   $cdup = "." unless ($cdup && length $cdup);
+   } "Already at toplevel, but $ENV{GIT_DIR} not found\n";
+   chdir $cdup or die "Unable to chdir up to '$cdup'\n";
$_repository = Git->repository(Repository => $ENV{GIT_DIR});
 }
 
-- 
1.8.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 0/2] Make git-svn work with gitdir links

2013-01-20 Thread Barry Wardell
These patches fix a bug which prevented git-svn from working with repositories
which use gitdir links.

Changes since v2:
 - Rebased onto latest master.
 - Added test case which verifies that the problem has been fixed.
 - Fixed problems with git svn (init|clone|multi-init).
 - All git-svn test cases now pass (except two in t9101 which also failed
   before these patches).

Barry Wardell (2):
  git-svn: Add test for git-svn repositories with a gitdir link
  git-svn: Simplify calculation of GIT_DIR

 git-svn.perl | 36 +---
 t/t9100-git-svn-basic.sh |  8 
 2 files changed, 21 insertions(+), 23 deletions(-)

-- 
1.8.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 0/2] Make git-svn work with gitdir links

2013-01-23 Thread Barry Wardell
On Wed, Jan 23, 2013 at 2:32 AM, Eric Wong  wrote:
>
> Barry Wardell  wrote:
> > These patches fix a bug which prevented git-svn from working with 
> > repositories
> > which use gitdir links.
> >
> > Changes since v2:
> >  - Rebased onto latest master.
> >  - Added test case which verifies that the problem has been fixed.
> >  - Fixed problems with git svn (init|clone|multi-init).
> >  - All git-svn test cases now pass (except two in t9101 which also failed
> >before these patches).
>
> t9101 did not fail for me before your patches.  However I have a
> patch on top of your 2/2 which should fix things.
>
> `git rev-parse --show-cdup` outputs nothing if GIT_DIR is set,
> so I unset GIT_DIR temporarily.
>
> I'm not sure why --show-cdup behaves like this, though..
>
> Does squashing this on top of your changes fix all your failures?
> I plan on squashing both your changes together with the below:
>
> diff --git a/git-svn.perl b/git-svn.perl
> index c232798..e5bd292 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -332,11 +332,13 @@ if ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
> $ENV{GIT_DIR} = command_oneline([qw/rev-parse --git-dir/]);
> } "Unable to find .git directory\n";
> my $cdup = undef;
> +   my $git_dir = delete $ENV{GIT_DIR};
> git_cmd_try {
> $cdup = command_oneline(qw/rev-parse --show-cdup/);
> chomp $cdup if ($cdup);
> $cdup = "." unless ($cdup && length $cdup);
> -   } "Already at toplevel, but $ENV{GIT_DIR} not found\n";
> +   } "Already at toplevel, but $git_dir not found\n";
> +   $ENV{GIT_DIR} = $git_dir;
> chdir $cdup or die "Unable to chdir up to '$cdup'\n";
> $_repository = Git->repository(Repository => $ENV{GIT_DIR});
>  }


Yes, I can confirm that applying this patch on top of mine makes all
git-svn tests pass again. I have also re-run the tests without my
patch applied and found that they do all indeed pass, so I apologize
for my previous incorrect comment.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html