Skip to content

Commit 2cace3f

Browse files
committed
Uses fileset to manage different file loading
Loading commits w/ or w/o a pathspec which determines if filtered
1 parent c5a8fc1 commit 2cace3f

23 files changed

+352
-245
lines changed

src/commands/diffWithRevisionFrom.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class DiffWithRevisionFromCommand extends ActiveEditorCommand {
5555
{
5656
empty: `No stashes with '${gitUri.getFormattedFileName()}' found`,
5757
// Stashes should always come with files, so this should be fine (but protect it just in case)
58-
filter: c => c.files?.some(f => f.path === path || f.originalPath === path) ?? true,
58+
filter: c => c.fileset?.files.some(f => f.path === path || f.originalPath === path) ?? true,
5959
},
6060
);
6161
if (pick == null) return;

src/commands/git/show.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export class ShowGitCommand extends QuickCommand<State> {
176176
assertsStateStepCommit(state);
177177

178178
if (state.counter < 3) {
179-
if (state.reference.files == null) {
179+
if (state.reference.fileset?.files == null || state.reference.fileset?.filtered) {
180180
await state.reference.ensureFullDetails();
181181
}
182182

src/commands/openFileAtRevisionFrom.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class OpenFileAtRevisionFromCommand extends ActiveEditorCommand {
5353
`${title}${gitUri.getFormattedFileName({ truncateTo: quickPickTitleMaxChars - title.length })}`,
5454
'Choose a stash to compare with',
5555
// Stashes should always come with files, so this should be fine (but protect it just in case)
56-
{ filter: c => c.files?.some(f => f.path === path || f.originalPath === path) ?? true },
56+
{ filter: c => c.fileset?.files.some(f => f.path === path || f.originalPath === path) ?? true },
5757
);
5858
if (pick == null) return;
5959

src/commands/patches.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,9 @@ async function createDraft(repository: Repository, args: CreatePatchCommandArgs)
421421
if (commit == null) return undefined;
422422

423423
if (args.from == null) {
424-
if (commit.files == null) return;
424+
if (commit.fileset?.files == null) return;
425425

426-
change.files = [...commit.files];
426+
change.files = [...commit.fileset.files];
427427
} else {
428428
const diff = await repository.git.diff().getDiff?.(to, args.from);
429429
if (diff == null) return;

src/commands/quickCommand.steps.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2242,7 +2242,7 @@ export function* showCommitOrStashFilesStep<
22422242
context: Context,
22432243
options?: { picked?: string },
22442244
): StepResultGenerator<CommitFilesQuickPickItem | CommitFileQuickPickItem> {
2245-
if (state.reference.files == null) {
2245+
if (state.reference.fileset?.files == null) {
22462246
debugger;
22472247
}
22482248

@@ -2263,7 +2263,7 @@ export function* showCommitOrStashFilesStep<
22632263
hint: `Click to see ${isStash(state.reference) ? 'stash' : 'commit'} actions`,
22642264
}),
22652265
createQuickPickSeparator('Files'),
2266-
...(state.reference.files?.map(
2266+
...(state.reference.fileset?.files.map(
22672267
fs => new CommitFileQuickPickItem(state.reference, fs, options?.picked === fs.path),
22682268
) ?? []),
22692269
] as (CommitFilesQuickPickItem | CommitFileQuickPickItem)[],

src/commands/showQuickCommitFile.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class ShowQuickCommitFileCommand extends ActiveEditorCachedCommand {
128128

129129
const path = args.commit?.file?.path ?? gitUri.fsPath;
130130
if (isCommit(args.commit)) {
131-
if (args.commit.files == null) {
131+
if (args.commit.fileset?.files == null || args.commit.fileset?.filtered) {
132132
await args.commit.ensureFullDetails();
133133
}
134134
}

src/env/node/git/sub-providers/stash.ts

+14-10
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,20 @@ export class StashGitSubProvider implements GitStashSubProvider {
139139
message.split('\n', 1)[0] ?? '',
140140
s.parents.split(' '),
141141
message,
142-
s.files?.map(
143-
f =>
144-
new GitFileChange(
145-
this.container,
146-
repoPath,
147-
f.path,
148-
f.status as GitFileStatus,
149-
f.originalPath,
150-
),
151-
) ?? [],
142+
{
143+
files:
144+
s.files?.map(
145+
f =>
146+
new GitFileChange(
147+
this.container,
148+
repoPath,
149+
f.path,
150+
f.status as GitFileStatus,
151+
f.originalPath,
152+
),
153+
) ?? [],
154+
filtered: false,
155+
},
152156
undefined,
153157
[],
154158
undefined,

src/git/actions/commit.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -756,11 +756,11 @@ export async function openOnlyChangedFiles(container: Container, files: GitFile[
756756
export async function openOnlyChangedFiles(container: Container, commitOrFiles: GitCommit | GitFile[]): Promise<void> {
757757
let files;
758758
if (isCommit(commitOrFiles)) {
759-
if (commitOrFiles.files == null) {
759+
if (commitOrFiles.fileset?.files == null || commitOrFiles.fileset?.filtered) {
760760
await commitOrFiles.ensureFullDetails();
761761
}
762762

763-
files = commitOrFiles.files ?? [];
763+
files = commitOrFiles.fileset?.files ?? [];
764764
} else {
765765
files = commitOrFiles.map(f => new GitFileChange(container, f.repoPath!, f.path, f.status, f.originalPath));
766766
}
@@ -848,13 +848,13 @@ async function getChangesRefArgs(
848848
};
849849
}
850850

851-
if (commitOrFiles.files == null) {
851+
if (commitOrFiles.fileset?.files == null) {
852852
await commitOrFiles.ensureFullDetails();
853853
}
854854

855855
return {
856856
commit: commitOrFiles,
857-
files: commitOrFiles.files ?? [],
857+
files: commitOrFiles.fileset?.files ?? [],
858858
options: refOrOptions as TextDocumentShowOptions | undefined,
859859
ref: {
860860
repoPath: commitOrFiles.repoPath,
@@ -881,13 +881,13 @@ async function getChangesRefsArgs(
881881
};
882882
}
883883

884-
if (commitOrFiles.files == null) {
884+
if (commitOrFiles.fileset?.files == null) {
885885
await commitOrFiles.ensureFullDetails();
886886
}
887887

888888
return {
889889
commit: commitOrFiles,
890-
files: commitOrFiles.files ?? [],
890+
files: commitOrFiles.fileset?.files ?? [],
891891
options: refsOrOptions as TextDocumentShowOptions | undefined,
892892
refs: {
893893
repoPath: commitOrFiles.repoPath,
@@ -904,12 +904,12 @@ async function getCommitChangesArgs(
904904
commit: GitCommit,
905905
filter?: (file: GitFileChange) => boolean,
906906
): Promise<{ files: readonly GitFile[]; refs: RefRange }> {
907-
if (commit.files == null) {
907+
if (commit.fileset?.files == null) {
908908
await commit.ensureFullDetails();
909909
}
910910

911911
return {
912-
files: (filter != null ? commit.files?.filter(filter) : commit.files) ?? [],
912+
files: (filter != null ? commit.fileset?.files?.filter(filter) : commit.fileset?.files) ?? [],
913913
refs: {
914914
repoPath: commit.repoPath,
915915
rhs: commit.sha,

0 commit comments

Comments
 (0)