git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-cvsimport: fix initial checkout
@ 2008-03-13 19:09 Marc-Andre Lureau
  2008-03-13 21:05 ` Junio C Hamano
  2008-03-13 22:18 ` Martin Langhoff
  0 siblings, 2 replies; 9+ messages in thread
From: Marc-Andre Lureau @ 2008-03-13 19:09 UTC (permalink / raw)
  To: git; +Cc: Martin Langhoff, Marc-Andre Lureau

git-symbolic-ref HEAD returns master reference, even if the file does
not exists. That prevents the initial checkout and fails in
git-rev-parse. The patch checks the existence of the reference file
before assuming an original branch exists. There might be better
solutions than checking file existence.
---
 git-cvsimport.perl |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index 95c5eec..1512fe4 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -570,12 +570,16 @@ unless (-d $git_dir) {
 	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) {
+	if (-f "$git_dir/$last_branch") {
+	    $last_branch = basename($last_branch);
+	    unless ($last_branch) {
 		warn "Cannot read the last branch name: $! -- assuming 'master'\n";
 		$last_branch = "master";
+	    }
+	} else {
+	    $last_branch = "";
 	}
+	close(F);
 	$orig_branch = $last_branch;
 	$tip_at_start = `git-rev-parse --verify HEAD`;
 
@@ -953,6 +957,7 @@ while (<CVS>) {
 		print "* UNKNOWN LINE * $_\n";
 	}
 }
+
 commit() if $branch and $state != 11;
 
 unless ($opt_P) {
-- 
1.5.4.4.534.gfb90c.dirty

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-03-13 23:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-13 19:09 [PATCH] git-cvsimport: fix initial checkout Marc-Andre Lureau
2008-03-13 21:05 ` Junio C Hamano
2008-03-13 22:18 ` Martin Langhoff
2008-03-13 23:04   ` Marc-André Lureau
2008-03-13 23:07     ` Marc-André Lureau
2008-03-13 23:29     ` Martin Langhoff
2008-03-13 23:15   ` Junio C Hamano
2008-03-13 23:27     ` Martin Langhoff
2008-03-13 23:22   ` Marc-André Lureau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).