summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 488a63e)
raw | patch | inline | side by side (parent: 488a63e)
author | Eric Wong <normalperson@yhbt.net> | |
Fri, 16 Feb 2007 09:45:13 +0000 (01:45 -0800) | ||
committer | Eric Wong <normalperson@yhbt.net> | |
Fri, 23 Feb 2007 08:57:13 +0000 (00:57 -0800) |
On newly-created repositories, 'refs/heads/master' does not
point to anything. This can be confusing to new users; so we
update 'master' to point to the last imported ref after fetching
is done.
Once 'master' is valid; we assume HEAD points to it; and if
the repository is not bare, then checkout the files if the
working tree is clean and unused.
Signed-off-by: Eric Wong <normalperson@yhbt.net>
point to anything. This can be confusing to new users; so we
update 'master' to point to the last imported ref after fetching
is done.
Once 'master' is valid; we assume HEAD points to it; and if
the repository is not bare, then checkout the files if the
working tree is clean and unused.
Signed-off-by: Eric Wong <normalperson@yhbt.net>
git-svn.perl | patch | blob | history |
diff --git a/git-svn.perl b/git-svn.perl
index 2152bf3de8a5205029926996e7174466ebd499ed..7ffbf641392f398743337d602696c328cec80b79 100755 (executable)
--- a/git-svn.perl
+++ b/git-svn.perl
$_template, $_shared,
$_version, $_fetch_all,
$_merge, $_strategy, $_dry_run,
- $_prefix);
+ $_prefix, $_no_checkout);
$Git::SVN::_follow_parent = 1;
my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
'config-dir=s' => \$Git::SVN::Ra::config_dir,
'noMetadata' => \$Git::SVN::_no_metadata,
'useSvmProps' => \$Git::SVN::_use_svm_props,
'log-window-size=i' => \$Git::SVN::Ra::_log_window_size,
+ 'no-checkout' => \$_no_checkout,
'quiet|q' => \$_q,
'repack-flags|repack-args|repack-opts=s' =>
\$Git::SVN::_repack_flags,
$cmd{$cmd}->[0]->(@ARGV);
};
fatal $@ if $@;
+post_fetch_checkout();
exit 0;
####################### primary functions ######################
########################### utility functions #########################
+sub post_fetch_checkout {
+ return if $_no_checkout;
+ my $gs = $Git::SVN::_head or return;
+ return if verify_ref('refs/heads/master^0');
+
+ 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'));
+
+ return if $ENV{GIT_DIR} !~ m#^(?:.*/)?\.git$#;
+ my $index = $ENV{GIT_INDEX_FILE} || "$ENV{GIT_DIR}/index";
+ return if -f $index;
+
+ chomp(my $bare = `git config --bool --get core.bare`);
+ return if $bare eq 'true';
+ return if command_oneline(qw/rev-parse --is-inside-git-dir/) eq 'true';
+ command_noisy(qw/read-tree -m -u -v HEAD HEAD/);
+ print STDERR "Checked out HEAD:\n ",
+ $gs->full_url, " r", $gs->last_rev, "\n";
+}
+
sub complete_svn_url {
my ($url, $path) = @_;
$path =~ s#/+$##;
use strict;
use warnings;
use vars qw/$default_repo_id $default_ref_id $_no_metadata $_follow_parent
- $_repack $_repack_flags $_use_svm_props/;
+ $_repack $_repack_flags $_use_svm_props $_head/;
use Carp qw/croak/;
use File::Path qw/mkpath/;
use File::Copy qw/copy/;
}
close $fh or croak $!;
if ($update_ref) {
+ $_head = $self;
command_noisy('update-ref', '-m', "r$rev",
$self->refname, $commit);
}