Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for sparse-checkout mode in Git add command to resolve is… #233048

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions extensions/git/src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,19 @@ export class Repository {
args.push('-A');
}

try {
const configSparseCheckout = (await this.exec(['config', '--get', 'core.sparsecheckout'])).stdout?.trim();
const isSparseActive = configSparseCheckout && configSparseCheckout.toLowerCase() === 'true';

if (isSparseActive) {
args.push('--sparse');
}
} catch (err) {
if (err.stderr) {
throw err;
}
}

if (paths && paths.length) {
for (const chunk of splitInChunks(paths.map(sanitizePath), MAX_CLI_LENGTH)) {
await this.exec([...args, '--', ...chunk]);
Expand Down
22 changes: 22 additions & 0 deletions extensions/git/src/test/smoke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,28 @@ suite('git smoke test', function () {
assert.strictEqual(repository.state.workingTreeChanges[1].status, Status.UNTRACKED);
});

test('stages with sparse-checkout', async function () {
cp.execSync('git sparse-checkout init --no-cone', { cwd });
cp.execSync('git sparse-checkout set app.js', { cwd });

const appjs = uri('app.js');
const newfile = uri('newfile.txt');

await repository.add([newfile.path]);

assert.strictEqual(repository.state.indexChanges.length, 1);
assert.strictEqual(repository.state.indexChanges[0].uri.path, newfile.path);
assert.strictEqual(repository.state.indexChanges[0].status, Status.INDEX_ADDED);

assert.strictEqual(repository.state.workingTreeChanges.length, 1);
assert.strictEqual(repository.state.workingTreeChanges[0].uri.path, appjs.path);
assert.strictEqual(repository.state.workingTreeChanges[0].status, Status.MODIFIED);

await repository.revert([newfile.fsPath]);

cp.execSync('git sparse-checkout disable', { cwd });
});

test('stages, commits changes and verifies outgoing change', async function () {
const appjs = uri('app.js');
const newfile = uri('newfile.txt');
Expand Down
4 changes: 2 additions & 2 deletions test/automation/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions test/automation/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vscode-automation",
"version": "1.71.0",
"version": "1.96.0",
"description": "VS Code UI automation driver",
"author": {
"name": "Microsoft Corporation"
Expand Down Expand Up @@ -31,4 +31,4 @@
"npm-run-all": "^4.1.5",
"watch": "^1.0.2"
}
}
}