git-cvsimport does not like detached HEAD

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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";

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]