Hi,
I don't know if you are aware of this, but the gitignore implementation is slightly different to the original gitignore implementation regarding absolute paths.
Imagine I have a repository and I have the following filepath internal/util/parse.go. In the original gitignore file I can just use parse.go to exclude the parse.go file. This is not the case for go-git's gitignore. If I just specify parse.go it will not match on an absolute path like internal/util/parse.go or /tmp/internal/util/parse.go.
You can verify this behavior via:
mkdir -p /tmp/test/internal/util
touch /tmp/test/internal/util/parse.go
cd /tmp/test/
git init
echo "parse.go" > .gitignore
If you check the status of the repository via git status you will see, that the parse.go file in /tmp/test/internal/util/parse.go is being excluded.
This is not the case for go-git. For example in our project: https://github.com/in-toto/in-toto-golang/blob/92c7c374bb0f3b9b55c54c20bc933b9be94d8477/in_toto/runlib.go#L77
We are using the gitignore matcher and we try to match on the following:
// path = "/tmp/in_toto_test_dir711641952/foo.tar.gz
// regex is: "foo.tar.gz"
match := m.Match([]string{path}, fileInfo.IsDir())
This should actually match (like in the real gitignore), and the path should get excluded.
Hi,
I don't know if you are aware of this, but the gitignore implementation is slightly different to the original gitignore implementation regarding absolute paths.
Imagine I have a repository and I have the following filepath
internal/util/parse.go. In the original gitignore file I can just useparse.goto exclude theparse.gofile. This is not the case for go-git's gitignore. If I just specifyparse.goit will not match on an absolute path likeinternal/util/parse.goor/tmp/internal/util/parse.go.You can verify this behavior via:
If you check the status of the repository via
git statusyou will see, that the parse.go file in/tmp/test/internal/util/parse.gois being excluded.This is not the case for go-git. For example in our project: https://github.com/in-toto/in-toto-golang/blob/92c7c374bb0f3b9b55c54c20bc933b9be94d8477/in_toto/runlib.go#L77
We are using the gitignore matcher and we try to match on the following:
This should actually match (like in the real gitignore), and the path should get excluded.