# cvsimport and branches with "(" in the name

4 messages from 2008-04-29 to 2008-04-30. Participants: Nigel Magnay, Jeff King, Morten Welinder.
Thread: https://gitlist.dev/t/13315

## Nigel Magnay, 2008-04-29 07:22

Subject: cvsimport and branches with "(" in the name
Message-ID: <320075ff0804290022r56c9f4efx74a13d3502be212@mail.gmail.com>
URL: https://gitlist.dev/e/320075ff0804290022r56c9f4efx74a13d3502be212%40mail.gmail.com

```
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, 2008-04-29 15:52

Subject: Re: cvsimport and branches with "(" in the name
Message-ID: <20080429155238.GA18494@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20080429155238.GA18494%40sigill.intra.peff.net
In-Reply-To: <320075ff0804290022r56c9f4efx74a13d3502be212@mail.gmail.com>

```
On Tue, Apr 29, 2008 at 08:22:02AM +0100, Nigel Magnay wrote:

> 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, 2008-04-30 00:45

Subject: Re: cvsimport and branches with "(" in the name
Message-ID: <118833cc0804291745m2da2a3bdl21a9440e961afb6@mail.gmail.com>
URL: https://gitlist.dev/e/118833cc0804291745m2da2a3bdl21a9440e961afb6%40mail.gmail.com
In-Reply-To: <20080429155238.GA18494@sigill.intra.peff.net>

```
>  -       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, 2008-04-30 03:31

Subject: Re: cvsimport and branches with "(" in the name
Message-ID: <20080430033146.GA28373@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20080430033146.GA28373%40sigill.intra.peff.net
In-Reply-To: <118833cc0804291745m2da2a3bdl21a9440e961afb6@mail.gmail.com>

```
On Tue, Apr 29, 2008 at 08:45:42PM -0400, Morten Welinder wrote:

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

```
