mirror of
https://github.com/git/git.git
synced 2026-01-10 10:13:33 +00:00
get_default_branch_name(): prepare for showing some advice
We are about to introduce a message giving users running `git init` some advice about `init.defaultBranch`. This will necessarily be done in `repo_default_branch_name()`. Not all code paths want to show that advice, though. In particular, the `git clone` codepath _specifically_ asks for `init_db()` to be quiet, via the `INIT_DB_QUIET` flag. In preparation for showing users above-mentioned advice, let's change the function signature of `get_default_branch_name()` to accept the parameter `quiet`. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
cfaff3aac8
commit
cc0f13c57d
@@ -202,7 +202,8 @@ void initialize_repository_version(int hash_algo, int reinit)
|
||||
static int create_default_files(const char *template_path,
|
||||
const char *original_git_dir,
|
||||
const char *initial_branch,
|
||||
const struct repository_format *fmt)
|
||||
const struct repository_format *fmt,
|
||||
int quiet)
|
||||
{
|
||||
struct stat st1;
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
@@ -267,7 +268,7 @@ static int create_default_files(const char *template_path,
|
||||
char *ref;
|
||||
|
||||
if (!initial_branch)
|
||||
initial_branch = git_default_branch_name();
|
||||
initial_branch = git_default_branch_name(quiet);
|
||||
|
||||
ref = xstrfmt("refs/heads/%s", initial_branch);
|
||||
if (check_refname_format(ref, 0) < 0)
|
||||
@@ -438,7 +439,8 @@ int init_db(const char *git_dir, const char *real_git_dir,
|
||||
validate_hash_algorithm(&repo_fmt, hash);
|
||||
|
||||
reinit = create_default_files(template_dir, original_git_dir,
|
||||
initial_branch, &repo_fmt);
|
||||
initial_branch, &repo_fmt,
|
||||
flags & INIT_DB_QUIET);
|
||||
if (reinit && initial_branch)
|
||||
warning(_("re-init: ignored --initial-branch=%s"),
|
||||
initial_branch);
|
||||
|
||||
Reference in New Issue
Block a user