git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] cvsimport: use git-update-ref when updating
@ 2006-03-30 12:06 Johannes Schindelin
  2006-03-31  1:50 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Schindelin @ 2006-03-30 12:06 UTC (permalink / raw)
  To: git, junkio


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.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>

---

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

diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index 3728294..957af13 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -15,6 +15,7 @@ # You can change that with the '-o' opti
 
 use strict;
 use warnings;
+use Fcntl;
 use Getopt::Std;
 use File::Spec;
 use File::Temp qw(tempfile);
@@ -677,11 +678,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) {

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] cvsimport: use git-update-ref when updating
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2006-03-31  1:50 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cvsimport: use git-update-ref when updating
  2006-03-31  1:50 ` Junio C Hamano
@ 2006-03-31 10:08   ` Johannes Schindelin
  2006-03-31 10:32     ` Eric Wong
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Schindelin @ 2006-03-31 10:08 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

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.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cvsimport: use git-update-ref when updating
  2006-03-31 10:08   ` Johannes Schindelin
@ 2006-03-31 10:32     ` Eric Wong
  2006-03-31 11:14       ` Johannes Schindelin
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Wong @ 2006-03-31 10:32 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Junio C Hamano, git

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.

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

-- 
Eric Wong

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cvsimport: use git-update-ref when updating
  2006-03-31 10:32     ` Eric Wong
@ 2006-03-31 11:14       ` Johannes Schindelin
  0 siblings, 0 replies; 5+ messages in thread
From: Johannes Schindelin @ 2006-03-31 11:14 UTC (permalink / raw)
  To: Eric Wong; +Cc: Junio C Hamano, git

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-03-31 11:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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

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