summaryrefslogtreecommitdiff
path: root/builtin/clone.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2020-07-06 22:09:17 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-07-06 22:09:17 -0700
commit11cbda2add5d3eb7c415f1f6dd8186181a7f9874 (patch)
tree7d722860aa28b92087406bf063c7ad6fe6c45c30 /builtin/clone.c
parentMerge branch 'rs/pack-bits-in-object-better' (diff)
parentcontrib: subtree: adjust test to change in fmt-merge-msg (diff)
downloadtgif-11cbda2add5d3eb7c415f1f6dd8186181a7f9874.tar.xz
Merge branch 'js/default-branch-name'
The name of the primary branch in existing repositories, and the default name used for the first branch in newly created repositories, is made configurable, so that we can eventually wean ourselves off of the hardcoded 'master'. * js/default-branch-name: contrib: subtree: adjust test to change in fmt-merge-msg testsvn: respect `init.defaultBranch` remote: use the configured default branch name when appropriate clone: use configured default branch name when appropriate init: allow setting the default for the initial branch name via the config init: allow specifying the initial branch name for the new repository docs: add missing diamond brackets submodule: fall back to remote's HEAD for missing remote.<name>.branch send-pack/transport-helper: avoid mentioning a particular branch fmt-merge-msg: stop treating `master` specially
Diffstat (limited to 'builtin/clone.c')
-rw-r--r--builtin/clone.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/builtin/clone.c b/builtin/clone.c
index e3519a8355..bef70745c0 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -1111,7 +1111,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
}
}
- init_db(git_dir, real_git_dir, option_template, GIT_HASH_UNKNOWN, INIT_DB_QUIET);
+ init_db(git_dir, real_git_dir, option_template, GIT_HASH_UNKNOWN, NULL,
+ INIT_DB_QUIET);
if (real_git_dir)
git_dir = real_git_dir;
@@ -1275,9 +1276,13 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
remote_head_points_at = NULL;
remote_head = NULL;
option_no_checkout = 1;
- if (!option_bare)
- install_branch_config(0, "master", option_origin,
- "refs/heads/master");
+ if (!option_bare) {
+ const char *branch = git_default_branch_name();
+ char *ref = xstrfmt("refs/heads/%s", branch);
+
+ install_branch_config(0, branch, option_origin, ref);
+ free(ref);
+ }
}
write_refspec_config(src_ref_prefix, our_head_points_at,