Only detect Perforce when a P4CONFIG marker is present - #4987
Open
SebastienTolron wants to merge 1 commit into
Open
Only detect Perforce when a P4CONFIG marker is present#4987SebastienTolron wants to merge 1 commit into
SebastienTolron wants to merge 1 commit into
Conversation
|
Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (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. |
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
force-pushed
the
fix/perforce-marker-detection
branch
from
July 1, 2026 12:51
73da379 to
627de42
Compare
Author
|
I have signed the OCA |
|
Thank you for signing the OCA. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PerforceRepositoryhas no local repository marker (unlike.git,.hg,.svn, …). As a result,isRepositoryFor()probes every scanned directory by executingp4 dirs/p4 fileswhenever thep4binary is available.This has two bad consequences on machines that only use other SCMs:
p4client is configured through the environment (P4PORT/P4CLIENT/P4CONFIG),p4 files/p4 dirscan 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.p4is spawned in every non-repository directory during the discovery walk.Fix
Gate Perforce detection on local evidence before running any
p4command: a P4CONFIG marker file (named by theP4CONFIGenvironment 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
PerforceRepositoryTestthat do not require a running Perforce server:isRepositoryFor()short-circuits (nop4invocation) without a marker(The single skipped test is the pre-existing
@EnabledForRepository(PERFORCE)integration test.)🤖 Generated with Claude Code