Use git-show-ref to check for branch existence.

wilder
Michael Pyne 14 years ago
parent 14f9dba9fe
commit d5778a4ac7
  1. 11
      kdesrc-build

@ -3026,15 +3026,12 @@ EOF
# Use "$branch" directly if not already used, otherwise try
# to prefix with the best remote name or origin.
my $bestRemoteName = $remoteNamesRef ? $remoteNamesRef->[0] : 'origin';
for my $possibleBranch ($branch, "$bestRemoteName-$branch", "origin-$branch") {
my @known_branches = eval {
# undef == no filter
filter_program_output(undef, 'git', 'branch', '--list', $possibleBranch)
};
my $result = safe_system('git', 'show-ref', '--quiet', '--verify',
'--', "/refs/heads/$possibleBranch");
# The desired branch name is OK as-is if no exceptions were thrown and
# the branch wasn't already known to git.
return $possibleBranch if !@known_branches && !$@;
return $possibleBranch if $result == 1;
}
croak_runtime("Unable to find good branch name for $module branch name $branch");

Loading…
Cancel
Save