libgit2 / libgit2/libgit2sharp

.gitignore exclusions not being honoring correctly

Open
#1,416 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
3.5k
Forks
925
PR merge metrics
No merged PRs in 30d

Description

Hello,

I am having an issue with inconsistent behavior when trying to exclude folders using a .gitignore. This issue is related to: https://github.com/git-tfs/git-tfs/issues/1047

Given the following repository directory:

/Main/.gitignore
/Main/Foo/test.txt
/Main/Foo/packages/test.txt
/Main/FooBar/test.txt
/Main/FooBar/packages/test.txt

And the following .gitignore file:

**/packages/*
!Foo/
!Foo/**

When I running the following code:

using (var repo = new Repository(@"C:\Git\Project\Main"))
{
	repo.RetrieveStatus().Untracked.Dump();
}

Then I get to following results:

.gitignore
Foo\test.txt
FooBar\test.txt

When I run git status -u
Then I get to following results:

.gitignore
Foo/packages/test.txt
Foo/test.txt
FooBar/test.txt

I have also tried populating the ignore rules manually using AddTemporaryRules with the same results.

Thanks!

Christopher Haws

git version 2.10.2.windows.1
LibGit2Sharp version 0.23.1

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

Reproduce the report with Repository.RetrieveStatus and the shown nested .gitignore rules, then compare its Untracked results with git status -u. Also check the AddTemporaryRules path, and consider the issue done when negated directory rules produce the same included files as Git.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, git
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.