git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] cvsimport: use git-update-ref when updating

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Mar 31, 2006, 11:14 UTC
Message-ID
<Pine.LNX.4.63.0603311310580.23287@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<20060331103230.GB15159@hand.yhbt.net>
Hi,
On Fri, 31 Mar 2006, Eric Wong wrote:
Show 18 quoted lines
> 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 :-)

Show 6 quoted lines
> > > > +       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) {
Previous: Eric Wong
Message 5 of 5 in “cvsimport: use git-update-ref when updating”
  1. cvsimport: use git-update-ref when updatingJohannes Schindelin, Mar 30, 2006
  2. Junio C HamanoMar 31, 2006
  3. Johannes SchindelinMar 31, 2006
  4. Eric WongMar 31, 2006
  5. Johannes SchindelinMar 31, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.