Skip to content

Do not warn the user if default branch does not exist #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/repository.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class FastImportRepository : public Repository
QVector<int> marks;
};

QString defaultBranch;
QHash<QString, Branch> branches;
QHash<QString, QByteArray> branchNotes;
QHash<QString, AnnotatedTag> annotatedTags;
Expand Down Expand Up @@ -351,15 +352,15 @@ FastImportRepository::FastImportRepository(const Rules::Repository &rule)
QProcess config;
config.start("git", QStringList() << "config" << "init.defaultBranch");
config.waitForFinished(-1);
QString defaultBranch = QString(config.readAllStandardOutput()).trimmed();
defaultBranch = QString(config.readAllStandardOutput()).trimmed();

// Create the default branch
if (defaultBranch.isEmpty()) {
branches["master"].created = 1;
} else {
branches[defaultBranch].created = 1;
defaultBranch = "master";
}

branches[defaultBranch].created = 1;

if (!CommandLineParser::instance()->contains("dry-run") && !CommandLineParser::instance()->contains("create-dump")) {
fastImport.setWorkingDirectory(name);
if (!QDir(name).exists()) { // repo doesn't exist yet.
Expand Down Expand Up @@ -756,7 +757,7 @@ void FastImportRepository::commit()
Repository::Transaction *FastImportRepository::newTransaction(const QString &branch, const QString &svnprefix,
int revnum)
{
if (!branches.contains(branch)) {
if (!branchExists(branch)) {
qWarning() << "WARN: Transaction:" << branch << "is not a known branch in repository" << name << endl
<< "Going to create it automatically";
}
Expand Down Expand Up @@ -1153,8 +1154,9 @@ int FastImportRepository::Transaction::commit()
if (br.created && !br.marks.isEmpty() && br.marks.last()) {
parentmark = br.marks.last();
} else {
if (revnum > 1) {
// Any branch at revision 1 isn't going to exist, so lets not alarm the user.
if (revnum > 1 && branch != repository->defaultBranch) {
// Any branch at revision 1 isn't going to exist -> do not alarm the user.
// Default branch might also not exist yet -> do not alarm the user.
qWarning() << "WARN: Branch" << branch << "in repository" << repository->name << "doesn't exist at revision"
<< revnum << "-- did you resume from the wrong revision?";
}
Expand Down