Skip to content

Failed to initialize repository while the path contains "~" #83

Closed

Description

@tonyseek

I have tried to initialize a repository using a short path which contains "~", a exception be raised:

>>> repo = git.Repo.init("~/test.git", bare=True)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File ".../lib/python2.7/site-packages/git/repo/base.py", line 657, in init
    return Repo(path)
  File ".../lib/python2.7/site-packages/git/repo/base.py", line 98, in __init__
    raise NoSuchPathError(epath)
NoSuchPathError: /home/username/test.git

If I create the target directory first, it will be another exception:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File ".../lib/python2.7/site-packages/git/repo/base.py", line 657, in init
    return Repo(path)
  File ".../lib/python2.7/site-packages/git/repo/base.py", line 122, in __init__
    raise InvalidGitRepositoryError(epath)
InvalidGitRepositoryError: /home/username/test.git

But while I use the full path without any character ~ instead of, it works.

>>> repo = git.Repo.init("/home/username/test.git", bare=True)
>>> repo
<git.Repo "/home/username/test.git">
>>> 

Activity

  1. added this to the v0.3.5 - bugfixes milestone on Nov 19, 2014
  2. Byron commented on Nov 19, 2014

    @Byron
    Member

    Even though I wouldn't expect git-python to handle "~", as it's functionality of the shell, I'd expect it to fail gracefully or to work.

  3. self-assigned this
    on Jan 10, 2015
  4. Byron commented on Jan 10, 2015

    @Byron
    Member

    This issue is fixed, and verified by a new test-case.

    Also there is a video on youtube showing the process of fixing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions