# Buggy code
async def get_full_sha1(self, rev: str) -> str:
    """
    Gets full sha1 object name.

    Parameters
    ----------
    rev : str
        Revision to search for full sha1 object name.

    Raises
    ------
    .UnknownRevision
        When git cannot find provided revision.
    .AmbiguousRevision
        When git cannot resolve provided short sha1 to one commit.

    Returns
    -------
    `str`
        Full sha1 object name for provided revision.

    """
    git_command = ProcessFormatter().format(
        self.GIT_GET_FULL_SHA1, path=self.folder_path, rev=rev
    )
    p = await self._run(git_command)

    if p.returncode != 0:
        stderr = p.stderr.decode().strip()
        ambiguous_error = (
            f"error: short SHA1 {rev} is ambiguous\nhint: The candidates are:\n"
        )
        if not stderr.startswith(ambiguous_error):
            raise errors.UnknownRevision(
                f"Revision {rev} cannot be found.", git_command
            )
        candidates = []
        for match in self.AMBIGUOUS_ERROR_REGEX.finditer(stderr, len(ambiguous_error)):
            candidates.append(Candidate(match["rev"], match["type"], match["desc"]))
        if candidates:
            raise errors.AmbiguousRevision(
                f"Short SHA1 {rev} is ambiguous.", git_command, candidates
            )
        raise errors.UnknownRevision(f"Revision {rev} cannot be found.", git_command)

    return p.stdout.decode().strip()


# Traceback (UnicodeDecodeError)
[ERROR] red: Exception in command 'cog update'
Traceback (most recent call last):
File "c:\__\coding\redenv\lib\site-packages\discord\ext\commands\core.py", line 83, in wrapped
ret = await coro(*args, **kwargs)
File "c:\__\coding\redenv\lib\site-packages\redbot\cogs\downloader\downloader.py", line 885, in _cog_update
await self._cog_update_logic(ctx, cogs=cogs)
File "c:\__\coding\redenv\lib\site-packages\redbot\cogs\downloader\downloader.py", line 979, in _cog_update_logic
updated_cognames, message = await self._update_cogs_and_libs(
File "c:\__\coding\redenv\lib\site-packages\redbot\cogs\downloader\downloader.py", line 1237, in _update_cogs_and_libs
failed_reqs = await self._install_requirements(cogs_to_update)
File "c:\__\coding\redenv\lib\site-packages\redbot\cogs\downloader\downloader.py", line 434, in _install_requirements
if not await repo.install_raw_requirements([req], self.LIB_PATH):
File "c:\__\coding\redenv\lib\site-packages\redbot\cogs\downloader\repo_manager.py", line 931, in install_raw_requirements
p = await self._run(
File "c:\__\coding\redenv\lib\site-packages\redbot\cogs\downloader\repo_manager.py", line 533, in _run
stderr = p.stderr.decode().strip()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc5 in position 936: invalid continuation byte

# Fixed code
async def get_full_sha1(self, rev: str) -> str:
    """
    Gets full sha1 object name.

    Parameters
    ----------
    rev : str
        Revision to search for full sha1 object name.

    Raises
    ------
    .UnknownRevision
        When git cannot find provided revision.
    .AmbiguousRevision
        When git cannot resolve provided short sha1 to one commit.

    Returns
    -------
    `str`
        Full sha1 object name for provided revision.

    """
    git_command = ProcessFormatter().format(
        self.GIT_GET_FULL_SHA1, path=self.folder_path, rev=rev
    )
    p = await self._run(git_command)

    if p.returncode != 0:
        stderr = p.stderr.decode(**DECODE_PARAMS).strip()
        ambiguous_error = (
            f"error: short SHA1 {rev} is ambiguous\nhint: The candidates are:\n"
        )
        if not stderr.startswith(ambiguous_error):
            raise errors.UnknownRevision(
                f"Revision {rev} cannot be found.", git_command
            )
        candidates = []
        for match in self.AMBIGUOUS_ERROR_REGEX.finditer(stderr, len(ambiguous_error)):
            candidates.append(Candidate(match["rev"], match["type"], match["desc"]))
        if candidates:
            raise errors.AmbiguousRevision(
                f"Short SHA1 {rev} is ambiguous.", git_command, candidates
            )
        raise errors.UnknownRevision(f"Revision {rev} cannot be found.", git_command)

    return p.stdout.decode(**DECODE_PARAMS).strip()