Skip to content

In --experimental, don't report git untracked files as skipped with --use-git-ignore#577

Merged
maciejpirog merged 4 commits intomainfrom
mpir/experimental-git-untracked-file-is-not-error
Feb 12, 2026
Merged

In --experimental, don't report git untracked files as skipped with --use-git-ignore#577
maciejpirog merged 4 commits intomainfrom
mpir/experimental-git-untracked-file-is-not-error

Conversation

@maciejpirog
Copy link
Contributor

@maciejpirog maciejpirog commented Feb 9, 2026

Closes #575

Before, when run --experimental with --use-git-ignore (default), we always reported that some files were skipped. This was counterintuitive, because it didn't mean that any files were actually skipped.

Now, if the flag is set and the scanned root (more precisely, at least one of the scanned roots) is a git repo, we print the message Scan was limited to files tracked by git separate from the Some files were skipped or only partially analyzed message. This way, when the user sees the latter, it means that there were actually files skipped for a reason (different than not being tracked by git).

Example when both messages appear:

┌──────────────┐
│ Scan Summary │
└──────────────┘
Scan was limited to files tracked by git.
Some files were skipped or only partially analyzed.
  Scan skipped: 76 files matching .semgrepignore patterns.
  For a full list of skipped files, run opengrep with the --verbose flag.

Ran 2 rules on 460 files: 8038 findings.

Example of a scan of a git repo when no files tracked by git are actually skipped:

┌──────────────┐
│ Scan Summary │
└──────────────┘
Scan was limited to files tracked by git.

Ran 1 rules on 2 files: 2 findings.

Example of a scan of a root that is not a git repo, but there are files skipped:

┌──────────────┐
│ Scan Summary │
└──────────────┘
Some files were skipped or only partially analyzed.
  Scan skipped: 1 files larger than 1 MB, 1 files matching .semgrepignore patterns.
  For a full list of skipped files, run opengrep with the --verbose flag.

Ran 2 rules on 5 files: 315 findings.

@maciejpirog maciejpirog changed the title In --experimental, don't report git untracked files as skipped with --use-git-ignore In --experimental, don't report git untracked files as skipped with --use-git-ignore Feb 9, 2026
let selected, skipped = Find_targets.get_target_fpaths conf target_roots in
selected |> List.sort Fpath.compare
let targets = Find_targets.get_target_fpaths conf target_roots in
targets.targets |> List.sort Fpath.compare
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe targets.selected would be more clear?

Copy link
Collaborator

Choose a reason for hiding this comment

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

and would match targets.skipped

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you are right. I will change it to selected

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@maciejpirog maciejpirog force-pushed the mpir/experimental-git-untracked-file-is-not-error branch from 5f90e1d to 06b8b42 Compare February 10, 2026 10:28
@maciejpirog maciejpirog force-pushed the mpir/experimental-git-untracked-file-is-not-error branch from 06b8b42 to 44332d3 Compare February 10, 2026 15:02
Comment on lines +913 to +917
(* TODO: The 'git_repo' fields is needed to print out a warning to the *)
(* user, because some files in a git repo can be ignored. When multiple *)
(* roots are specified, we display this warning to the user when *)
(* at least one root is a git repo. Should we be more precise and *)
(* display which roots are git repos? *)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Comments are like this everywhere:

(*
 *
 *
*)

But here each line is a comment.

Copy link
Collaborator

Choose a reason for hiding this comment

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

git_repo field (not fields)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comments are like this everywhere

Yeah, a setting somehow changed in my editor, and I keep forgetting to fix it....

Comment on lines +922 to +924
(fun (t, s, gr) root ->
let t', s', gr' = get_targets_for_project conf root in
Fppath_set.union t t', s' @ s, gr || gr')
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would rename these variables (t, s, gr) to something that's immediately clear.

skipped_targets
in
(selected_targets, skipped_targets)
(selected_targets, skipped_targets, is_git_repo)
Copy link
Collaborator

Choose a reason for hiding this comment

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

But we have a record type now, can we not reuse?

Comment on lines 39 to +54
@@ -52,9 +51,7 @@ let pp_summary ~respect_gitignore ~(maturity : Maturity.t) ~max_target_bytes
targets_not_in_git += 1
continue
if targets_not_in_git != dir_targets: *)
Some "Scan was limited to files tracked by git."
else None
in
Fmt.pf ppf "Scan was limited to files tracked by git.@\n";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Indentation of nested comment block.

Copy link
Collaborator

