goldstar611 / gitless

A maintained fork of the simple git interface
https://goldstar611.github.io/gitless/
MIT License
26 stars 2 forks source link

gl crashes in repo with no commits #10

Closed goldstar611 closed 2 years ago

goldstar611 commented 2 years ago
user@host /tmp/gl-core-test0l6rlbpr $ git init
Initialized empty Git repository in /tmp/gl-core-test0l6rlbpr/.git/

user@host /tmp/gl-core-test0l6rlbpr $ gl status
Traceback (most recent call last):
  File "/usr/local/bin/gl", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/dist-packages/gitless/cli/gl.py", line 97, in main
    parser = build_parser(sub_cmds, repo)
  File "/usr/local/lib/python3.7/dist-packages/gitless/cli/gl.py", line 79, in build_parser
    sub_cmd.parser(subparsers, repo)
  File "/usr/local/lib/python3.7/dist-packages/gitless/cli/file_cmd.py", line 19, in f
    skip_dir_test=repo and repo.current_branch.path_is_ignored,
  File "/usr/local/lib/python3.7/dist-packages/gitless/core.py", line 222, in current_branch
    b = self.git_repo.head
_pygit2.GitError: reference 'refs/heads/master' not found
goldstar611 commented 2 years ago

For someone who comes from git to gl it's easy to keep typing git init instead of gl init There's a number of assumptions in the code that a branch is available and a head is present.