summaryrefslogtreecommitdiffstats
path: root/core/git-access.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2020-04-14 15:12:56 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-04-15 07:58:10 -0700
commit433149af19c0d0424383f756500c4f0b7d1cd831 (patch)
tree3cceec7d6126d761faa8c85f329571c9e0c4d552 /core/git-access.c
parentebb342c969fab99d1c497b24f5511ebb427cdc92 (diff)
downloadsubsurface-433149af19c0d0424383f756500c4f0b7d1cd831.tar.gz
git-storage: make creation of empty cache repo set the initial branch
In create_and_push_remote(), we set up the remote tracking etc to use the proper branch name, but never actually set up the initial local branch for the new cache repository at all. So the repository would end up with the default 'master' branch, instead of the branch name it should have. This went unnoticed, because most setups start by initializing the git caches by cloning from the cloud, and that worked fine. Debugged-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'core/git-access.c')
-rw-r--r--core/git-access.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/core/git-access.c b/core/git-access.c
index 0db4faf8e..b015524cb 100644
--- a/core/git-access.c
+++ b/core/git-access.c
@@ -703,7 +703,7 @@ static git_repository *create_and_push_remote(const char *localdir, const char *
{
git_repository *repo;
git_config *conf;
- char *variable_name, *merge_head;
+ char *variable_name, *head;
if (verbose)
fprintf(stderr, "git storage: create and push remote\n");
@@ -711,9 +711,12 @@ static git_repository *create_and_push_remote(const char *localdir, const char *
/* first make sure the directory for the local cache exists */
subsurface_mkdir(localdir);
+ head = format_string("refs/heads/%s", branch);
+
/* set up the origin to point to our remote */
git_repository_init_options init_opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
init_opts.origin_url = remote;
+ init_opts.initial_head = head;
/* now initialize the repository with */
git_repository_init_ext(&repo, localdir, &init_opts);
@@ -725,9 +728,8 @@ static git_repository *create_and_push_remote(const char *localdir, const char *
free(variable_name);
variable_name = format_string("branch.%s.merge", branch);
- merge_head = format_string("refs/heads/%s", branch);
- git_config_set_string(conf, variable_name, merge_head);
- free(merge_head);
+ git_config_set_string(conf, variable_name, head);
+ free(head);
free(variable_name);
/* finally create an empty commit and push it to the remote */