+void Repository::reloadBranches()
+{
+ QHash<QString, Branch>::Iterator it = branches.begin(),
+ end = branches.end();
+ for ( ; it != end; ++it) {
+ QString branchRef = it.key();
+ if (!branchRef.startsWith("refs/heads/"))
+ branchRef.prepend("refs/heads/");
+
+ bool branchExists;
+ // does this branch already exist?
+ QProcess revParse;
+ revParse.setWorkingDirectory(name);
+ revParse.start("git-rev-parse", QStringList() << "--verify" << branchRef);
+ revParse.waitForFinished();
+
+ if (revParse.exitCode() == 0)
+ branchExists = true;
+ else
+ branchExists = false;
+
+ if (branchExists) {
+ startFastImport();
+ fastImport.write("reset " + branchRef.toUtf8() +
+ "\nfrom " + branchRef.toUtf8() + "^0\n");
+ it->isCreated = true;
+ }
+ }
+}
+