exa treats gitignore `/`s literally

Created on 29 Mar 2018  ยท  4Comments  ยท  Source: ogham/exa

Example test:

Take the following repository structure:

.
โ”œโ”€โ”€ .gitignore
โ””โ”€โ”€ a
โ”‚  โ””โ”€โ”€ x
โ””โ”€โ”€ b
   โ””โ”€โ”€ x

with the contents of .gitignore being:

a/
/b

exa --tree --git-ignore will show all of the files.
In comparison, fd and rg --files will show no output.

Most helpful comment

Since there appears to be some confusion, let's clarify:
This is the gitignore documentation, and should serve as the implementation basis for any gitignore-related functionality.

As per said documentation:

A leading slash matches the beginning of the pathname. For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".

In terms of being relative to the filesystem, git does not consider the filesystem paths because git has no control over where the checkout happens. If someone has a checkout in /git/x and has /git/x/y in the gitignore, what happens if someone checked the same repository out in ~/x?

Gitignore only makes sense in the scope of git (rather than the larger filesystem) and thus must not consider anything outside of the repository (including in alternative implemetations, such as here).

(requirement keywords as per rfc2119)

All 4 comments

I came here to post this. For bizarre reasons / is considered by gitignore to be the root of the _repository_, not the filesystem.

I use a leading "/" quite often to block objects that only appear at the root of a repo, like "/target" for Rust/Cargo projects. I was pretty confused to see exa listing them when --git-ignore is specified.

I came here to post this. For bizarre reasons / is considered by gitignore to be the root of the _repository_, not the filesystem.

Doesn't seem that bizarre; this seems like a reasonable convention to indicate you want to ignore "project_root/target" but not "project_root/src/target"

Since there appears to be some confusion, let's clarify:
This is the gitignore documentation, and should serve as the implementation basis for any gitignore-related functionality.

As per said documentation:

A leading slash matches the beginning of the pathname. For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".

In terms of being relative to the filesystem, git does not consider the filesystem paths because git has no control over where the checkout happens. If someone has a checkout in /git/x and has /git/x/y in the gitignore, what happens if someone checked the same repository out in ~/x?

Gitignore only makes sense in the scope of git (rather than the larger filesystem) and thus must not consider anything outside of the repository (including in alternative implemetations, such as here).

(requirement keywords as per rfc2119)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

raxod502 picture raxod502  ยท  5Comments

huxi picture huxi  ยท  3Comments

photex picture photex  ยท  4Comments

dbohdan picture dbohdan  ยท  6Comments

mikemadden42 picture mikemadden42  ยท  3Comments