git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git-cvsimport does not like detached HEAD

From
Junio C Hamano <junkio@cox.net>
Date
Apr 3, 2007, 08:23 UTC
Message-ID
<7vmz1pzx12.fsf@assigned-by-dhcp.cox.net>

In my day-job project, I use git-cvsimport with -i option to treat the central CVS repository as if it is just a branch in a remote git repository. Since I hoard many changes in my git repository and trickle only a few changes at a time to the central CVS back, I keep shuffling and rebasing my commits on top of what I obtain from CVS, and many times, my HEAD is detached and not on a particular branch.

However, it seems git-cvsimport does not like to work when your HEAD is detached.

Here is a minimum patch that seems to let me going, but I am not quite sure what the implication is for letting orig_branch (and last_branch) to default to "master" (I do not use "master" branch for that project so maybe I am getting lucky).

---
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index 1a1ba7b..a64219f 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -563,8 +563,11 @@ 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);
+	$last_branch = <F>;
+	if (defined $last_branch) {
+		chomp($last_branch);
+		$last_branch = basename($last_branch);
+	}
 	close(F);
 	unless ($last_branch) {
 		warn "Cannot read the last branch name: $! -- assuming 'master'\n";
Next: Martin Langhoff
Message 1 of 2 in “git-cvsimport does not like detached HEAD”
  1. Junio C HamanoApr 3, 2007
  2. Martin LanghoffApr 4, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.