@dimitris-m dimitris-m left a comment

Choose a reason for hiding this comment

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

Left some comments that are easy to address.

Question:
Are there already tests for the case where is_git_repo = false and there are skipped files (non-git repo with actual skips)?

Copy link
Collaborator

@dimitris-m dimitris-m left a comment

Choose a reason for hiding this comment

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

lgtm

@maciejpirog maciejpirog merged commit a1a9fed into main Feb 12, 2026
6 checks passed
@maciejpirog maciejpirog deleted the mpir/experimental-git-untracked-file-is-not-error branch February 12, 2026 15:21
@maciejpirog maciejpirog mentioned this pull request Feb 17, 2026
@dimitris-m dimitris-m mentioned this pull request Feb 17, 2026
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Feb 19, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [opengrep/opengrep](https://github.com/opengrep/opengrep) | patch | `v1.16.0` → `v1.16.1` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>opengrep/opengrep (opengrep/opengrep)</summary>

### [`v1.16.1`](https://github.com/opengrep/opengrep/releases/tag/v1.16.1): Opengrep 1.16.1

[Compare Source](opengrep/opengrep@v1.16.0...v1.16.1)

#### Improvements

- Pin Nuitka to 2.8.9 across all build workflows by [@&#8203;dimitris-m](https://github.com/dimitris-m) in [#&#8203;594](opengrep/opengrep#594)
- Remove redundant pip and Nuitka dependencies by [@&#8203;dimitris-m](https://github.com/dimitris-m) in [#&#8203;573](opengrep/opengrep#573)
- Support split rule/target directories in test subcommand by [@&#8203;qkaiser](https://github.com/qkaiser) in [#&#8203;576](opengrep/opengrep#576)

#### Benchmarking

- New benchmarking using hyperfine by [@&#8203;dimitris-m](https://github.com/dimitris-m) in [#&#8203;557](opengrep/opengrep#557) and [#&#8203;579](opengrep/opengrep#579)

#### Bug fixes

- Allow multiple logical operators in metavariable comparison by [@&#8203;maciejpirog](https://github.com/maciejpirog) in [#&#8203;590](opengrep/opengrep#590)
- In `--experimental`, don't report git untracked files as skipped with `--use-git-ignore` by [@&#8203;maciejpirog](https://github.com/maciejpirog) in [#&#8203;577](opengrep/opengrep#577)
- C#: Add primary constructor arguments to base class by [@&#8203;maciejpirog](https://github.com/maciejpirog) in [#&#8203;589](opengrep/opengrep#589)
- Dockerfile: Add missing buildkit constructs by [@&#8203;maciejpirog](https://github.com/maciejpirog) in [#&#8203;581](opengrep/opengrep#581)
- Dockerfile: Fix CRLF and comment-in-continuation parsing by [@&#8203;abezdina](https://github.com/abezdina) in [#&#8203;586](opengrep/opengrep#586)
- Rust: Fix taint propagation through variable shadowing by [@&#8203;dimitris-m](https://github.com/dimitris-m) in [#&#8203;572](opengrep/opengrep#572)
- TS/TSX: Add support for the `satisfies` construct by [@&#8203;maciejpirog](https://github.com/maciejpirog) in [#&#8203;592](opengrep/opengrep#592)

#### Installation

- Add Windows install script (pwsh) by [@&#8203;dimitris-m](https://github.com/dimitris-m) in [#&#8203;569](opengrep/opengrep#569)
- Ensure that install.ps1 works on ARM by [@&#8203;dimitris-m](https://github.com/dimitris-m) in [#&#8203;571](opengrep/opengrep#571)
- Fix: handle unparseable cosign version in install.sh by [@&#8203;dimitris-m](https://github.com/dimitris-m) in [#&#8203;580](opengrep/opengrep#580)

#### Documentation

- Improve the README by [@&#8203;dimitris-m](https://github.com/dimitris-m) in [#&#8203;570](opengrep/opengrep#570)

#### New Contributors

- [@&#8203;qkaiser](https://github.com/qkaiser) made their first contribution in [#&#8203;576](opengrep/opengrep#576)
- [@&#8203;abezdina](https://github.com/abezdina) made their first contribution in [#&#8203;586](opengrep/opengrep#586)

**Full Changelog**: <opengrep/opengrep@v1.16.0...v1.16.1>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNC4yIiwidXBkYXRlZEluVmVyIjoiNDMuMjQuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6OnBhdGNoIl19-->
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.

Every git scan with --experimental reports skipped files

2 participants