libgit2 / libgit2/pygit2

Repository object init with literal GIT_DIR

Open
#906 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
Python
Stars
1.7k
Forks
408
Avg merge
2d 57m
Merged PRs (30d)
7

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the pygit2.Repository initialization entry point and compare its handling of "./" with Git's literal GIT_DIR behavior. Check the available libgit2 repository-opening behavior before deciding how a literal path should be represented. Done means a Repository can target /tmp/weird.git without discovering /tmp/weird.git/.git, with coverage for this nested-repository case.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, python
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.