Skip to content

Commit 322b33a

Browse files
author
Gabriel Nützi
committed
Support git default branch name
- Instead of master use the `init.defaultBranch` if set.
1 parent d8084f9 commit 322b33a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/repository.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,18 @@ FastImportRepository::FastImportRepository(const Rules::Repository &rule)
326326
branches.insert(branchRule.name, branch);
327327
}
328328

329-
// create the default branch
330-
branches["master"].created = 1;
329+
// create the defaultBranch from the config
330+
QProcess config;
331+
config.start("git", QStringList() << "config" << "init.defaultBranch");
332+
config.waitForFinished(-1);
333+
QString defaultBranch = QString(config.readAllStandardOutput()).trimmed();
334+
335+
// Create the default branch
336+
if (defaultBranch.isEmpty()) {
337+
branches["master"].created = 1;
338+
} else {
339+
branches[defaultBranch].created = 1;
340+
}
331341

332342
if (!CommandLineParser::instance()->contains("dry-run") && !CommandLineParser::instance()->contains("create-dump")) {
333343
fastImport.setWorkingDirectory(name);

0 commit comments

Comments
 (0)