Skip to content
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

Option to ignore git submodules #23

Closed
Mmdixon opened this issue Sep 23, 2016 · 9 comments
Closed

Option to ignore git submodules #23

Mmdixon opened this issue Sep 23, 2016 · 9 comments
Labels
enhancement An enhancement to the functionality of the software. help wanted Others are encouraged to work on this issue.

Comments

@Mmdixon
Copy link

Mmdixon commented Sep 23, 2016

git grep by default does not search for files within a git submodule, even though they appear like normal directories.
rg on the other hand will by default recurse into these directories.

Since .gitignore is supported, it would be convenient to support how git searches when there are submodules. (Either by default and turn off with one of the -u flags, or provide some other flag besides explicitly black listing the submodule folders.)

@BurntSushi
Copy link
Owner

How can rg detect whether a directory is a submodule or not?

(Running a git command is not something I want to do.)

@BurntSushi
Copy link
Owner

I'd like to close this. If there's a simple way to detect submodules that doesn't sacrifice performance, I might be willing to support that. One thing I'm worried about is that I personally don't have much experience with submodules, so I don't know whether it's the Right Thing to ignore them or not. My suspicion is yes, it is right, because I tend to see them used as a way to vendor dependencies.

@mengelbrecht
Copy link

If it is going to be implemented please make it optional. Internal libraries shared between multiple projects can also be included as submodules. In that case I want to search them too e.g. when performing a global refactoring.

@BurntSushi BurntSushi added the question An issue that is lacking clarity on one or more points. label Sep 25, 2016
@Mmdixon
Copy link
Author

Mmdixon commented Sep 26, 2016

@BurntSushi there will be a .gitmodules file with a list of the following format:

[submodule "myName"]
    path = src/myName
    url = someUrl
# repeat

Here, the path has the folder src/myName the start of the submodule (which is another git repository).

@Kha
Copy link

Kha commented Sep 26, 2016

More importantly, there should be a .git file in the submodule workdir. So a general option to ignore nested repositories should cover submodules.

@Mmdixon
Copy link
Author

Mmdixon commented Sep 26, 2016

ah that is true too, a .git file instead of folder in the submodule directory.

@BurntSushi
Copy link
Owner

I think the .git file thing is a newer feature of git though?

I think I'd like to ask that you use .ignore files to explicitly skip searching submodule directories.

With that said, if someone submitted a PR to the ignore crate that added support for ignoring submodules (which was disabled by default), then I'd be OK adding a new flag to ripgrep to enable that.

@BurntSushi BurntSushi added enhancement An enhancement to the functionality of the software. help wanted Others are encouraged to work on this issue. and removed question An issue that is lacking clarity on one or more points. labels Nov 6, 2016
@BurntSushi
Copy link
Owner

I'm going to close this as part of a process of culling the issue tracker to things that are likely to be implemented. I think my previous comment still stands, but I would still rather not add a new flag and instead just insist that this be part of using ripgrep's .ignore file functionality.

@BatmanAoD
Copy link

Would you still be open to a PR on the ignore crate to support ignoring nested git directories?

I think the .git file thing is a newer feature of git though?

If I understand correctly, the idea is just to check for the existence of the standard .git/ directory containing git metadata, so not a new feature of git at all. I.e., the check would be something like:

  • when searching in a git repository rooted at /repo/root,
  • if /repo/root/foo/bar/.git/ exists,
  • ignore all of /repo/root/foo/bar.

zaneduffield added a commit to zaneduffield/ripgrep that referenced this issue Mar 9, 2024
This implements the suggestion made in BurntSushi#23 to provide an option to ignore nested
git repositories.

A nested git repository is identified by the presence of a .git file or
directory. It's a directory in the regular case, but it's a file for git
worktrees and git submodules.

This option is disabled by default.
zaneduffield added a commit to zaneduffield/ripgrep that referenced this issue Mar 9, 2024
This implements the suggestion made in BurntSushi#23 to provide an option to ignore nested
git repositories.

A nested git repository is identified by the presence of a .git file or
directory. It's a directory in the regular case, but it's a file for git
worktrees and git submodules.

This option is disabled by default.
zaneduffield added a commit to zaneduffield/ripgrep that referenced this issue Mar 9, 2024
This implements the suggestion made in BurntSushi#23 to provide an option to ignore nested
git repositories.

A nested git repository is identified by the presence of a .git file or
directory. It's a directory in the regular case, but it's a file for git
worktrees and git submodules.

This option is disabled by default.
dbarnett added a commit to insanum/gcalcli that referenced this issue Sep 18, 2024
Helps ripgrep defaults handle them properly while waiting for ripgrep to
get submodule support built-in (BurntSushi/ripgrep#23).
dbarnett added a commit to insanum/gcalcli that referenced this issue Sep 18, 2024
Helps ripgrep defaults handle them properly while waiting for ripgrep to
get submodule support built-in (BurntSushi/ripgrep#23).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement to the functionality of the software. help wanted Others are encouraged to work on this issue.
Projects
None yet
Development

No branches or pull requests

5 participants