# Buggy code
def update_repo(self, name):
    try:
        dd = self.path
        if name not in self.repos:
            raise UpdateError("Repo does not exist in data, wtf")
        folder = os.path.join(dd, name)
        # Make sure we don't git reset the Red folder on accident
        if not os.path.exists(os.path.join(folder, ".git")):
            # if os.path.exists(folder):
            # shutil.rmtree(folder)
            url = self.repos[name].get("url")
            if not url:
                raise UpdateError("Need to clone but no URL set")
            branch = None
            if "@" in url:  # Specific branch
                url, branch = url.rsplit("@", maxsplit=1)
            if branch is None:
                p = run(["git", "clone", url, dd + name])
            else:
                p = run(["git", "clone", "-b", branch, url, dd + name])
            if p.returncode != 0:
                raise CloningError()
            self.populate_list(name)
            return name, REPO_CLONE, None
        else:
            rpcmd = ["git", "-C", dd + name, "rev-parse", "HEAD"]
            p = run(["git", "-C", dd + name, "reset", "--hard", "origin/HEAD", "-q"])
            if p.returncode != 0:
                raise UpdateError("Error resetting to origin/HEAD")
            p = run(rpcmd, stdout=PIPE)
            if p.returncode != 0:
                raise UpdateError("Unable to determine old commit hash")
            oldhash = p.stdout.decode().strip()
            p = run(["git", "-C", dd + name, "pull", "-q", "--ff-only"])
            if p.returncode != 0:
                raise UpdateError("Error pulling updates")
            p = run(rpcmd, stdout=PIPE)
            if p.returncode != 0:
                raise UpdateError("Unable to determine new commit hash")
            newhash = p.stdout.decode().strip()
            if oldhash == newhash:
                return name, REPO_SAME, None
            else:
                self.populate_list(name)
                self.save_repos()
                ret = {}
                cmd = [
                    "git",
                    "-C",
                    dd + name,
                    "diff",
                    "--no-commit-id",
                    "--name-status",
                    oldhash,
                    newhash,
                ]
                p = run(cmd, stdout=PIPE)
                if p.returncode != 0:
                    raise UpdateError("Error in git diff")
                changed = p.stdout.strip().decode().split("\n")
                for f in changed:
                    if not f.endswith(".py"):
                        continue
                    status, cogpath = f.split("\t")
                    cogname = os.path.split(cogpath)[-1][:-3]  # strip .py
                    if status not in ret:
                        ret[status] = []
                    ret[status].append(cogname)
                return name, ret, oldhash
    except CloningError as e:
        raise CloningError(name, *e.args) from None
    except UpdateError as e:
        raise UpdateError(name, *e.args) from None


# Traceback (ValueError)
Traceback (most recent call last):
File "lib\discord\ext\commands\core.py", line 50, in wrapped
ret = yield from coro(args, **kwargs)
File "C:\Users\bot\Downloads\X\cogs\downloader.py", line 243, in update
name, updates, oldhash = await f
File "C:\Users\bot\AppData\Local\Programs\Python\Python36\lib\asyncio\tasks.py", line 452, in _wait_for_one
return f.result()  # May raise f.exception().
File "C:\Users\bot\AppData\Local\Programs\Python\Python36\lib\concurrent\futures\thread.py", line 55, in run
result = self.fn(self.args, **self.kwargs)
File "C:\Users\bot\Downloads\X\cogs\downloader.py", line 615, in update_repo
status, cogpath = f.split('\t')
ValueError: too many values to unpack (expected 2)

# Fixed code
def update_repo(self, name):
    def run(*args, **kwargs):
        env = os.environ.copy()
        env["GIT_TERMINAL_PROMPT"] = "0"
        kwargs["env"] = env
        return sp_run(*args, **kwargs)

    try:
        dd = self.path
        if name not in self.repos:
            raise UpdateError("Repo does not exist in data, wtf")
        folder = os.path.join(dd, name)
        # Make sure we don't git reset the Red folder on accident
        if not os.path.exists(os.path.join(folder, ".git")):
            # if os.path.exists(folder):
            # shutil.rmtree(folder)
            url = self.repos[name].get("url")
            if not url:
                raise UpdateError("Need to clone but no URL set")
            branch = None
            if "@" in url:  # Specific branch
                url, branch = url.rsplit("@", maxsplit=1)
            if branch is None:
                p = run(["git", "clone", url, dd + name])
            else:
                p = run(["git", "clone", "-b", branch, url, dd + name])
            if p.returncode != 0:
                raise CloningError()
            self.populate_list(name)
            return name, REPO_CLONE, None
        else:
            rpcmd = ["git", "-C", dd + name, "rev-parse", "HEAD"]
            p = run(["git", "-C", dd + name, "reset", "--hard", "origin/HEAD", "-q"])
            if p.returncode != 0:
                raise UpdateError("Error resetting to origin/HEAD")
            p = run(rpcmd, stdout=PIPE)
            if p.returncode != 0:
                raise UpdateError("Unable to determine old commit hash")
            oldhash = p.stdout.decode().strip()
            p = run(["git", "-C", dd + name, "pull", "-q", "--ff-only"])
            if p.returncode != 0:
                raise UpdateError("Error pulling updates")
            p = run(rpcmd, stdout=PIPE)
            if p.returncode != 0:
                raise UpdateError("Unable to determine new commit hash")
            newhash = p.stdout.decode().strip()
            if oldhash == newhash:
                return name, REPO_SAME, None
            else:
                self.populate_list(name)
                self.save_repos()
                ret = {}
                cmd = [
                    "git",
                    "-C",
                    dd + name,
                    "diff",
                    "--no-commit-id",
                    "--name-status",
                    oldhash,
                    newhash,
                ]
                p = run(cmd, stdout=PIPE)

                if p.returncode != 0:
                    raise UpdateError("Error in git diff")

                changed = p.stdout.strip().decode().split("\n")

                for f in changed:
                    if not f.endswith(".py"):
                        continue

                    status, _, cogpath = f.partition("\t")
                    cogname = os.path.split(cogpath)[-1][:-3]  # strip .py
                    if status not in ret:
                        ret[status] = []
                    ret[status].append(cogname)

                return name, ret, oldhash

    except CloningError as e:
        raise CloningError(name, *e.args) from None
    except UpdateError as e:
        raise UpdateError(name, *e.args) from None