symref support for import scripts
Fix git import script not to assume that .git/HEAD is a symlink. Signed-off-by: Pavel Roskin <proski@gnu.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Pavel Roskin committed
Nov 16, 2005 at 13:27 UTC
8366a10ab21f22deb7ea4a9dbd02effcd279318c
3 files changed
+13
-8
git-archimport.perl
+1
-2
@@ -410,8 +410,7 @@ foreach my $ps (@psets) {
410
open HEAD, ">$git_dir/refs/heads/$ps->{branch}";
411
print HEAD $commitid;
412
close HEAD;
413
- unlink ("$git_dir/HEAD");
414
- symlink("refs/heads/$ps->{branch}","$git_dir/HEAD");
413
+ system('git-update-ref', 'HEAD', "$ps->{branch}");
414
415
# tag accordingly
416
ptag($ps->{id}, $commitid); # private tag
git-cvsimport.perl
+6
-3
@@ -437,7 +437,11 @@ unless(-d $git_dir) {
437
"Either use the correct '-o branch' option,\n".
438
"or import to a new repository.\n";
439
440
- $last_branch = basename(readlink("$git_dir/HEAD"));
440
+ open(F, "git-symbolic-ref HEAD |") or
441
+ die "Cannot run git-symbolic-ref: $!\n";
442
+ chomp ($last_branch = <F>);
443
+ $last_branch = basename($last_branch);
444
+ close(F);
445
unless($last_branch) {
446
warn "Cannot read the last branch name: $! -- assuming 'master'\n";
447
$last_branch = "master";
@@ -829,8 +833,7 @@ if($orig_branch) {
833
print "DONE; creating $orig_branch branch\n" if $opt_v;
834
system("cp","$git_dir/refs/heads/$opt_o","$git_dir/refs/heads/master")
835
unless -f "$git_dir/refs/heads/master";
832
- unlink("$git_dir/HEAD");
833
- symlink("refs/heads/$orig_branch","$git_dir/HEAD");
836
+ system('git-update-ref', 'HEAD', "$orig_branch");
837
unless ($opt_i) {
838
system('git checkout');
839
die "checkout failed: $?\n" if $?;
git-svnimport.perl
+6
-3
@@ -216,7 +216,11 @@ unless(-d $git_dir) {
216
-f "$git_dir/svn2git"
217
or die "'$git_dir/svn2git' does not exist.\n".
218
"You need that file for incremental imports.\n";
219
- $last_branch = basename(readlink("$git_dir/HEAD"));
219
+ open(F, "git-symbolic-ref HEAD |") or
220
+ die "Cannot run git-symbolic-ref: $!\n";
221
+ chomp ($last_branch = <F>);
222
+ $last_branch = basename($last_branch);
223
+ close(F);
224
unless($last_branch) {
225
warn "Cannot read the last branch name: $! -- assuming 'master'\n";
226
$last_branch = "master";
@@ -766,8 +770,7 @@ if($orig_branch) {
770
print "DONE; creating $orig_branch branch\n" if $opt_v and (not defined $opt_l or $opt_l > 0);
771
system("cp","$git_dir/refs/heads/$opt_o","$git_dir/refs/heads/master")
772
unless -f "$git_dir/refs/heads/master";
769
- unlink("$git_dir/HEAD");
770
- symlink("refs/heads/$orig_branch","$git_dir/HEAD");
773
+ system('git-update-ref', 'HEAD', "$orig_branch");
774
unless ($opt_i) {
775
system('git checkout');
776
die "checkout failed: $?\n" if $?;