Skip to content

Add p4ignore.ini support - #92

Merged
Shengyu Fu (shengyfu) merged 6 commits into
mainfrom
shengyfu-support-p4ignore
Aug 17, 2026
Merged

Add p4ignore.ini support#92
Shengyu Fu (shengyfu) merged 6 commits into
mainfrom
shengyfu-support-p4ignore

Conversation

@shengyfu

@shengyfu Shengyu Fu (shengyfu) commented Aug 17, 2026

Copy link
Copy Markdown
Member

Summary

  • load root-level p4ignore.ini rules alongside Git ignore rules
  • normalize Windows path separators and preserve negated re-inclusions
  • prune ignored subtrees during indexing, file counting, and metadata scans
  • apply the same rules to watcher event filtering
  • propagate --no-ignore consistently through search, counting, indexing, serving, reloads, and stale scans
  • include global Git ignore rules in watcher matching with local rules taking precedence
  • rebuild ignore matchers and reconcile indexed paths when .gitignore or p4ignore.ini changes while serving
  • document Perforce ignore behavior and --no-ignore semantics

Validation

  • cargo test --workspace --quiet
  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --quiet -- -D warnings

Recognize root-level p4ignore.ini rules across indexing, metadata scans, file counting, and watcher filtering. Normalize Windows separators and preserve negated re-inclusions while pruning ignored subtrees.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 379a17fb-47de-4e29-9192-322b10af777b
Copilot AI lite review requested due to automatic review settings August 17, 2026 18:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds Perforce-style ignore support by loading root-level p4ignore.ini rules alongside existing Git ignore behavior, and applies those rules consistently during directory walks, metadata scans, and watcher filtering.

Changes:

  • Introduce p4ignore.ini parsing/matching (including Windows separator normalization and ! re-includes).
  • Prune p4ignored subtrees during indexing walks, file metadata scans, and .gitignore discovery for watcher matchers.
  • Update CLI/README docs to mention p4ignore.ini under --no-ignore.
Show a summary per file
File Description
tgrep-core/src/walker.rs Adds p4ignore-based pruning to repo walks and metadata scans; includes tests.
tgrep-core/src/gitignore.rs Implements p4ignore parsing/matcher and integrates rules into point-query ignore matcher.
tgrep-cli/src/main.rs Updates --no-ignore help text to mention p4ignore.ini.
README.md Documents p4ignore support and updates --no-ignore description.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 4/4 changed files
  • Comments generated: 4
  • Review effort level: Lite

Comment thread tgrep-core/src/walker.rs
Comment thread tgrep-core/src/gitignore.rs
Comment thread tgrep-cli/src/main.rs
Comment thread README.md
Propagate --no-ignore through index and serve discovery, include global Git excludes in watcher matching, and reconcile live indexes when ignore files change.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 379a17fb-47de-4e29-9192-322b10af777b
Copilot AI review requested due to automatic review settings August 17, 2026 20:11
Signed-off-by: Shengyu Fu <shengyfu@microsoft.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 9/9 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread tgrep-core/src/gitignore.rs
Comment thread tgrep-cli/src/serve.rs Outdated
Copilot AI review requested due to automatic review settings August 17, 2026 20:17
Keep .gitignore files discoverable when p4ignore.ini excludes them, and consolidate serve options after the latest main merge.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 379a17fb-47de-4e29-9192-322b10af777b

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 9/9 changed files
  • Comments generated: 3
  • Review effort level: Lite

Comment thread tgrep-core/src/walker.rs
Comment thread tgrep-cli/src/serve.rs Outdated
Comment thread tgrep-cli/src/serve.rs Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 379a17fb-47de-4e29-9192-322b10af777b
Copilot AI review requested due to automatic review settings August 17, 2026 20:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

Suppressed comments (4)

Previously missed (4) — in code that hasn't changed since the last review.

tgrep-core/src/walker.rs:206

  • p4ignore.ini rules are added to the point-query builder before .gitignore rules. Since gitignore pattern order is “last match wins”, a later .gitignore whitelist can override an earlier p4ignore ignore, but the actual directory walk applies p4ignore as a hard filter_entry (so .gitignore cannot override it). This mismatch can let the watcher upsert files the initial walk would never index, causing divergence. To mirror the walker's behavior, add p4ignore rules after .gitignore rules so p4ignore has higher precedence (or otherwise make both paths use the same precedence model).
    let info_exclude = root.join(".git").join("info").join("exclude");
    if info_exclude.is_file() {
        let _ = builder.add(&info_exclude);
    }
    crate::gitignore::add_p4ignore_rules(&mut builder, root);

tgrep-core/src/gitignore.rs:198

  • build_matcher adds p4ignore.ini rules before discovering/adding .gitignore rules. Because gitignore precedence is order-dependent, this allows a later .gitignore whitelist to override an earlier p4ignore ignore, but the actual filesystem walk applies p4ignore via a separate filter_entry (effectively higher precedence). That inconsistency can make the watcher treat paths as indexable that the walker would have pruned. A minimal way to align semantics is to (re-)add p4ignore rules after the .gitignore discovery loop so p4ignore patterns come last.
    for entry in walker.flatten() {
        if entry.file_name() == ".gitignore" && entry.path().is_file() {
            let _ = builder.add(entry.path());
        }
    }

tgrep-cli/src/serve.rs:1316

  • When indexed_paths is Some (ignore-rule reconciliation) but old_stamps is empty (e.g., filestamps missing/corrupt), the current logic classifies every already-indexed file as added because the stamp lookup always returns None. That can trigger a full reindex on any ignore-rule change even though the reconciliation mode already has indexed_paths and could limit work to membership changes (newly-unignored / newly-ignored). Consider short-circuiting the stamp comparison when indexed_paths.is_some() and old_stamps.is_empty() to avoid reindexing everything unnecessarily.
        match old_stamps.get(&fm.relative_path) {
            Some(old) if *old == stamp => {}
            Some(_) => changed.push(fm.relative_path.clone()),
            None => added.push(fm.relative_path.clone()),
        }

Cargo.toml:6

  • This PR is scoped to adding p4ignore.ini support, but it also bumps the workspace version from 0.1.21 to 1.0.0. If this is intentional (a 1.0 release), it should be called out explicitly in the PR description / release notes; otherwise, consider splitting it into a separate release PR to keep changes focused.
[workspace.package]
version = "1.0.0"
  • Files reviewed: 10/11 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Limit Perforce ignore refreshes to the supported root file and ensure watcher event bursts share a single refresh worker.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 379a17fb-47de-4e29-9192-322b10af777b
Copilot AI review requested due to automatic review settings August 17, 2026 20:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

Cargo.toml:6

  • Workspace version is bumped to 1.0.0 as part of this PR, but the PR description is focused on ignore-rule behavior and doesn’t mention a release/versioning change. Since this affects downstream consumers and release notes, either document the version bump in the PR description (or changelog), or split the version bump into a dedicated release PR if that was not intended.
version = "1.0.0"
  • Files reviewed: 10/11 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread tgrep-cli/src/serve.rs
@shengyfu
Shengyu Fu (shengyfu) merged commit e32b3c9 into main Aug 17, 2026
10 checks passed
@shengyfu
Shengyu Fu (shengyfu) deleted the shengyfu-support-p4ignore branch August 17, 2026 22:12
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.

3 participants