# [PATCH] Git::SVN: handle missing ref_id case correctly

5 messages from 2015-01-10 to 2015-01-10. Participants: Ramkumar Ramachandra, Eric Wong.
Thread: https://gitlist.dev/t/38330

## Ramkumar Ramachandra, 2015-01-10 14:35

Subject: [PATCH] Git::SVN: handle missing ref_id case correctly
Message-ID: <1420900510-78522-1-git-send-email-artagnon@gmail.com>
URL: https://gitlist.dev/e/1420900510-78522-1-git-send-email-artagnon%40gmail.com

```
$ENV{GIT_SVN_ID} will return a string, so check it with defined. Also,
ref_id should not match "refs/remotes/".

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 perl/Git/SVN.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/perl/Git/SVN.pm b/perl/Git/SVN.pm
index d9a52a5..06ff216 100644
--- a/perl/Git/SVN.pm
+++ b/perl/Git/SVN.pm
@@ -40,7 +40,7 @@ BEGIN {
 our $_follow_parent  = 1;
 our $_minimize_url   = 'unset';
 our $default_repo_id = 'svn';
-our $default_ref_id  = $ENV{GIT_SVN_ID} || 'git-svn';
+our $default_ref_id  = defined $ENV{GIT_SVN_ID} ? $ENV{GIT_SVN_ID} : 'git-svn';
 
 my ($_gc_nr, $_gc_period);
 
@@ -2365,7 +2365,7 @@ sub _new {
 
 	# 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/(.*)}) {
+	if ($ref_id =~ m{^refs/remotes/(.+)}) {
 		my $old_dir = "$ENV{GIT_DIR}/svn/$1";
 		if (-d $old_dir && ! -d $dir) {
 			$dir = $old_dir;
-- 
2.2.1

```

## Ramkumar Ramachandra, 2015-01-10 15:12

Subject: Re: [PATCH] Git::SVN: handle missing ref_id case correctly
Message-ID: <CALkWK0=jEh06hZSmHim54BaP_KiC8hg-455STQphu17PSoQTqw@mail.gmail.com>
URL: https://gitlist.dev/e/CALkWK0%3DjEh06hZSmHim54BaP_KiC8hg-455STQphu17PSoQTqw%40mail.gmail.com
In-Reply-To: <1420900510-78522-1-git-send-email-artagnon@gmail.com>

```
Ramkumar Ramachandra wrote:
> -our $default_ref_id  = $ENV{GIT_SVN_ID} || 'git-svn';
> +our $default_ref_id  = defined $ENV{GIT_SVN_ID} ? $ENV{GIT_SVN_ID} : 'git-svn';

This is probably not a functional change; please look at the second hunk.

```

## Eric Wong, 2015-01-10 22:13

Subject: Re: [PATCH] Git::SVN: handle missing ref_id case correctly
Message-ID: <20150110221308.GA32253@dcvr.yhbt.net>
URL: https://gitlist.dev/e/20150110221308.GA32253%40dcvr.yhbt.net
In-Reply-To: <CALkWK0=jEh06hZSmHim54BaP_KiC8hg-455STQphu17PSoQTqw@mail.gmail.com>

```
Ramkumar Ramachandra <artagnon@gmail.com> wrote:
> Ramkumar Ramachandra wrote:
> > -our $default_ref_id  = $ENV{GIT_SVN_ID} || 'git-svn';
> > +our $default_ref_id  = defined $ENV{GIT_SVN_ID} ? $ENV{GIT_SVN_ID} : 'git-svn';
> 
> This is probably not a functional change; please look at the second hunk.

It is functional, maybe someone will use GIT_SVN_ID=0 ?

```

## Ramkumar Ramachandra, 2015-01-10 22:14

Subject: Re: [PATCH] Git::SVN: handle missing ref_id case correctly
Message-ID: <CALkWK0mXx5qQSNSC4ju8Bejy_XhewxDA+nwy1JCmodX3t-H+3A@mail.gmail.com>
URL: https://gitlist.dev/e/CALkWK0mXx5qQSNSC4ju8Bejy_XhewxDA%2Bnwy1JCmodX3t-H%2B3A%40mail.gmail.com
In-Reply-To: <20150110221308.GA32253@dcvr.yhbt.net>

```
Eric Wong wrote:
> It is functional, maybe someone will use GIT_SVN_ID=0 ?

Right. Kindly drop the first hunk.

```

## Ramkumar Ramachandra, 2015-01-10 22:18

Subject: Re: [PATCH] Git::SVN: handle missing ref_id case correctly
Message-ID: <CALkWK0mQCe_gUZCCnoZyNPCp=cubQcPAOSqAN0pzMA5eyYUdAQ@mail.gmail.com>
URL: https://gitlist.dev/e/CALkWK0mQCe_gUZCCnoZyNPCp%3DcubQcPAOSqAN0pzMA5eyYUdAQ%40mail.gmail.com
In-Reply-To: <CALkWK0mXx5qQSNSC4ju8Bejy_XhewxDA+nwy1JCmodX3t-H+3A@mail.gmail.com>

```
Ramkumar Ramachandra wrote:
>> It is functional, maybe someone will use GIT_SVN_ID=0 ?
>
> Right. Kindly drop the first hunk.

Amendment: there are actually many other places where variables are
checked without "defined", so I doubt we want to put up with the extra
ugliness to allow "0".

```
