Skip to content

Make orphaned commit checks configurable - #2264

Open
wyatt-holden wants to merge 2 commits into
gitgitgadget:masterfrom
wyatt-holden:wyattholden/checkout-orphaned-commit-warning
Open

wyatt-holden wants to merge 2 commits into
gitgitgadget:masterfrom
wyatt-holden:wyattholden/checkout-orphaned-commit-warning

Conversation

@wyatt-holden

Copy link
Copy Markdown

When leaving a detached HEAD, git checkout and git switch call orphaned_commit_warning() to warn about commits that are not reachable from any existing ref or the destination HEAD. This requires enumerating refs and walking commit history, which can be expensive in large repositories.

In an affected Scalar-managed repository, Trace2 showed tree unpacking finishing approximately 12 seconds into checkout, but the process continuing for roughly another 193 seconds. A stack dump captured the main thread inside  orphaned_commit_warning(), enumerating loose refs and opening ref files. Running checkout with --quiet, which bypasses this routine, reduced the observed runtime to approximately 14 seconds. However, --quiet also suppresses unrelated output.

This two-commit series adds a targeted opt-out and enables it in Scalar:

  1. Make orphaned-commit checks configurable. Add  checkout.orphanedCommitWarning , enabled by default, for both checkout and switch. Setting it to false skips the entire check while retaining the previous HEAD description and normal checkout output. When an enabled check takes more than two seconds, advice suggests the opt-out and explains the consequence. This advice is controlled by  advice.checkoutOrphanedCommitWarning . A new Trace2 region exposes the routine’s duration.
  2. Disable the check in Scalar’s recommended configuration. Recommend checkout.orphanedCommitWarning=false through Scalar’s existing configuration mechanism, preserving explicit user settings. Update documentation and add coverage for clone, register, reconfigure, and user overrides.

Ordinary Git retains its existing default behavior. Users who disable the check lose the immediate warning about commits left behind; those commits can still be recovered through the HEAD reflog while the relevant entries and objects remain available.

@gitgitgadget

gitgitgadget Bot commented Oct 16, 2026

Copy link
Copy Markdown

Welcome to GitGitGadget

Hi @wyatt-holden, and welcome to GitGitGadget, the GitHub App to send patch series to the Git mailing list from GitHub Pull Requests.

Please make sure that either:

  • Your Pull Request has a good description, if it consists of multiple commits, as it will be used as cover letter.
  • Your Pull Request description is empty, if it consists of a single commit, as the commit message should be descriptive enough by itself.

You can CC potential reviewers by adding a footer to the PR description with the following syntax:

CC: Revi Ewer <revi.ewer@example.com>, Ill Takalook <ill.takalook@example.net>

NOTE: DO NOT copy/paste your CC list from a previous GGG PR's description,
because it will result in a malformed CC list on the mailing list. See
example.

Also, it is a good idea to review the commit messages one last time, as the Git project expects them in a quite specific form:

  • the lines should not exceed 76 columns,
  • the first line should be like a header and typically start with a prefix like "tests:" or "revisions:" to state which subsystem the change is about, and
  • the commit messages' body should be describing the "why?" of the change.
  • Finally, the commit messages should end in a Signed-off-by: line matching the commits' author.

It is in general a good idea to await the automated test ("Checks") in this Pull Request before contributing the patches, e.g. to avoid trivial issues such as unportable code.

Contributing the patches

Before you can contribute the patches, your GitHub username needs to be added to the list of permitted users. Any already-permitted user can do that, by adding a comment to your PR of the form /allow. A good way to find other contributors is to locate recent pull requests where someone has been /allowed:

Both the person who commented /allow and the PR author are able to /allow you.

An alternative is the channel #git-devel on the Libera Chat IRC network:

<newcontributor> I've just created my first PR, could someone please /allow me? https://github.com/gitgitgadget/git/pull/12345
<veteran> newcontributor: it is done
<newcontributor> thanks!

Once on the list of permitted usernames, you can contribute the patches to the Git mailing list by adding a PR comment /submit.

If you want to see what email(s) would be sent for a /submit request, add a PR comment /preview to have the email(s) sent to you. You must have a public GitHub email address for this. Note that any reviewers CC'd via the list in the PR description will not actually be sent emails.

After you submit, GitGitGadget will respond with another comment that contains the link to the cover letter mail in the Git mailing list archive. Please make sure to monitor the discussion in that thread and to address comments and suggestions (while the comments and suggestions will be mirrored into the PR by GitGitGadget, you will still want to reply via mail).

