From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Emanuele Giaquinta <e.giaquinta@glauco.it>, git@vger.kernel.org
Subject: [PATCH 3/3] cvsimport: miscellaneous packed-ref fixes
Date: Wed, 28 Nov 2007 13:56:28 -0500 [thread overview]
Message-ID: <20071128185628.GC11320@coredump.intra.peff.net> (raw)
In-Reply-To: <20071128185504.GA11236@coredump.intra.peff.net>
These were found with a grep for '$git_dir'; they all
replace a direct access of "$git_dir/refs/..." with a call
to git-show-ref or git-update-ref.
Signed-off-by: Jeff King <peff@peff.net>
---
git-cvsimport.perl | 20 +++++++++-----------
1 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index b852f2f..1b5f187 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -864,29 +864,27 @@ while (<CVS>) {
print STDERR "Branch $branch erroneously stems from itself -- changed ancestor to $opt_o\n";
$ancestor = $opt_o;
}
- if (-f "$git_dir/$remote/$branch") {
+ if (defined get_headref("$remote/$branch")) {
print STDERR "Branch $branch already exists!\n";
$state=11;
next;
}
- unless (open(H,"$git_dir/$remote/$ancestor")) {
+ my $id = get_headref("$remote/$ancestor");
+ if (!$id) {
print STDERR "Branch $ancestor does not exist!\n";
$ignorebranch{$branch} = 1;
$state=11;
next;
}
- chomp(my $id = <H>);
- close(H);
- unless (open(H,"> $git_dir/$remote/$branch")) {
- print STDERR "Could not create branch $branch: $!\n";
+
+ system(qw(git update-ref -m cvsimport),
+ "$remote/$branch", $id);
+ if($? != 0) {
+ print STDERR "Could not create branch $branch\n";
$ignorebranch{$branch} = 1;
$state=11;
next;
}
- print H "$id\n"
- or die "Could not write branch $branch: $!";
- close(H)
- or die "Could not write branch $branch: $!";
}
$last_branch = $branch if $branch ne $last_branch;
$state = 9;
@@ -998,7 +996,7 @@ if ($orig_branch) {
$orig_branch = "master";
print "DONE; creating $orig_branch branch\n" if $opt_v;
system("git-update-ref", "refs/heads/master", "$remote/$opt_o")
- unless -f "$git_dir/refs/heads/master";
+ defined get_headref('refs/heads/master');
system("git-symbolic-ref", "$remote/HEAD", "$remote/$opt_o")
if ($opt_r && $opt_o ne 'HEAD');
system('git-update-ref', 'HEAD', "$orig_branch");
--
1.5.3.6.2039.g0495
next prev parent reply other threads:[~2007-11-28 18:57 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-27 15:01 git-cvsimport bug Emanuele Giaquinta
2007-11-28 16:57 ` Jeff King
2007-11-28 18:55 ` Jeff King
2007-11-28 18:55 ` [PATCH 1/3] Add basic cvsimport tests Jeff King
2007-11-28 22:14 ` Junio C Hamano
2007-11-28 22:20 ` David Kastrup
2007-11-29 9:12 ` Andreas Ericsson
2007-11-28 18:56 ` [PATCH 2/3] cvsimport: use show-ref to support packed refs Jeff King
2007-11-28 19:16 ` Johannes Schindelin
2007-11-28 19:44 ` Jeff King
2007-11-28 20:37 ` Johannes Schindelin
2007-11-28 22:23 ` Junio C Hamano
2007-11-28 22:43 ` Jeff King
2007-11-28 22:52 ` Jeff King
2007-11-28 18:56 ` Jeff King [this message]
2007-11-29 0:52 ` [PATCH 3/3] cvsimport: miscellaneous packed-ref fixes Junio C Hamano
2007-11-29 14:19 ` Jeff King
2007-11-30 18:41 ` git-cvsimport bug Emanuele Giaquinta
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071128185628.GC11320@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=e.giaquinta@glauco.it \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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.
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 NNTP newsgroup(s).