Skip to content

index.add('.') adds even .git directory into the index, and adds files also with ./ prefix #375

Open
@yarikoptic

Description

@yarikoptic

Compare how stock git does it (related: there was this noise about security issue of having case-insensitive filesystems and .Git file in a repo):

$> rm -rf /tmp/123; mkdir /tmp/123; cd /tmp/123; git init; echo 1 > 1; git add 1; git status                                                                      
Initialized empty Git repository in /tmp/123/.git/
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

    new file:   1

and how GitPython (as of 1.0.1-74-gc8b8379 as in Debian):

$> rm -rf /tmp/123; mkdir /tmp/123; cd /tmp/123; git init; echo 1 > 1; python -c 'import git; r=git.Repo("/tmp/123"); r.index.add(".")'; git status
Initialized empty Git repository in /tmp/123/.git/
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

    new file:   ./.git/HEAD
    new file:   ./.git/config
    new file:   ./.git/description
    new file:   ./.git/hooks/applypatch-msg.sample
    new file:   ./.git/hooks/commit-msg.sample
    new file:   ./.git/hooks/post-update.sample
    new file:   ./.git/hooks/pre-applypatch.sample
    new file:   ./.git/hooks/pre-commit.sample
    new file:   ./.git/hooks/pre-push.sample
    new file:   ./.git/hooks/pre-rebase.sample
    new file:   ./.git/hooks/prepare-commit-msg.sample
    new file:   ./.git/hooks/update.sample
    new file:   ./.git/info/exclude
    new file:   ./.git/objects/49/8b267a8c7812490d6479839c5577eaaec79d62
    new file:   ./.git/objects/51/5f4836297fdf7567c066983c16e5eff598f7bd
    new file:   ./.git/objects/cb/089cd89a7d7686d284d8761201649346b5aa1c
    new file:   ./.git/objects/d0/0491fd7e5bb6fa28c517a0bb32b8b506539d4d
    new file:   ./1

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    1

not sure why git says that 1 is untracked but ./1 was added... I guess also GitPython intricacy

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions