aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2007-11-28 13:56:28 -0500
committerJunio C Hamano <gitster@pobox.com>2007-11-28 14:38:35 -0800
commit0750d751157addde94f28a7933ed4f914a526eb7 (patch)
tree4f66ac21f80ac3d23234e2d77e5be7684fbdb0ac
parent9da0dabcd9ff71083b6bbc9878c22b12002400dd (diff)
downloadgit-0750d751157addde94f28a7933ed4f914a526eb7.tar.gz
git-0750d751157addde94f28a7933ed4f914a526eb7.tar.xz
cvsimport: miscellaneous packed-ref fixes
These were found with a grep for '$git_dir'; they all replace a direct access of "$git_dir/refs/..." with a call to git-rev-parse or git-update-ref. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xgit-cvsimport.perl20
1 files changed, 9 insertions, 11 deletions
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index a7a7d8f44..d29b547d2 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";
+ unless 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");