Browse Source

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 <normalperson@yhbt.net>
maint
Eric Wong 16 years ago
parent
commit
b186a261b1
  1. 11
      git-svn.perl
  2. 7
      t/t9135-git-svn-moved-branch-empty-file.sh
  3. 25
      t/t9145-git-svn-master-branch.sh

11
git-svn.perl

@ -1156,6 +1156,17 @@ sub post_fetch_checkout { @@ -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'));

7
t/t9135-git-svn-moved-branch-empty-file.sh

@ -10,7 +10,12 @@ test_expect_success 'load svn dumpfile' ' @@ -10,7 +10,12 @@ test_expect_success 'load svn dumpfile' '
test_expect_success 'clone using git svn' 'git svn clone -s "$svnrepo" x'

test_expect_success 'test that b1 exists and is empty' '
(cd x && test -f b1 && ! test -s b1)
(
cd x &&
git reset --hard branch-c &&
test -f b1 &&
! test -s b1
)
'

test_done

25
t/t9145-git-svn-master-branch.sh

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
#!/bin/sh
#
# Copyright (c) 2009 Eric Wong
#
test_description='git svn initial master branch is "trunk" if possible'
. ./lib-git-svn.sh

test_expect_success 'setup test repository' '
mkdir i &&
> i/a &&
svn_cmd import -m trunk i "$svnrepo/trunk" &&
svn_cmd import -m b/a i "$svnrepo/branches/a" &&
svn_cmd import -m b/b i "$svnrepo/branches/b"
'

test_expect_success 'git svn clone --stdlayout sets up trunk as master' '
git svn clone -s "$svnrepo" g &&
(
cd g &&
test x`git rev-parse --verify refs/remotes/trunk^0` = \
x`git rev-parse --verify refs/heads/master^0`
)
'

test_done
Loading…
Cancel
Save