Use git-for-each-ref to check whether the origin branch exists.
This works in repositories that have their refs packed by "git-pack-refs --all --prune" whereas testing the file $git_dir/refs/heads/$opt_o does not. Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
Stephan Springl committed
May 23, 2007 at 12:13 UTC
7ca055f75ad7ffd2251d4b607fbb86d7bcfd77c7
1 file changed
+5
-5
git-cvsimport.perl
+5
-5
@@ -559,11 +559,6 @@ unless (-d $git_dir) {
559
$last_branch = $opt_o;
560
$orig_branch = "";
561
} else {
562
- -f "$git_dir/refs/heads/$opt_o"
563
- or die "Branch '$opt_o' does not exist.\n".
564
- "Either use the correct '-o branch' option,\n".
565
- "or import to a new repository.\n";
566
-
562
open(F, "git-symbolic-ref HEAD |") or
563
die "Cannot run git-symbolic-ref: $!\n";
564
chomp ($last_branch = <F>);
@@ -588,6 +583,11 @@ unless (-d $git_dir) {
583
$branch_date{$head} = $1;
584
}
585
close(H);
586
+ if (!exists $branch_date{$opt_o}) {
587
+ die "Branch '$opt_o' does not exist.\n".
588
+ "Either use the correct '-o branch' option,\n".
589
+ "or import to a new repository.\n";
590
+ }
591
}
592
593
-d $git_dir