Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix - Negation of rules #3894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Fix - Negation of rules #3894

wants to merge 1 commit into from

Conversation

tgandrews
Copy link

Currently, negative rules are thrown away if they do not affect a rule before.
This change adds a test which failed before but works now that we no longer
throw away negative rules.

I have tried to prove this with tests but I think more are required to cover this.

Currently negative rules are thrown away if they do not affect a rule before.
This change adds a test which failed before but works now that we no longer
throw away negative rules.
@tgandrews tgandrews changed the title 🪲 Fix - Negation of rules 🐛 Fix - Negation of rules Aug 10, 2016
@tgandrews tgandrews changed the title 🐛 Fix - Negation of rules Fix - Negation of rules Aug 10, 2016
@tgandrews
Copy link
Author

I think the failing tests are wrong but have not removed them so that we can have a discussion.

@pks-t
Copy link
Member

pks-t commented Aug 11, 2016

No, the tests are actually correct in that they match the behavior of git.git. The following little hacky script tests this against upstream:

#!/bin/sh

REPO="$(mktemp -d)"

trap "rm -rf \"$REPO\"" EXIT

cd "$REPO"
git init -q

cat > .gitignore <<EOF
foo.txt
parent/child1
parent/child2
parent/child4
parent/nested/child5
nested/child6
nested/child7
padded_parent/child8
!parent/child1
!parent/child2/bar.txt
!parent/child3
!child4
!nested/child5
!nested/child6
!child7/
!_parent/child8
top
!top/mid/btm
zoo/*
!zoo/bar
!zoo/foo/bar
EOF

for path in "padded_parent/child8/bar.txt" "parent/child2/bar.txt" "parent/child3/foo.txt" "parent/nested/child5/bar.txt" "top/mid/btm/tracked" "top/mid/btm/untracked"
do
    if ! git check-ignore -q "$path"
    then
        echo "$path should have been ignored"
        exit 1
    fi
done

for path in "parent/child1/bar.txt" "parent/child4/bar.txt" "parent/nested/child6/bar.txt" "parent/nested/child7/bar.txt" "foo/bar"
do
    if git check-ignore -q "$path"
    then
        echo "$path should not have been ignored"
        exit 1
    fi
done

@tgandrews
Copy link
Author

tgandrews commented Aug 11, 2016

OK - I have clearly misunderstood this.

The problem I am having is the scenario I have created the test for:

A .gitignore containing

bar.txt
!parent/child/bar.txt

Currently libgit2 says the child bar.txt is ignored but git does not. I guess this needs work. I will look further into it and re-open when resolved.

@pks-t
Copy link
Member

pks-t commented Aug 12, 2016

Well, you're actually correct with your observation that we fail to treat your case correctly. Created a new PR which should fix your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants