refs: drop git_default_branch_name()
The `git_default_branch_name()` function is a thin wrapper around `repo_default_branch_name()` with two differences: - We implicitly rely on `the_repository`. - We cache the default branch name. None of the callsites of `git_default_branch_name()` are hot code paths though, so the caching of the branch name is not really required. Refactor the callsites to use `repo_default_branch_name()` instead and drop `git_default_branch_name()`, thus getting rid of one more case where we rely on `the_repository`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
30aaff437f
commit
97abaab5f6
@ -1468,6 +1468,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
|
||||
} else if (remote_head) {
|
||||
our_head_points_at = NULL;
|
||||
} else {
|
||||
char *to_free = NULL;
|
||||
const char *branch;
|
||||
|
||||
if (!mapped_refs) {
|
||||
@ -1480,7 +1481,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
|
||||
"refs/heads/", &branch)) {
|
||||
unborn_head = xstrdup(transport_ls_refs_options.unborn_head_target);
|
||||
} else {
|
||||
branch = git_default_branch_name(0);
|
||||
branch = to_free = repo_default_branch_name(the_repository, 0);
|
||||
unborn_head = xstrfmt("refs/heads/%s", branch);
|
||||
}
|
||||
|
||||
@ -1496,6 +1497,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
|
||||
* a match.
|
||||
*/
|
||||
our_head_points_at = find_remote_branch(mapped_refs, branch);
|
||||
|
||||
free(to_free);
|
||||
}
|
||||
|
||||
write_refspec_config(src_ref_prefix, our_head_points_at,
|
||||
|
Reference in New Issue
Block a user