Patrick Steinhardt <ps@xxxxxx> writes: > 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@xxxxxx> > --- > builtin/clone.c | 5 ++++- > builtin/var.c | 2 +- > refs.c | 10 ---------- > refs.h | 4 +--- > remote.c | 12 ++++++++---- > setup.c | 5 ++++- > 6 files changed, 18 insertions(+), 20 deletions(-) > > diff --git a/builtin/clone.c b/builtin/clone.c > index 554b29768c..bd3e8302ed 100644 > --- a/builtin/clone.c > +++ b/builtin/clone.c > @@ -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; > This is a really good pattern, Makes it much cleaner to understand. [snip]
Attachment:
signature.asc
Description: PGP signature