All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Roskin <proski@gnu.org>
To: git <git@vger.kernel.org>
Subject: [PATCH] symref support for import scripts
Date: Wed, 16 Nov 2005 13:27:28 -0500	[thread overview]
Message-ID: <1132165648.4024.6.camel@dv> (raw)

Fix git import script not to assume that .git/HEAD is a symlink.

Signed-off-by: Pavel Roskin <proski@gnu.org>

diff --git a/git-archimport.perl b/git-archimport.perl
index e22c816..23becb7 100755
--- a/git-archimport.perl
+++ b/git-archimport.perl
@@ -410,8 +410,7 @@ foreach my $ps (@psets) {
     open  HEAD, ">$git_dir/refs/heads/$ps->{branch}";
     print HEAD $commitid;
     close HEAD;
-    unlink ("$git_dir/HEAD");
-    symlink("refs/heads/$ps->{branch}","$git_dir/HEAD");
+    system('git-update-ref', 'HEAD', "$ps->{branch}");
 
     # tag accordingly
     ptag($ps->{id}, $commitid); # private tag
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index 7bd9136..efe1934 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -437,7 +437,11 @@ unless(-d $git_dir) {
 		       "Either use the correct '-o branch' option,\n".
 		       "or import to a new repository.\n";
 
-	$last_branch = basename(readlink("$git_dir/HEAD"));
+	open(F, "git-symbolic-ref HEAD |") or
+		die "Cannot run git-symbolic-ref: $!\n";
+	chomp ($last_branch = <F>);
+	$last_branch = basename($last_branch);
+	close(F);
 	unless($last_branch) {
 		warn "Cannot read the last branch name: $! -- assuming 'master'\n";
 		$last_branch = "master";
@@ -829,8 +833,7 @@ if($orig_branch) {
 	print "DONE; creating $orig_branch branch\n" if $opt_v;
 	system("cp","$git_dir/refs/heads/$opt_o","$git_dir/refs/heads/master")
 		unless -f "$git_dir/refs/heads/master";
-	unlink("$git_dir/HEAD");
-	symlink("refs/heads/$orig_branch","$git_dir/HEAD");
+	system('git-update-ref', 'HEAD', "$orig_branch");
 	unless ($opt_i) {
 		system('git checkout');
 		die "checkout failed: $?\n" if $?;
diff --git a/git-svnimport.perl b/git-svnimport.perl
index af13fdd..45d77c5 100755
--- a/git-svnimport.perl
+++ b/git-svnimport.perl
@@ -216,7 +216,11 @@ unless(-d $git_dir) {
 	-f "$git_dir/svn2git"
 		or die "'$git_dir/svn2git' does not exist.\n".
 		       "You need that file for incremental imports.\n";
-	$last_branch = basename(readlink("$git_dir/HEAD"));
+	open(F, "git-symbolic-ref HEAD |") or
+		die "Cannot run git-symbolic-ref: $!\n";
+	chomp ($last_branch = <F>);
+	$last_branch = basename($last_branch);
+	close(F);
 	unless($last_branch) {
 		warn "Cannot read the last branch name: $! -- assuming 'master'\n";
 		$last_branch = "master";
@@ -766,8 +770,7 @@ if($orig_branch) {
 	print "DONE; creating $orig_branch branch\n" if $opt_v and (not defined $opt_l or $opt_l > 0);
 	system("cp","$git_dir/refs/heads/$opt_o","$git_dir/refs/heads/master")
 		unless -f "$git_dir/refs/heads/master";
-	unlink("$git_dir/HEAD");
-	symlink("refs/heads/$orig_branch","$git_dir/HEAD");
+	system('git-update-ref', 'HEAD', "$orig_branch");
 	unless ($opt_i) {
 		system('git checkout');
 		die "checkout failed: $?\n" if $?;


-- 
Regards,
Pavel Roskin

             reply	other threads:[~2005-11-16 18:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-16 18:27 Pavel Roskin [this message]
2005-11-16 19:43 ` [PATCH] symref support for import scripts Junio C Hamano
2005-11-16 19:57   ` Matthias Urlichs
2005-11-16 20:26     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1132165648.4024.6.camel@dv \
    --to=proski@gnu.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.