threads / discuss / 13315

cvsimport and branches with "(" in the name

Subject: cvsimport and branches with "(" in the name

## tl;dr

4 messages between Apr 29, 2008 and Apr 30, 2008.

replies: 3people: 3as markdown or json

Nigel Magnay· Apr 29, 2008, 07:22 UTC · lore

git 1.5.4.4 on ubuntu, I cvsimport a repository that has an oddly named branch - I get

sh: Syntax error: "(" unexpected Cannot write branch ChapelHill_3_0(iteration2)_esap_demo for update: Bad file descriptor

though the end of my -v log shows

Tree ID 46f13621661205b02a80d7d431a2c59be500ae45 Parent ID d635ccf06e1cac3afacc4fba6e70bba7f771ead2 Committed patch 1956 (ChapelHill_3_0(iteration2)_esap_demo +0000 2006-12-04 10:28:31) Commit ID 76c991af0c690d9ae5471c0b661dfba3b3df18c6

and refs/heads has a correctly named file

My guess is something in the guts isn't liking the ( character, when committing the next patch.

Any ideas on how to diagnose / fix it further ?
Jeff King· Apr 29, 2008, 15:52 UTC · re: Nigel Magnay · lore

Re: cvsimport and branches with "(" in the name

On Tue, Apr 29, 2008 at 08:22:02AM +0100, Nigel Magnay wrote:
Show 6 quoted lines
> git 1.5.4.4 on ubuntu, I cvsimport a repository that has an oddly
> named branch - I get
> 
> sh: Syntax error: "(" unexpected
> Cannot write branch ChapelHill_3_0(iteration2)_esap_demo for update:
> Bad file descriptor

Looks like cvsimport is handing something as an argument to a git command, but we accidentally involve the shell. Maybe here:

diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index 95c5eec..bdac5d5 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -772,7 +772,7 @@ sub commit {
 	waitpid($pid,0);
 	die "Error running git-commit-tree: $?\n" if $?;
 
-	system("git-update-ref $remote/$branch $cid") == 0
+	system('git-update-ref', "$remote/$branch", $cid) == 0
 		or die "Cannot write branch $branch for update: $!\n";
 
 	if ($tag) {

Does that fix it?

> Any ideas on how to diagnose / fix it further ?

If that doesn't work, you might try running with GIT_TRACE=1, and then
you can see which commands are being run when the error occurs.

-Peff
Morten Welinder· Apr 30, 2008, 00:45 UTC · re: Jeff King · lore

Re: cvsimport and branches with "(" in the name

>  -       system("git-update-ref $remote/$branch $cid") == 0
>  +       system('git-update-ref', "$remote/$branch", $cid) == 0

I hope there are no further such system calls left. This could run arbitrary commands if one was tricked into importing an evil repository.

Morten
Jeff King· Apr 30, 2008, 03:31 UTC · re: Morten Welinder · lore

Re: cvsimport and branches with "(" in the name

On Tue, Apr 29, 2008 at 08:45:42PM -0400, Morten Welinder wrote:
Show 5 quoted lines
> >  -       system("git-update-ref $remote/$branch $cid") == 0
> >  +       system('git-update-ref', "$remote/$branch", $cid) == 0
> 
> I hope there are no further such system calls left.  This could run arbitrary
> commands if one was tricked into importing an evil repository.

Yes, even if that doesn't fix his problem, it should still be changed. I have confirmed that it's the only such one in git-cvsimport.

-Peff

← back to recent threads