1008
break;
1009
}
1011
break;
1013
>
} else {
1014
>
// Numstat line: "<added>\t<removed>\t<path>" or, for renames,
1015
>
// "<added>\t<removed>\t" followed by NUL-separated old/new paths.
1016
>
const [addedStr, removedStr, filePath] = segment.split('\t');
1017
>
let key: string;
1018
>
if (filePath === '' || filePath === undefined) {
1019
const oldPath = segments[i++];
1020
const newPath = segments[i++];
1021
key = newPath ?? oldPath ?? '';
1023
>
key = filePath;
1024
>
}
1025
>
if (!key) { continue; }
1026
>
numStats.set(key, {
1027
>
added: addedStr === '-' ? 0 : Number(addedStr) || 0,
1028
>
removed: removedStr === '-' ? 0 : Number(removedStr) || 0,
1029
>
});
1030
>
}
1031
}
1032
1033
return changes.map(change => {
1035
>
1036
>
const beforeFileUri = change.oldPath ? URI.joinPath(repositoryRoot, change.oldPath) : undefined;
1037
>
const afterFileUri = change.newPath ? URI.joinPath(repositoryRoot, change.newPath) : undefined;
1038
>
1039
>
const before = change.kind !== FileEditKind.Create && change.oldPath && beforeFileUri
1040
>
? {
1041
>
uri: beforeFileUri.toString(),
1042
>
content: { uri: buildGitBlobUri(sessionUri, beforeRef, change.oldPath, beforeFileUri.path) },
1043
>
}
1044
: undefined;
1046
>
const after = change.kind !== FileEditKind.Delete && change.newPath && afterFileUri
1047
>
? {
1048
>
uri: afterFileUri.toString(),
1049
>
content: afterRef !== undefined
1050
? { uri: buildGitBlobUri(sessionUri, afterRef, change.newPath, afterFileUri.path) }
1051
: { uri: afterFileUri.toString() }
1053
: undefined;
1055
>
const diff = {
1056
>
added: stats?.added ?? 0,
1057
>
removed: stats?.removed ?? 0
1058
>
};
1059
>
1060
>
return {
1061
>
...(before ? { before } : {}),
1062
>
...(after ? { after } : {}),
1063
>
diff
1064
>
};
1065
});
1066
}