From: Junio C Hamano Date: Mon, 25 Jun 2012 05:47:04 GMT Subject: Re: [PATCH/RFC] git-svn: don't create master if another head exists Message-ID: <7v4nq0hrjb.fsf@alter.siamese.dyndns.org> In-Reply-To: <20120624220835.GA4762@beczulka> Marcin Owsiany writes: > diff --git a/git-svn.perl b/git-svn.perl > index 0b074c4..90f3d06 100755 > --- a/git-svn.perl > +++ b/git-svn.perl > @@ -1613,6 +1613,8 @@ sub post_fetch_checkout { > } > > my $valid_head = verify_ref('HEAD^0'); > + my @heads_commits = eval { command(qw(show-ref --heads --hash)) }; > + return if $valid_head and grep { $_ eq $valid_head } @heads_commits; > command_noisy(qw(update-ref refs/heads/master), $gs->refname); > return if ($valid_head || !verify_ref('HEAD^0')); This looks like a typical XY solution. What are you really trying to validate? "HEAD" points at an existing branch and you do not care what branch it is? HEAD may not even point at a valid branch but can be detached as long as it happens to point at a commit that is at the tip of some branch (hence building further commit on HEAD will break the condition you are checking in the above code)?