From: Stephan Springl Date: Wed, 23 May 2007 11:13:21 +0000 (+0100) Subject: Use git-for-each-ref to check whether the origin branch exists. X-Git-Tag: v1.5.2.1~19 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7ca055f75ad7ffd2251d4b607fbb86d7bcfd77c7;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/git-cvsimport.perl b/git-cvsimport.perl index ac74bc51b..f68afe78a 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -559,11 +559,6 @@ unless (-d $git_dir) { $last_branch = $opt_o; $orig_branch = ""; } else { - -f "$git_dir/refs/heads/$opt_o" - or die "Branch '$opt_o' does not exist.\n". - "Either use the correct '-o branch' option,\n". - "or import to a new repository.\n"; - open(F, "git-symbolic-ref HEAD |") or die "Cannot run git-symbolic-ref: $!\n"; chomp ($last_branch = ); @@ -588,6 +583,11 @@ unless (-d $git_dir) { $branch_date{$head} = $1; } close(H); + if (!exists $branch_date{$opt_o}) { + die "Branch '$opt_o' does not exist.\n". + "Either use the correct '-o branch' option,\n". + "or import to a new repository.\n"; + } } -d $git_dir