phil294 / GitLG

A free, interactive Git UI for VSCode
MIT License
156 stars 16 forks source link

Error when no commits / no repository #71

Open Amanoki opened 9 months ago

Amanoki commented 9 months ago
  1. The following error happens:

    • when there is no commit in the repository;
    • when the initial commit is undone and no commits left. The initial commit will still show up in the list and the error pops up if clicking on the refresh button. If I make a different initial commit, the error no longer appears but the old initial commit still doesn't disappear.
      git-log--graph: git log --graph extension encountered an unexpected error. Sorry! Error summary: {"code":128,"killed":false,"signal":null,"cmd":"git rev-parse --abbrev-ref HEAD","stdout":"HEAD\n","stderr":"fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.\nUse '--' to separate paths from revisions, like this:\n'git <command> [<revision>...] -- [<file>...]'\n"}. For details, see VSCode developer console. Please consider reporting this error.
  2. The following error happens when opening a workspace with no .git folder.

    git-log--graph: git log --graph extension encountered an unexpected error. Sorry! Error summary: {}. For details, see VSCode developer console. Please consider reporting this error.
phil294 commented 9 months ago

hey, thanks for reporting this, but I think it's unlikely I will fix it. This is pretty much a non-problem because why would anybody use a git extension in an empty repository? And more importantly, this extension is by design very direct in its calls to git. There aren't many safety wrappers or state guards, so this minor issue would probably need a lot of work to work fine under all scenarios (what if you are missing permissions? what if you delete the initial commit after loading successful once? what if your .git folder is broken? What if you delete your .git folder after extension start? etc)

Hope I didn't misunderstand you. I'll close this as wontfix. Please don't feel discouraged to open new issues though!

phil294 commented 9 months ago

The following error happens when opening a workspace with no .git folder.

~I didn't even know that was possible. Not allowing this would indeed be good.~ (Nvm: I misunderstood)

Same thing - the extension just requires some repo to be available, otherwise all kinds of logic breaks down.

Amanoki commented 9 months ago

Hello, let me clarify:

  • when there is no commit in the repository;

This happened when I newly added the .git folder without making any commit yet.

  • when the initial commit is undone and no commits left.

This happened exactly when I deleted the initial commit after loading successfully once. The error itself may not be a problem but the problem is that this deleted initial commit kept staying in the list and didn't disappear even after new commits were created, unless I deleted and recreated a new repo.

2. The following error happens when opening a workspace with no .git folder.

Not that I intentionally want to use it but the error simply shows up whenever I open non-git projects when this extension is installed. Though this can be easily solved, I just need to disable it for non-git workspaces in VS Code settings.

I hope this explains the situations! As a user I would normally expect the extension to run quietly or not run in these cases instead of popping up error messages every time. It would be nice if they could be fixed, but if not it is indeed not a big problem as most can be solved on my side. (Except for the second point: I would like to know if there is any other way to make the deleted initial commit disappear rather than deleting & recreating the whole repo!)