]> andersk Git - svn-all-fast-export.git/commitdiff
Make it easier to do automatic branching
authorThiago Macieira <thiago@doriath.(none)>
Wed, 13 Aug 2008 13:05:55 +0000 (15:05 +0200)
committerThiago Macieira <thiago.macieira@trolltech.com>
Wed, 13 Aug 2008 13:06:10 +0000 (15:06 +0200)
src/repository.cpp

index 1ebdb6f0e5f78c130261e098822849ef5c33527c..7c085ceabce94c16c3a10dd88822ccaaf7ee9158 100644 (file)
@@ -45,30 +45,20 @@ Repository::~Repository()
 
 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/"))
-            branchRef.prepend("refs/heads/");
+    QProcess revParse;
+    revParse.setWorkingDirectory(name);
+    revParse.start("git", QStringList() << "rev-parse" << "--symbolic" << "--branches");
+    revParse.waitForFinished();
+
+    if (revParse.exitCode() == 0 && revParse.bytesAvailable()) {
+        startFastImport();
+
+        while (revParse.canReadLine()) {
+            QByteArray branchName = revParse.readLine();
 
-        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\n");
-            it->created = 1;
+            branches[branchName].created = 1;
+            fastImport.write("reset refs/heads/" + branchName +
+                             "\nfrom refs/heads/" + branchName + "^0\n\n");
         }
     }
 }
This page took 0.031631 seconds and 5 git commands to generate.