From: Sven Verdoolaege Date: Tue, 16 Aug 2005 11:07:25 GMT Subject: Re: [PATCH] Add merge detection to git-cvsimport Message-ID: <20050816110725.GL11882MdfPADPa@garage.linux.student.kuleuven.ac.be> In-Reply-To: <20050816103527.F420A33010C@ng.eduforge.org> On Tue, Aug 16, 2005 at 10:35:27PM +1200, Martin Langhoff wrote: > + > +sub get_headref($$) { If you want to check whether a ref is valid, then it is better to use git-rev-parse... > + my $name = shift; > + my $git_dir = shift; > + my $sha; > + > + if (open(C,"$git_dir/refs/heads/$name")) { > + chomp($sha = ); > + close(C); > + length($sha) == 40 > + or die "Cannot get head id for $name ($sha): $!\n"; ... but if you're just going to die, then why not simply let git-commit-tree do the test ? > + if ($mparent eq 'HEAD') { $mparent = 'origin'}; Please don't hardcode 'origin' here. skimo