Skip to content

Commit 43045ae

Browse files
authored
Disable extensions.worktreeConfig when disabling sparse-checkout (#1692)
1 parent 37b0821 commit 43045ae

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

.github/workflows/test.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
- releases/*
99

1010

11-
# Note that when you see patterns like "ref: test-data/v2/basic" within this workflow,
11+
# Note that when you see patterns like "ref: test-data/v2/basic" within this workflow,
1212
# these refer to "test-data" branches on this actions/checkout repo.
1313
# (For example, test-data/v2/basic -> https://github.com/actions/checkout/tree/test-data/v2/basic)
1414

@@ -37,7 +37,7 @@ jobs:
3737
steps:
3838
# Clone this repo
3939
- name: Checkout
40-
uses: actions/checkout@v3
40+
uses: actions/checkout@v4.1.1
4141

4242
# Basic checkout
4343
- name: Checkout basic
@@ -257,7 +257,7 @@ jobs:
257257
path: basic
258258
- name: Verify basic
259259
run: __test__/verify-basic.sh --archive
260-
260+
261261
test-git-container:
262262
runs-on: ubuntu-latest
263263
container: bitnami/git:latest

__test__/verify-basic.sh

+14
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ else
1818
exit 1
1919
fi
2020

21+
# Verify that sparse-checkout is disabled.
22+
SPARSE_CHECKOUT_ENABLED=$(git -C ./basic config --local --get-all core.sparseCheckout)
23+
if [ "$SPARSE_CHECKOUT_ENABLED" != "" ]; then
24+
echo "Expected sparse-checkout to be disabled (discovered: $SPARSE_CHECKOUT_ENABLED)"
25+
exit 1
26+
fi
27+
28+
# Verify git configuration shows worktreeConfig is effectively disabled
29+
WORKTREE_CONFIG_ENABLED=$(git -C ./basic config --local --get-all extensions.worktreeConfig)
30+
if [[ "$WORKTREE_CONFIG_ENABLED" != "" ]]; then
31+
echo "Expected extensions.worktreeConfig (boolean) to be disabled in git config. This could be an artifact of sparse checkout functionality."
32+
exit 1
33+
fi
34+
2135
# Verify auth token
2236
cd basic
2337
git fetch --no-tags --depth=1 origin +refs/heads/main:refs/remotes/origin/main

dist/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,8 @@ class GitCommandManager {
582582
disableSparseCheckout() {
583583
return __awaiter(this, void 0, void 0, function* () {
584584
yield this.execGit(['sparse-checkout', 'disable']);
585+
// Disabling 'sparse-checkout` leaves behind an undesirable side-effect in config (even in a pristine environment).
586+
yield this.tryConfigUnset('extensions.worktreeConfig', false);
585587
});
586588
}
587589
sparseCheckout(sparseCheckout) {

src/git-command-manager.ts

+2
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ class GitCommandManager {
178178

179179
async disableSparseCheckout(): Promise<void> {
180180
await this.execGit(['sparse-checkout', 'disable'])
181+
// Disabling 'sparse-checkout` leaves behind an undesirable side-effect in config (even in a pristine environment).
182+
await this.tryConfigUnset('extensions.worktreeConfig', false)
181183
}
182184

183185
async sparseCheckout(sparseCheckout: string[]): Promise<void> {

0 commit comments

Comments
 (0)