From 322b33a0f1b72b05c6c4f6b976cea11c7bbf7609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20N=C3=BCtzi?= Date: Fri, 2 Jul 2021 15:16:01 +0200 Subject: [PATCH] Support git default branch name - Instead of master use the `init.defaultBranch` if set. --- src/repository.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/repository.cpp b/src/repository.cpp index 5fd5b24..45be415 100644 --- a/src/repository.cpp +++ b/src/repository.cpp @@ -326,8 +326,18 @@ FastImportRepository::FastImportRepository(const Rules::Repository &rule) branches.insert(branchRule.name, branch); } - // create the default branch - branches["master"].created = 1; + // create the defaultBranch from the config + QProcess config; + config.start("git", QStringList() << "config" << "init.defaultBranch"); + config.waitForFinished(-1); + QString defaultBranch = QString(config.readAllStandardOutput()).trimmed(); + + // Create the default branch + if (defaultBranch.isEmpty()) { + branches["master"].created = 1; + } else { + branches[defaultBranch].created = 1; + } if (!CommandLineParser::instance()->contains("dry-run") && !CommandLineParser::instance()->contains("create-dump")) { fastImport.setWorkingDirectory(name);