# Path: sgit/util.py
# def noop(*args, **kwargs):
#     pass
# 
# def find_view_by_settings(window, **kwargs):
#     for view in window.views():
#         s = view.settings()
#         matches = [s.get(k) == v for k, v in list(kwargs.items())]
#         if all(matches):
#             return view
# 
# Path: sgit/cmd.py
# class GitCmd(GitRepoHelper, Cmd):
#     executable = 'git'
#     bin = ['git']
#     opts = [
#         '--no-pager',
#         '-c', 'color.diff=false',
#         '-c', 'color.status=false',
#         '-c', 'color.branch=false',
#         '-c', 'status.displayCommentPrefix=true',
#         '-c', 'core.commentchar=#',
#     ]
# 
#     def git(self, cmd, *args, **kwargs):
#         return self.cmd(cmd, *args, **kwargs)
# 
#     def git_string(self, cmd, *args, **kwargs):
#         return self._string(cmd, *args, **kwargs)
# 
#     def git_lines(self, cmd, *args, **kwargs):
#         return self._lines(cmd, *args, **kwargs)
# 
#     def git_exit_code(self, cmd, *args, **kwargs):
#         return self._exit_code(cmd, *args, **kwargs)
# 
#     def git_async(self, cmd, *args, **kwargs):
#         return self.cmd_async(cmd, *args, **kwargs)
# 
# Path: sgit/helpers.py
# class GitShowHelper(object):
# 
#     def get_show(self, repo, obj):
#         return self.git_string(['show', '--format=medium', '--no-color', obj], cwd=repo)


from functools import partial
from sublime_plugin import WindowCommand, TextCommand
from .util import noop, find_view_by_settings
from .cmd import GitCmd
from .helpers import GitShowHelper
import sublime
            return

        if not obj:
            self.window.show_input_panel('Object:', '', partial(self.show, repo), noop, noop)
        else:
            self.show(repo, obj)

    def show(self, repo, obj=None):
        if not obj:
            exit, obj, _ = self.git(['rev-parse', 'HEAD'], cwd=repo)
            if exit != 0:
                return sublime.error_message("Nothing committed (yet)")
            obj = obj.strip()

        title = GIT_SHOW_TITLE_PREFIX + obj[:7] if len(obj) == 40 else obj
        view = find_view_by_settings(self.window, git_view='show', git_repo=repo, git_show_obj=obj)
        if not view:
            view = self.window.new_file()
            view.set_name(title)
            view.set_scratch(True)
            view.set_read_only(True)
            view.set_syntax_file(GIT_SHOW_SYNTAX)

            view.settings().set('git_view', 'show')
            view.settings().set('git_repo', repo)
            view.settings().set('git_show_obj', obj)

        view.run_command('git_show_refresh', {'obj': obj})



# Path: sgit/util.py
# def noop(*args, **kwargs):
#     pass
# 
# def find_view_by_settings(window, **kwargs):
#     for view in window.views():
#         s = view.settings()
#         matches = [s.get(k) == v for k, v in list(kwargs.items())]
#         if all(matches):
#             return view
# 
# Path: sgit/cmd.py
# class GitCmd(GitRepoHelper, Cmd):
#     executable = 'git'
#     bin = ['git']
#     opts = [
#         '--no-pager',
#         '-c', 'color.diff=false',
#         '-c', 'color.status=false',
#         '-c', 'color.branch=false',
#         '-c', 'status.displayCommentPrefix=true',
#         '-c', 'core.commentchar=#',
#     ]
# 
#     def git(self, cmd, *args, **kwargs):
#         return self.cmd(cmd, *args, **kwargs)
# 
#     def git_string(self, cmd, *args, **kwargs):
#         return self._string(cmd, *args, **kwargs)
# 
#     def git_lines(self, cmd, *args, **kwargs):
#         return self._lines(cmd, *args, **kwargs)
# 
#     def git_exit_code(self, cmd, *args, **kwargs):
#         return self._exit_code(cmd, *args, **kwargs)
# 
#     def git_async(self, cmd, *args, **kwargs):
#         return self.cmd_async(cmd, *args, **kwargs)
# 
# Path: sgit/helpers.py
# class GitShowHelper(object):
# 
#     def get_show(self, repo, obj):
#         return self.git_string(['show', '--format=medium', '--no-color', obj], cwd=repo)


# Path: sgit/show.py
from functools import partial
from sublime_plugin import WindowCommand, TextCommand
from .util import noop, find_view_by_settings
from .cmd import GitCmd
from .helpers import GitShowHelper
import sublime

            return

        if not obj:
            self.window.show_input_panel('Object:', '', partial(self.show, repo), noop, noop)
        else:
            self.show(repo, obj)

    def show(self, repo, obj=None):
        if not obj:
            exit, obj, _ = self.git(['rev-parse', 'HEAD'], cwd=repo)
            if exit != 0:
                return sublime.error_message("Nothing committed (yet)")
            obj = obj.strip()

        title = GIT_SHOW_TITLE_PREFIX + obj[:7] if len(obj) == 40 else obj
        view = find_view_by_settings(self.window, git_view='show', git_repo=repo, git_show_obj=obj)
        if not view:
            view = self.window.new_file()
            view.set_name(title)
            view.set_scratch(True)
            view.set_read_only(True)
            view.set_syntax_file(GIT_SHOW_SYNTAX)

            view.settings().set('git_view', 'show')
            view.settings().set('git_repo', repo)
            view.settings().set('git_show_obj', obj)

        view.run_command('git_show_refresh', {'obj': obj})



class GitShowRefreshCommand(TextCommand, GitCmd, GitShowHelper):