Skip to content

Repository object init with literal GIT_DIR #906

Open
@gobenji

Description

@gobenji

Consider the following corner case:

ben@f1:/tmp$ git init --bare weird.git
Initialized empty Git repository in /tmp/weird.git/                                              
ben@f1:/tmp$ cd weird.git
ben@f1:/tmp/weird.git$ git init --bare .git
Initialized empty Git repository in /tmp/weird.git/.git/                                         
ben@f1:/tmp/weird.git$ git rev-parse --git-dir
.git
ben@f1:/tmp/weird.git$ GIT_DIR="./" git rev-parse --git-dir                                      
./
ben@f1:/tmp/weird.git$ python3 -c 'import pygit2; print(pygit2.Repository("./"))'                
pygit2.Repository('/tmp/weird.git/.git/')
ben@f1:/tmp/weird.git$ GIT_DIR=./ python3 -c 'import pygit2; print(pygit2.Repository("./"))'     
pygit2.Repository('/tmp/weird.git/.git/')

It's possible to use git to work on the repo with GIT_DIR="/tmp/weird.git".

How can I use pygit2 to work on the same repo ("/tmp/weird.git") and not the other repo in "/tmp/weird.git/.git"? Essentially, I'd like to init a pygit2.Repository object with a literal GIT_DIR, without performing repository discovery.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions