Skip to content

feat: respect .gitignore in Jujutsu (.jj) repositories#2016

Open
leno23 wants to merge 1 commit into
sharkdp:masterfrom
leno23:feat/jujutsu-gitignore-1817
Open

feat: respect .gitignore in Jujutsu (.jj) repositories#2016
leno23 wants to merge 1 commit into
sharkdp:masterfrom
leno23:feat/jujutsu-gitignore-1817

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 26, 2026

Summary

Fixes #1817.

Jujutsu repositories use a .jj directory and still rely on .gitignore files, but fd only applies gitignore rules without a .git directory when --no-require-git is passed.

When any search path is inside a Jujutsu repository (a .jj directory exists in an ancestor path), automatically treat the search like --no-require-git unless the user explicitly passes --require-git.

Test plan

  • cargo test --locked jujutsu
  • New integration test test_jujutsu_repo_respects_gitignore
  • Unit test should_require_git_in_jujutsu_repo

Jujutsu repos use a `.jj` directory instead of `.git` but still rely on
`.gitignore` files. Automatically disable require_git when searching
inside such repositories, matching the behavior of --no-require-git.

Fixes sharkdp#1817

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ce5b739316

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/walk.rs

!search_paths
.iter()
.any(|path| path.ancestors().any(|ancestor| ancestor.join(".jj").is_dir()))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Resolve search paths before scanning ancestors for .jj

path.ancestors() only walks lexical components of the provided search path, so for the common default ./ (or other relative paths) it never reaches parent directories above the current working directory. That means running fd from a subdirectory inside a Jujutsu repo (where .jj is at the repo root) will not be detected here, and .gitignore rules still won’t apply unless the user is at the root or passes an absolute path, which defeats the new feature for many real invocations.

Useful? React with 👍 / 👎.

Comment thread src/walk.rs
Comment on lines +708 to +714
if no_require_git {
return false;
}

!search_paths
.iter()
.any(|path| path.ancestors().any(|ancestor| ancestor.join(".jj").is_dir()))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor explicit --require-git in Jujutsu repositories

This helper cannot distinguish “default behavior” from an explicit --require-git, because it only receives no_require_git; as soon as .jj is found it always returns false (do not require git). In a Jujutsu repo this makes --require-git ineffective, even though the intended behavior and existing flag semantics rely on explicit override precedence.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator

@tmccombs tmccombs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to address this upstream in the ignore crate.

Also this doesn't handle if the search paths are relative, and if one search path has a .jj directory but others don't, it disables requiring a .git (or .jj) directory for all of them, which probably isn't desirable.

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.

Support for .gitignore with .jj (Jujutsu VCS) repositories

2 participants