git checkout doesn't require explicit branch parameter
[matrix.git] / matrix / git.py
index ffa53345b697f8ac8b89572b3f73ea38ef3dc86e..9a53d0f4e2fdb53814946c459b1362cc5eb6f954 100644 (file)
@@ -7,7 +7,7 @@ import bz2
 
 import config
 
-class Error (RuntimeError):
+class Error(RuntimeError):
        def __init__(self, args, workdir=None):
                command = ' '.join(args)
 
@@ -130,7 +130,7 @@ def pull(name, url=None, refspec=None):
        else:
                cmd = ['pull',url,refspec]
        if call(cmd, workdir=name) != 0:
-               raise Error('pull', url)
+               raise Error(cmd, name)
 
 def create_branch(name, branch, point, checkout=False,link=False,force=False):
        if checkout:
@@ -156,8 +156,12 @@ def delete_branch(name, branch, force=False, quiet=False):
 
        return call(['branch', command, branch], name, quiet, not quiet) == 0
 
-def checkout(name, branch):
-       call(['checkout', branch], workdir=name, fail=True)
+def checkout(name, branch=None):
+       cmd = ['checkout']
+       if branch:
+               cmd.append(branch)
+
+       call(cmd, workdir=name, fail=True)
 
 def rev_parse(name, arg):
        lines = call_output(['rev-parse', arg], workdir=name)