Skip to content

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

Closed
wyf027 wants to merge 2 commits into
sharkdp:masterfrom
wyf027:feat/jujutsu-gitignore-1817
Closed

feat: respect .gitignore in Jujutsu (.jj) repositories#2016
wyf027 wants to merge 2 commits into
sharkdp:masterfrom
wyf027:feat/jujutsu-gitignore-1817

Conversation

@wyf027

@wyf027 wyf027 commented May 26, 2026

Copy link
Copy Markdown
Contributor

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 #1817

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

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

Copy link
Copy Markdown

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 Outdated

!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 Outdated
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 👍 / 👎.

@tmccombs tmccombs left a comment

Copy link
Copy Markdown
Collaborator

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.

@wyf027

wyf027 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the review feedback and CI failure in commit 3267318. The .jj detection now resolves relative search paths against the current directory and only relaxes require_git when all search paths are inside a Jujutsu repo, so a mixed set of .jj and non-.jj search paths no longer disables the git requirement globally. Also ran cargo fmt to clear the formatter check.

Local verification:

  • cargo fmt --check
  • cargo test should_require_git
  • cargo test detects_jujutsu_repo_for_relative_search_path
  • cargo test test_jujutsu_repo_respects_gitignore
  • cargo clippy --all-targets -- -D warnings

@tmccombs

tmccombs commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

This now has the opposite problem where it will only use gitignore if all the base paths have .jj directories. And furthermore, doesn't handle cases where a subdirectory has a .jj dir, or has a .gitignore file, but not a .git OR .jj directory.

I really think this would be better handled by looking for .jj directories in the ignore crate itself, and would suggest you instead open a PR with ripgrep.

In lieu of that, along with my suspicion that this is AI slop that hasn't had human review. I am closing this PR.

@tmccombs tmccombs closed this Jun 8, 2026
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