If you do not want to subscribe to the Git mailing list just to be able to respond to a mail, you can download the mbox from the Git mailing list archive (click the (raw) link), then import it into your mail program. If you use GMail, you can do this via:

curl -g --user "<EMailAddress>:<Password>" \
    --url "imaps://imap.gmail.com/INBOX" -T /path/to/raw.txt

To iterate on your change, i.e. send a revised patch or patch series, you will first want to (force-)push to the same branch. You probably also want to modify your Pull Request description (or title). It is a good idea to summarize the revision by adding something like this to the cover letter (read: by editing the first comment on the PR, i.e. the PR description):

Changes since v1:
- Fixed a typo in the commit message (found by ...)
- Added a code comment to ... as suggested by ...
...

To send a new iteration, just add another PR comment with the contents: /submit.

Need help?

New contributors who want advice are encouraged to join git-mentoring@googlegroups.com, where volunteers who regularly contribute to Git are willing to answer newbie questions, give advice, or otherwise provide mentoring to interested contributors. You must join in order to post or view messages, but anyone can join.

You may also be able to find help in real time in the developer IRC channel, #git-devel on Libera Chat. Remember that IRC does not support offline messaging, so if you send someone a private message and log out, they cannot respond to you. The scrollback of #git-devel is archived, though.

@gitgitgadget

gitgitgadget Bot commented Oct 16, 2026

Copy link
Copy Markdown

There is an issue in commit 44df4e9:
checkout: make orphaned commit checks configurable

  • Commit not signed off

@gitgitgadget

gitgitgadget Bot commented Oct 16, 2026

Copy link
Copy Markdown

There is an issue in commit 00d3fc0:
scalar: disable orphaned commit checks by default

  • Commit not signed off

@wyatt-holden
wyatt-holden force-pushed the wyattholden/checkout-orphaned-commit-warning branch from 00d3fc0 to 8d9f70d Compare October 16, 2026 19:08
@gitgitgadget

gitgitgadget Bot commented Oct 16, 2026

Copy link
Copy Markdown

There is an issue in commit 1e3e99b:
checkout: make orphaned commit checks configurable

  • Commit not signed off

@gitgitgadget

gitgitgadget Bot commented Oct 16, 2026

Copy link
Copy Markdown

There is an issue in commit 8d9f70d:
scalar: disable orphaned commit checks by default

  • Commit not signed off

@wyatt-holden
wyatt-holden force-pushed the wyattholden/checkout-orphaned-commit-warning branch from 8d9f70d to b4c882f Compare October 16, 2026 19:19
Wyatt Holden added 2 commits October 16, 2026 12:43
When leaving a detached HEAD, checkout enumerates refs and walks
history to warn about commits left behind. In repositories with many
loose refs, this check can dominate checkout time.

Add checkout.orphanedCommitWarning, enabled by default, to skip the
check without suppressing other checkout output. Honor the setting
in both checkout and switch.

Suggest the opt-out when the check takes more than two seconds using
advice.checkoutOrphanedCommitWarning. Add a Trace2 region to expose
the cost, document the settings, and cover the behavior with tests

Signed-off-by: Wyatt Holden <wyattholden@microsoft.com>
Checking for commits left behind when leaving a detached HEAD can
be expensive in large repositories. Add
checkout.orphanedCommitWarning=false to Scalar's recommended settings
to avoid this foreground work while preserving normal checkout output.

Use the existing set-if-missing behavior so clone, register, and
reconfigure preserve explicit user choices. Document the tradeoff
and test the default and override handling.

Signed-off-by: Wyatt Holden <wyattholden@microsoft.com>
@wyatt-holden
wyatt-holden force-pushed the wyattholden/checkout-orphaned-commit-warning branch from b4c882f to 76d29a1 Compare October 16, 2026 19:44
@dscho

dscho commented Oct 17, 2026

Copy link
Copy Markdown
Member

/allow

@gitgitgadget

gitgitgadget Bot commented Oct 17, 2026

Copy link
Copy Markdown

User wyatt-holden is now allowed to use GitGitGadget.

WARNING: wyatt-holden has no public email address set on GitHub; GitGitGadget needs an email address to Cc: you on your contribution, so that you receive any feedback on the Git mailing list. Go to https://github.com/settings/profile to make your preferred email public to let GitGitGadget know which email address to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants