From 60d906fd579f15dafe4e6c1f584b43a4598fbfb2 Mon Sep 17 00:00:00 2001 From: rzj17 Date: Thu, 14 Nov 2019 15:44:16 +0000 Subject: [PATCH] Modify git add/revert to use splitInChunks --- extensions/git/src/git.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/extensions/git/src/git.ts b/extensions/git/src/git.ts index e952280f472..c38fdea0718 100644 --- a/extensions/git/src/git.ts +++ b/extensions/git/src/git.ts @@ -1226,12 +1226,13 @@ export class Repository { args.push('--'); if (paths && paths.length) { - args.push.apply(args, paths.map(sanitizePath)); + for (const chunk of splitInChunks(paths, MAX_CLI_LENGTH)) { + await this.run([...args, ...chunk]); + } } else { args.push('.'); + await this.run(args); } - - await this.run(args); } async rm(paths: string[]): Promise { @@ -1480,14 +1481,15 @@ export class Repository { args = ['reset', '-q', treeish, '--']; } - if (paths && paths.length) { - args.push.apply(args, paths.map(sanitizePath)); - } else { - args.push('.'); - } - try { - await this.run(args); + if (paths && paths.length > 0) { + for (const chunk of splitInChunks(paths, MAX_CLI_LENGTH)) { + await this.run([...args, ...chunk]); + } + } else { + args.push('.'); + await this.run(args); + } } catch (err) { // In case there are merge conflicts to be resolved, git reset will output // some "needs merge" data. We try to get around that.