def CMDdiff(parser, args):
    'Shows differences between local tree and last upload.'
    auth.add_auth_options(parser)
    (options, args) = parser.parse_args(args)
    auth_config = auth.extract_auth_config_from_options(options)
    if args:
        parser.error(('Unrecognized args: %s' % ' '.join(args)))
    if git_common.is_dirty_git_tree('diff'):
        return 1
    cl = Changelist(auth_config=auth_config)
    issue = cl.GetIssue()
    branch = cl.GetBranch()
    if (not issue):
        DieWithError(('No issue found for current branch (%s)' % branch))
    TMP_BRANCH = 'git-cl-diff'
    base_branch = cl.GetCommonAncestorWithUpstream()
    RunGit(['checkout', '-q', '-b', TMP_BRANCH, base_branch])
    cl.ClearBranch()
    try:
        rtn = cl.CMDPatchIssue(issue, reject=False, nocommit=False, directory=None)
        if (rtn != 0):
            RunGit(['reset', '--hard'])
            return rtn
        subprocess2.check_call(['git', 'diff', TMP_BRANCH, branch, '--'])
    finally:
        RunGit(['checkout', '-q', branch])
        RunGit(['branch', '-D', TMP_BRANCH])
    return 0
Shows differences between local tree and last upload.
def CMDdiff(parser, args):
    
    auth.add_auth_options(parser)
    (options, args) = parser.parse_args(args)
    auth_config = auth.extract_auth_config_from_options(options)
    if args:
        parser.error(('Unrecognized args: %s' % ' '.join(args)))
    if git_common.is_dirty_git_tree('diff'):
        return 1
    cl = Changelist(auth_config=auth_config)
    issue = cl.GetIssue()
    branch = cl.GetBranch()
    if (not issue):
        DieWithError(('No issue found for current branch (%s)' % branch))
    TMP_BRANCH = 'git-cl-diff'
    base_branch = cl.GetCommonAncestorWithUpstream()
    RunGit(['checkout', '-q', '-b', TMP_BRANCH, base_branch])
    cl.ClearBranch()
    try:
        rtn = cl.CMDPatchIssue(issue, reject=False, nocommit=False, directory=None)
        if (rtn != 0):
            RunGit(['reset', '--hard'])
            return rtn
        subprocess2.check_call(['git', 'diff', TMP_BRANCH, branch, '--'])
    finally:
        RunGit(['checkout', '-q', branch])
        RunGit(['branch', '-D', TMP_BRANCH])
    return 0