Punt shortlived xvm-console-devconfig with dead-end history from the
[invirt/scripts/git-migration.git] / git-migrate
index 35f3142..f10a512 100755 (executable)
@@ -11,16 +11,29 @@ def clonePackage(base, pkg):
             shutil.rmtree(pkg)
         # Use --no-follow-parent because we're going to handle that with
         # grafts.
             shutil.rmtree(pkg)
         # Use --no-follow-parent because we're going to handle that with
         # grafts.
-        subprocess.check_call(['git', 'svn', 'clone', '--no-follow-parent',
+        subprocess.check_call(['git', 'svn', 'clone',
+                               '--no-follow-parent',
                                '-Aauthors',
                                '-q',
                                '-Aauthors',
                                '-q',
-                               '--no-metadata', '%s/packages/%s' % (base, pkg)],
+                               '--no-metadata',
+                               '%s/packages/%s' % (base, pkg)],
                               stdout=subprocess.PIPE)
         
         # Then make the repository bare, because git-svn can't do this
         shutil.move('%s/.git' % pkg, '%s.git' % pkg)
                               stdout=subprocess.PIPE)
         
         # Then make the repository bare, because git-svn can't do this
         shutil.move('%s/.git' % pkg, '%s.git' % pkg)
-        shutil.rmtree('%s' % pkg)
-        subprocess.check_call(['git', 'config', 'core.bare', 'true'], cwd='%s.git' % pkg)
+        shutil.rmtree(pkg)
+        subprocess.check_call(['git', 'config', 'core.bare', 'true'],
+                              cwd='%s.git' % pkg)
+        
+    # Some of these repos have a rev where everything was deleted
+    # as a result of the move. We don't want that rev to exist.
+    p = subprocess.Popen(['git', 'ls-files'],
+                         cwd='%s.git' % pkg,
+                         stdout=subprocess.PIPE)
+    p.wait()
+    if len(p.stdout.read()) == 0:
+        subprocess.check_call(['git', 'reset', 'HEAD^'],
+                              cwd='%s.git' % pkg)
 
 def cloneAllPackages(base):
     for pkg in open('package-list'):
 
 def cloneAllPackages(base):
     for pkg in open('package-list'):