Allow git.checkout() to work on unmerged indexes
[stgit] / stgit / git.py
index d75b54e..6b14a74 100644 (file)
@@ -272,9 +272,11 @@ def rev_parse(git_id):
 def branch_exists(branch):
     """Existence check for the named branch
     """
-    for line in _output_lines(['git-rev-parse', '--symbolic', '--all']):
+    for line in _output_lines('git-rev-parse --symbolic --all 2>&1'):
         if line.strip() == branch:
             return True
+        if re.compile('[ |/]'+branch+' ').search(line):
+            raise GitException, 'Bogus branch: %s' % line
     return False
 
 def create_branch(new_branch, tree_id = None):
@@ -610,7 +612,7 @@ def checkout(files = None, tree_id = None, force = False):
     if not files:
         files = []
 
-    if tree_id and __run('git-read-tree -m', [tree_id]) != 0:
+    if tree_id and __run('git-read-tree', [tree_id]) != 0:
         raise GitException, 'Failed git-read-tree -m %s' % tree_id
 
     checkout_cmd = 'git-checkout-index -q -u'