def _git(*command_parts, **kwargs):
<EOL>git_kwargs = {'<STR_LIT>': False}<EOL>git_kwargs.update(kwargs)<EOL>try:<EOL><INDENT>result = sh.git(*command_parts, **git_kwargs)  <EOL>if hasattr(result, '<STR_LIT>') and result.exit_code > <NUM_LIT:0>:<EOL><INDENT>return result<EOL><DEDENT>return ustr(result)<EOL><DEDENT>except CommandNotFound:<EOL><INDENT>raise GitNotInstalledError()<EOL><DEDENT>except ErrorReturnCode as e:  <EOL><INDENT>error_msg = e.stderr.strip()<EOL>if '<STR_LIT>' in git_kwargs and b"<STR_LIT>" in error_msg.lower():<EOL><INDENT>error_msg = u"<STR_LIT>".format(git_kwargs['<STR_LIT>'])<EOL><DEDENT>else:<EOL><INDENT>error_msg = u"<STR_LIT>".format(e.full_cmd, error_msg)<EOL><DEDENT>raise GitContextError(error_msg)<EOL><DEDENT>
Convenience function for running git commands. Automatically deals with exceptions and unicode.