Skip to content

Commit 2306ad1

Browse files
author
Eric Amodio
committed
Fixes microsoft#129669: new setting to control status limit
Also bumps the default from 5000 to 10,000
1 parent 6fed60f commit 2306ad1

File tree

4 files changed

+35
-13
lines changed

4 files changed

+35
-13
lines changed

extensions/git/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2162,6 +2162,12 @@
21622162
"default": "whenEmpty",
21632163
"description": "%config.showUnpublishedCommitsButton%",
21642164
"scope": "resource"
2165+
},
2166+
"git.statusLimit": {
2167+
"type": "number",
2168+
"scope": "resource",
2169+
"default": 5000,
2170+
"description": "%config.statusLimit%"
21652171
}
21662172
}
21672173
},

extensions/git/package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@
189189
"config.showUnpublishedCommitsButton.always": "Always shows the action button, if there are unpublished commits.",
190190
"config.showUnpublishedCommitsButton.whenEmpty": "Only shows the action button if there are no other changes and there are unpublished commits.",
191191
"config.showUnpublishedCommitsButton.never": "Never shows the action button.",
192+
"config.statusLimit": "Controls how to limit the number of changes that can be parsed from Git status command. Can be set to 0 for no limit.",
192193
"submenu.explorer": "Git",
193194
"submenu.commit": "Commit",
194195
"submenu.commit.amend": "Amend",

extensions/git/src/git.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1842,7 +1842,7 @@ export class Repository {
18421842
const onStdoutData = (raw: string) => {
18431843
parser.update(raw);
18441844

1845-
if (parser.status.length > limit) {
1845+
if (limit !== 0 && parser.status.length > limit) {
18461846
child.removeListener('exit', onExit);
18471847
child.stdout!.removeListener('data', onStdoutData);
18481848
child.kill();

extensions/git/src/repository.ts

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ export class Repository implements Disposable {
842842
return this.repository.dotGit;
843843
}
844844

845-
private isRepositoryHuge = false;
845+
private isRepositoryHuge: false | { limit: number } = false;
846846
private didWarnAboutLimit = false;
847847

848848
private resourceCommandResolver = new ResourceCommandResolver(this);
@@ -973,6 +973,14 @@ export class Repository implements Disposable {
973973
}
974974

975975
validateInput(text: string, position: number): SourceControlInputBoxValidation | undefined {
976+
let tooManyChangesWarning: SourceControlInputBoxValidation | undefined;
977+
if (this.isRepositoryHuge) {
978+
tooManyChangesWarning = {
979+
message: localize('tooManyChangesWarning', "Too many changes were detected. Only the first {0} changes will be shown below.", this.isRepositoryHuge.limit),
980+
type: SourceControlInputBoxValidationType.Warning
981+
};
982+
}
983+
976984
if (this.rebaseCommit) {
977985
if (this.rebaseCommit.message !== text) {
978986
return {
@@ -986,7 +994,7 @@ export class Repository implements Disposable {
986994
const setting = config.get<'always' | 'warn' | 'off'>('inputValidation');
987995

988996
if (setting === 'off') {
989-
return;
997+
return tooManyChangesWarning;
990998
}
991999

9921000
if (/^\s+$/.test(text)) {
@@ -1022,7 +1030,7 @@ export class Repository implements Disposable {
10221030

10231031
if (line.length <= threshold) {
10241032
if (setting !== 'always') {
1025-
return;
1033+
return tooManyChangesWarning;
10261034
}
10271035

10281036
return {
@@ -1792,12 +1800,16 @@ export class Repository implements Disposable {
17921800
const scopedConfig = workspace.getConfiguration('git', Uri.file(this.repository.root));
17931801
const ignoreSubmodules = scopedConfig.get<boolean>('ignoreSubmodules');
17941802

1795-
const { status, didHitLimit } = await this.repository.getStatus({ ignoreSubmodules });
1803+
const limit = scopedConfig.get<number>('statusLimit', 5000);
1804+
1805+
const { status, didHitLimit } = await this.repository.getStatus({ limit, ignoreSubmodules });
17961806

17971807
const config = workspace.getConfiguration('git');
17981808
const shouldIgnore = config.get<boolean>('ignoreLimitWarning') === true;
17991809
const useIcons = !config.get<boolean>('decorations.enabled', true);
1800-
this.isRepositoryHuge = didHitLimit;
1810+
this.isRepositoryHuge = didHitLimit ? { limit } : false;
1811+
// Triggers or clears any validation warning
1812+
this._sourceControl.inputBox.validateInput = this._sourceControl.inputBox.validateInput;
18011813

18021814
if (didHitLimit && !shouldIgnore && !this.didWarnAboutLimit) {
18031815
const knownHugeFolderPaths = await this.findKnownHugeFolderPathsToIgnore();
@@ -1810,18 +1822,21 @@ export class Repository implements Disposable {
18101822

18111823
const addKnown = localize('add known', "Would you like to add '{0}' to .gitignore?", folderName);
18121824
const yes = { title: localize('yes', "Yes") };
1825+
const no = { title: localize('no', "No") };
18131826

1814-
const result = await window.showWarningMessage(`${gitWarn} ${addKnown}`, yes, neverAgain);
1827+
const result = await window.showWarningMessage(`${gitWarn} ${addKnown}`, yes, no, neverAgain);
1828+
if (result === yes) {
1829+
this.ignore([Uri.file(folderPath)]);
1830+
} else {
1831+
if (result === neverAgain) {
1832+
config.update('ignoreLimitWarning', true, false);
1833+
}
18151834

1816-
if (result === neverAgain) {
1817-
config.update('ignoreLimitWarning', true, false);
18181835
this.didWarnAboutLimit = true;
1819-
} else if (result === yes) {
1820-
this.ignore([Uri.file(folderPath)]);
18211836
}
18221837
} else {
1823-
const result = await window.showWarningMessage(gitWarn, neverAgain);
1824-
1838+
const ok = { title: localize('ok', "OK") };
1839+
const result = await window.showWarningMessage(gitWarn, ok, neverAgain);
18251840
if (result === neverAgain) {
18261841
config.update('ignoreLimitWarning', true, false);
18271842
}

0 commit comments

Comments
 (0)