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

Already on GitHub? Sign in to your account

.gitignore globs broken when specifying an absolute path #448

jdelStrother opened this Issue Jul 16, 2014 · 5 comments


None yet
6 participants

Hi there - I'm using ag 0.23.0 with unite.vim. I have a gitignore file at /my/directory/.gitignore, which contains a line public/assets*. When I run

  ag -g "application*" /my/directory

, it includes files in /my/directory/public/assets-production - which it shouldn't, given the .gitignore line.

Strangely, if I use a relative path for the last argument -

  ag -g "application*" .

, .gitignore gets parsed correctly, and files in public/assets-production are filtered out. Similarly, if I explicitly list public/assets-production in my .gitignore, that will also filter those results out, even when using the absolute path.

Bug, or am I missing something?

mmwtsn commented Jul 29, 2014

This may have been fixed in release v0.24 after pull request #401 was merged in. Ag has been experiencing a bug for a few months regarding ignore files. There is a fair bit of discussion in issue #385.

I'm still seeing this in 0.24, unfortunately

LeonB commented Aug 25, 2014

I'm having the same issue:

leon@polly:~/Public/advertentietool$ pwd
leon@polly:~/Public/advertentietool$ ag --follow --nocolor  -g "" . | wc -l
leon@polly:~/Public/advertentietool$ ag --follow --nocolor  -g "" `pwd` | wc -l
leon@polly:~/Public/advertentietool$ ag -V
ag version 0.24.1

@ggreer ggreer added the ignore label Sep 26, 2014

@ggreer ggreer closed this in a706fad Oct 24, 2014

vmrob commented Aug 20, 2016 edited

Curiously, the fix here actually breaks the following search:

$ tree -a
└── test
    ├── .gitignore
    └── foo

1 directory, 2 files
$ cat test/.gitignore 
$ cat test/foo
$ ag bar test

Reverting to ignores *ig = init_ignore(root_ignores, paths[i], strlen(paths[i])); fixes the above, but reintroduces this issue. I suppose the issue centers around the handling of absolute/relative paths and ignore patterns from root to those paths. A workaround is to use foo instead of /foo in .gitignore, but I think that's really just a hack.

deiwin commented May 2, 2017

I'm still seeing something similar. When an absolute path is used instead of a relative one, then the local .gitignore will be ignored. The global gitignore is still considered in both cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment