Skip to content

Only detect Perforce when a P4CONFIG marker is present - #4987

Open
SebastienTolron wants to merge 1 commit into
oracle:masterfrom
SebastienTolron:fix/perforce-marker-detection
Open

Only detect Perforce when a P4CONFIG marker is present#4987
SebastienTolron wants to merge 1 commit into
oracle:masterfrom
SebastienTolron:fix/perforce-marker-detection

Conversation

@SebastienTolron

Copy link
Copy Markdown

Problem

PerforceRepository has no local repository marker (unlike .git, .hg, .svn, …). As a result, isRepositoryFor() probes every scanned directory by executing p4 dirs/p4 files whenever the p4 binary is available.

This has two bad consequences on machines that only use other SCMs:

  1. Misclassification / lost history — when a p4 client is configured through the environment (P4PORT/P4CLIENT/P4CONFIG), p4 files/p4 dirs can return depot paths for directories that are actually Git working trees. Those trees get detected as Perforce, so their real (Git) history is never collected.
  2. Slow and noisy indexingp4 is spawned in every non-repository directory during the discovery walk.

Fix

Gate Perforce detection on local evidence before running any p4 command: a P4CONFIG marker file (named by the P4CONFIG environment variable, defaulting to .p4config) present in the directory or one of its ancestors. This mirrors the marker-based detection already used by the other SCM implementations. Real Perforce workspaces that use the standard P4CONFIG convention are still detected; unrelated (e.g. Git) trees are no longer probed or misclassified.

Tests

Added unit tests in PerforceRepositoryTest that do not require a running Perforce server:

  • marker absent → not detected
  • marker present → detected
  • marker in an ancestor directory → detected
  • isRepositoryFor() short-circuits (no p4 invocation) without a marker
Tests run: 7, Failures: 0, Errors: 0, Skipped: 1

(The single skipped test is the pre-existing @EnabledForRepository(PERFORCE) integration test.)

🤖 Generated with Claude Code

@oracle-contributor-agreement

Copy link
Copy Markdown

Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
The following contributors of this PR have not signed the OCA:

To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application.

When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated.

If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public.

@oracle-contributor-agreement oracle-contributor-agreement Bot added the OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. label Jul 1, 2026
@SebastienTolron

SebastienTolron commented Jul 1, 2026

Copy link
Copy Markdown
Author

Hi ,

This should fix #4572

Made with Claude Opus 4.8 ( High ).

Perforce has no local marker directory, so isRepositoryFor() previously
probed every scanned directory by executing `p4 dirs`/`p4 files`. When a
p4 client is configured through the environment, those commands can return
depot paths for non-Perforce (e.g. Git) working trees, causing them to be
misclassified as Perforce and losing their real history. It also makes the
indexer run p4 in every non-repository directory, which is slow and noisy.

Gate detection on local evidence: a P4CONFIG marker file (named by the
P4CONFIG env var, defaulting to .p4config) in the directory or an ancestor,
mirroring the marker-based detection used by the other SCMs. Add unit tests
that do not require a p4 server.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: sebastien.tolron <sebastien.tolron@gmail.com>
@SebastienTolron
SebastienTolron force-pushed the fix/perforce-marker-detection branch from 73da379 to 627de42 Compare July 1, 2026 12:51
@SebastienTolron

Copy link
Copy Markdown
Author

I have signed the OCA

@oracle-contributor-agreement

Copy link
Copy Markdown

Thank you for signing the OCA.

@oracle-contributor-agreement oracle-contributor-agreement Bot added OCA Verified All contributors have signed the Oracle Contributor Agreement. and removed OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. labels Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant