@matheusbsbs / matheus-bagliano / commits / 0750d75115
Fork 0

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>

Jeff King committed Nov 28, 2007 at 13:56 UTC 0750d751157addde94f28a7933ed4f914a526eb7
1 file changed +9 -11
git-cvsimport.perl
+9 -11
@@ -864,29 +864,27 @@ while (<CVS>) {
864 print STDERR "Branch $branch erroneously stems from itself -- changed ancestor to $opt_o\n";
865 $ancestor = $opt_o;
866 }
867 - if (-f "$git_dir/$remote/$branch") {
867 + if (defined get_headref("$remote/$branch")) {
868 print STDERR "Branch $branch already exists!\n";
869 $state=11;
870 next;
871 }
872 - unless (open(H,"$git_dir/$remote/$ancestor")) {
872 + my $id = get_headref("$remote/$ancestor");
873 + if (!$id) {
874 print STDERR "Branch $ancestor does not exist!\n";
875 $ignorebranch{$branch} = 1;
876 $state=11;
877 next;
878 }
878 - chomp(my $id = <H>);
879 - close(H);
880 - unless (open(H,"> $git_dir/$remote/$branch")) {
881 - print STDERR "Could not create branch $branch: $!\n";
879 +
880 + system(qw(git update-ref -m cvsimport),
881 + "$remote/$branch", $id);
882 + if($? != 0) {
883 + print STDERR "Could not create branch $branch\n";
884 $ignorebranch{$branch} = 1;
885 $state=11;
886 next;
887 }
886 - print H "$id\n"
887 - or die "Could not write branch $branch: $!";
888 - close(H)
889 - or die "Could not write branch $branch: $!";
888 }
889 $last_branch = $branch if $branch ne $last_branch;
890 $state = 9;
@@ -998,7 +996,7 @@ if ($orig_branch) {
996 $orig_branch = "master";
997 print "DONE; creating $orig_branch branch\n" if $opt_v;
998 system("git-update-ref", "refs/heads/master", "$remote/$opt_o")
1001 - unless -f "$git_dir/refs/heads/master";
999 + unless defined get_headref('refs/heads/master');
1000 system("git-symbolic-ref", "$remote/HEAD", "$remote/$opt_o")
1001 if ($opt_r && $opt_o ne 'HEAD');
1002 system('git-update-ref', 'HEAD', "$orig_branch");