git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Eric Wong <normalperson@yhbt.net>
Cc: Junio C Hamano <junkio@cox.net>, git@vger.kernel.org
Subject: Re: [PATCH] cvsimport: use git-update-ref when updating
Date: Fri, 31 Mar 2006 13:14:45 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.63.0603311310580.23287@wbgn013.biozentrum.uni-wuerzburg.de> (raw)
In-Reply-To: <20060331103230.GB15159@hand.yhbt.net>

Hi,

On Fri, 31 Mar 2006, Eric Wong wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > Hi,
> > 
> > On Thu, 30 Mar 2006, Junio C Hamano wrote:
> > 
> > > Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> > > 
> > > > This simplifies code, and also fixes a subtle bug: when importing in a
> > > > shared repository, where another user last imported from CVS, cvsimport
> > > > used to complain that it could not open <branch> for update.
> > > 
> > > The second hunk look sensible but I do not know about "use Fcntl"
> > > since I do not see anything you are adding that starts to use it...
> > 
> > O_EXCL. Without "use Fcntl;" perl says I am not allowed to use bareword 
> > things in strict mode or some such.
> 
> Huh?  I still don't see where O_EXCL is used.

Yes. I did not make that point clear enough, I guess. My first approach 
was to reimplement git-update-ref in perl, which worked well enough, until 
I remembered that you could just call programs from perl :-)

> > > > +       system("git-update-ref refs/heads/$branch $cid") == 0
> 
> Passing args to system() in list form is always preferable in case
> there's a shell-unfriendly variable:
> 
> 	system("git-update-ref", "refs/heads/$branch", $cid) == 0

Old habit dies hard.

---

 git-cvsimport.perl |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index 3728294..fe6298b 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -677,11 +677,7 @@ my $commit = sub {
 	waitpid($pid,0);
 	die "Error running git-commit-tree: $?\n" if $?;
 
-	open(C,">$git_dir/refs/heads/$branch")
-		or die "Cannot open branch $branch for update: $!\n";
-	print C "$cid\n"
-		or die "Cannot write branch $branch for update: $!\n";
-	close(C)
+	system("git-update-ref", "refs/heads/$branch", $cid) == 0
 		or die "Cannot write branch $branch for update: $!\n";
 
 	if($tag) {

      reply	other threads:[~2006-03-31 11:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-30 12:06 [PATCH] cvsimport: use git-update-ref when updating Johannes Schindelin
2006-03-31  1:50 ` Junio C Hamano
2006-03-31 10:08   ` Johannes Schindelin
2006-03-31 10:32     ` Eric Wong
2006-03-31 11:14       ` Johannes Schindelin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.63.0603311310580.23287@wbgn013.biozentrum.uni-wuerzburg.de \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    --cc=normalperson@yhbt.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).