Skip to content

Commit 00d3fc0

Browse files
Wyatt HoldenCopilot
andcommitted
scalar: disable orphaned commit checks by default
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. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b6f500b7-ce3c-4a1f-bc56-594b8f971a80
1 parent 44df4e9 commit 00d3fc0

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

‎Documentation/scalar.adoc‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,13 @@ am.keepCR=true::
214214
and non-Windows platforms and keeping carriage return (`\r`) characters
215215
in certain workflows.
216216

217+
checkout.orphanedCommitWarning=false::
218+
This disables the reachability check that warns about commits left
219+
behind when `git checkout` or `git switch` leaves a detached `HEAD`.
220+
The check can be expensive in large repositories. Other checkout
221+
output is unchanged, and commits left behind can still be found
222+
in the `HEAD` reflog until its entries expire.
223+
217224
commitGraph.changedPaths=true::
218225
This setting helps the background maintenance steps that compute the
219226
serialized commit-graph to also store changed-path Bloom filters. This

‎scalar.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ static int set_recommended_config(int reconfigure)
138138
*/
139139
struct scalar_config config[] = {
140140
{ "am.keepCR", "true" },
141+
{ "checkout.orphanedCommitWarning", "false" },
141142
{ "commitGraph.changedPaths", "true" },
142143
{ "commitGraph.generationVersion", "1" },
143144
{ "core.autoCRLF", "false" },

‎t/t9210-scalar.sh‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,23 @@ test_expect_success 'scalar register --no-maintenance' '
140140
test_subcommand ! git maintenance unregister --force <no-maint.event
141141
'
142142

143+
test_expect_success 'scalar disables orphan checks without overriding user configuration' '
144+
test_when_finished "scalar unregister orphan-check" &&
145+
git init orphan-check &&
146+
scalar register --no-maintenance orphan-check &&
147+
test_cmp_config -C orphan-check false checkout.orphanedCommitWarning &&
148+
149+
git -C orphan-check config unset checkout.orphanedCommitWarning &&
150+
scalar reconfigure --maintenance=keep orphan-check &&
151+
test_cmp_config -C orphan-check false checkout.orphanedCommitWarning &&
152+
153+
git -C orphan-check config set checkout.orphanedCommitWarning true &&
154+
scalar register --no-maintenance orphan-check &&
155+
test_cmp_config -C orphan-check true checkout.orphanedCommitWarning &&
156+
scalar reconfigure --maintenance=keep orphan-check &&
157+
test_cmp_config -C orphan-check true checkout.orphanedCommitWarning
158+
'
159+
143160
test_expect_success 'set up repository to clone' '
144161
test_commit first &&
145162
test_commit second &&
@@ -161,6 +178,8 @@ test_expect_success 'scalar clone' '
161178
(
162179
cd cloned/src &&
163180
181+
test_cmp_config false checkout.orphanedCommitWarning &&
182+
164183
git config --get --global --fixed-value maintenance.repo \
165184
"$(pwd)" &&
166185

0 commit comments

Comments
 (0)