8000 Ignore rules are not always respected — depending on ordering of rules and check-in status of other files · Issue #3535 · libgit2/libgit2 · GitHub
[go: up one dir, main page]

Skip to content
Ignore rules are not always respected — depending on ordering of rules and check-in status of other files #3535
Open
@mcdado

Description

@mcdado

While using GitUp I noticed some strange behaviors that I reported to @swisspol, the author of GitUp.

I reported the problem on the GitUp forum but it seems to be a libgit2 bug, which GitUp uses to interface with the repository and .gitignore files.

GitUp uses a slightly forked version of libgit2 which is based on e0ab1ca as of GitUp b1009 (which still shows the problem).

I created a demo repo on GitHub to showcase the problem.

I will use GitUp as a reference, but its behavior should depend on libgit2 as far as I know, so please excuse me if I use its own behavior as the culprit.

Here are the steps that I followed (details below):
screen shot 2015-12-06 at 00 19 17

  1. Create and commit a .htaccess and .gitignore file in the root of the project. .gitignore ignores everything and then adds some exceptions, for itself and for the .htaccess file.
  2. Create a test/ directory with a test file in it, in my case the file is test.php
  3. Create a .htaccess in the test/ directory with some dull content in it

So far so good. Now things start to get messy.

  1. Force add test/test.php even if it's in a ignored path and commit

After adding a file in the test/ directory that is ignored, now the base .gitignore rule is applied to this directory too, and GitUp shows the .htaccess file.
screen shot 2015-12-06 at 13 08 07

  1. Try removing the test.php file: git rm test/test.php, and the .htaccess file disappears.
    screen shot 2015-12-06 at 13 08 41
  2. Try force-adding another file, for example a dummy test/robots.txt file, and even before committing, the .htaccess file appears
    screen shot 2015-12-06 at 13 08 23

As you can see in the first screenshot, git correctly ignores the files in the ignored directory (you can see a git st which is alias for git status. I originally experience this bug with a node_modules directory not being ignored, which is a problem because there are a ton of files in the working directory that should be ignored and create a lot of noise.

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

      0