Browse Source

Reverts (most of) eda2cd3 (range issues)

This was a bad fix -- the issue wasn't special characters at all 😖
main
Eric Amodio 5 years ago
parent
commit
d69b488923
2 changed files with 10 additions and 28 deletions
  1. +10
    -7
      src/git/git.ts
  2. +0
    -21
      src/git/models/models.ts

+ 10
- 7
src/git/git.ts View File

@ -6,12 +6,11 @@ import * as iconv from 'iconv-lite';
import { GlyphChars } from '../constants'; import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Iterables, Objects, Strings } from '../system';
import { Objects, Strings } from '../system';
import { findGitPath, GitLocation } from './locator'; import { findGitPath, GitLocation } from './locator';
import { run, RunOptions } from './shell'; import { run, RunOptions } from './shell';
import { GitBranchParser, GitLogParser, GitReflogParser, GitStashParser, GitTagParser } from './parsers/parsers'; import { GitBranchParser, GitLogParser, GitReflogParser, GitStashParser, GitTagParser } from './parsers/parsers';
import { GitFileStatus } from './models/file'; import { GitFileStatus } from './models/file';
import { GitRevision } from './models/models';
export * from './models/models'; export * from './models/models';
export * from './parsers/parsers'; export * from './parsers/parsers';
@ -119,6 +118,10 @@ export async function git(options: GitCommandOptio
...(configs !== undefined ? configs : emptyArray) ...(configs !== undefined ? configs : emptyArray)
); );
if (process.platform === 'win32') {
args.splice(0, 0, '-c', 'core.longpaths=true');
}
promise = run<TOut>(gitInfo.path, args, encoding, runOpts); promise = run<TOut>(gitInfo.path, args, encoding, runOpts);
pendingCommands.set(command, promise); pendingCommands.set(command, promise);
@ -618,10 +621,10 @@ export namespace Git {
params.push(`--diff-filter=${filter}`); params.push(`--diff-filter=${filter}`);
} }
if (ref1) { if (ref1) {
params.push(...GitRevision.toParams(ref1));
params.push(ref1);
} }
if (ref2) { if (ref2) {
params.push(...GitRevision.toParams(ref2));
params.push(ref2);
} }
return git<string>({ cwd: repoPath, configs: ['-c', 'color.diff=false'] }, ...params, '--'); return git<string>({ cwd: repoPath, configs: ['-c', 'color.diff=false'] }, ...params, '--');
@ -630,7 +633,7 @@ export namespace Git {
export function diff__shortstat(repoPath: string, ref?: string) { export function diff__shortstat(repoPath: string, ref?: string) {
const params = ['diff', '--shortstat', '--no-ext-diff']; const params = ['diff', '--shortstat', '--no-ext-diff'];
if (ref) { if (ref) {
params.push(...GitRevision.toParams(ref));
params.push(ref);
} }
return git<string>({ cwd: repoPath, configs: ['-c', 'color.diff=false'] }, ...params, '--'); return git<string>({ cwd: repoPath, configs: ['-c', 'color.diff=false'] }, ...params, '--');
@ -730,7 +733,7 @@ export namespace Git {
if (reverse) { if (reverse) {
params.push('--reverse', '--ancestry-path', `${ref}..HEAD`); params.push('--reverse', '--ancestry-path', `${ref}..HEAD`);
} else { } else {
params.push(...GitRevision.toParams(ref));
params.push(ref);
} }
} }
@ -974,7 +977,7 @@ export namespace Git {
if (options.count) { if (options.count) {
params.push('--count'); params.push('--count');
} }
params.push(...Iterables.flatMap(refs, r => GitRevision.toParams(r)));
params.push(...refs);
const data = await git<string>({ cwd: repoPath, errors: GitErrorHandling.Ignore }, 'rev-list', ...params, '--'); const data = await git<string>({ cwd: repoPath, errors: GitErrorHandling.Ignore }, 'rev-list', ...params, '--');
return data.length === 0 ? undefined : Number(data.trim()) || undefined; return data.length === 0 ? undefined : Number(data.trim()) || undefined;

+ 0
- 21
src/git/models/models.ts View File

@ -1,8 +1,6 @@
'use strict'; 'use strict';
import { Git } from '../git'; import { Git } from '../git';
const revisionRangeRegex = /([^.]*)(\.\.\.?)([^.]*)/;
export namespace GitRevision { export namespace GitRevision {
export function createRange( export function createRange(
ref1: string | undefined, ref1: string | undefined,
@ -11,25 +9,6 @@ export namespace GitRevision {
): string { ): string {
return `${ref1 || ''}${notation}${ref2 || ''}`; return `${ref1 || ''}${notation}${ref2 || ''}`;
} }
export function toParams(ref: string | undefined) {
if (ref == null || ref.length === 0) return [];
const match = revisionRangeRegex.exec(ref);
if (match == null) return [ref];
const [, ref1, notation, ref2] = match;
const range = [];
if (ref1) {
range.push(ref1);
}
range.push(notation);
if (ref2) {
range.push(ref2);
}
return range;
}
} }
export interface GitReference { export interface GitReference {

Loading…
Cancel
Save