Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH] git-cvsimport: fix initial checkout

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:44:22

Marc-Andre Lureau [off-list ref] writes:
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.
I had an impression that this check was deliberately done, but I do not
recall the details.  Martin?
quoted hunk
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";
+	    }
In any case, what if last_branch is a branch with hierarchical name, I
have to wonder.  If you are on a branch whose name has a slash
in it, like "frotz/nitfol" when you start cvsimport, doesn't this (before
or after the patch) code break your repository?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help