@@ -262,7 +262,7 @@ export class Git {
262262 ) {
263263 strings = { stagedUncommitted: 'Index', uncommitted: 'Working Tree', working: '', ...strings };
264264
265- if (ref === '' ) return strings.working;
265+ if (ref == null || ref.length === 0 ) return strings.working;
266266 if (Git.isUncommitted(ref)) {
267267 if (Git.isStagedUncommitted(ref)) return strings.stagedUncommitted;
268268
@@ -463,7 +463,7 @@ export class Git {
463463 '--get',
464464 key
465465 );
466- return data === '' ? undefined : data.trim();
466+ return data.length === 0 ? undefined : data.trim();
467467 }
468468
469469 static async config_getRegex(pattern: string, repoPath?: string, options: { local?: boolean } = {}) {
@@ -473,7 +473,7 @@ export class Git {
473473 '--get-regex',
474474 pattern
475475 );
476- return data === '' ? undefined : data.trim();
476+ return data.length === 0 ? undefined : data.trim();
477477 }
478478
479479 static diff(repoPath: string, fileName: string, ref1?: string, ref2?: string, options: { encoding?: string } = {}) {
@@ -626,7 +626,7 @@ export class Git {
626626 '--',
627627 fileName
628628 );
629- return data === '' ? undefined : data.trim();
629+ return data.length === 0 ? undefined : data.trim();
630630 }
631631
632632 static async log_resolve(repoPath: string, fileName: string, ref: string) {
@@ -640,7 +640,7 @@ export class Git {
640640 '--',
641641 fileName
642642 );
643- return data === '' ? undefined : data.trim();
643+ return data.length === 0 ? undefined : data.trim();
644644 }
645645
646646 static log_search(repoPath: string, search: string[] = emptyArray, options: { maxCount?: number } = {}) {
@@ -671,7 +671,7 @@ export class Git {
671671 }
672672
673673 const data = await git<string>({ cwd: repoPath, errors: GitErrorHandling.Ignore }, ...params, '--', fileName);
674- return data === '' ? undefined : data.trim();
674+ return data.length === 0 ? undefined : data.trim();
675675 }
676676
677677 static async ls_tree(repoPath: string, ref: string, options: { fileName?: string } = {}) {
@@ -683,7 +683,7 @@ export class Git {
683683 params.push('-lrt', ref, '--');
684684 }
685685 const data = await git<string>({ cwd: repoPath, errors: GitErrorHandling.Ignore }, ...params);
686- return data === '' ? undefined : data.trim();
686+ return data.length === 0 ? undefined : data.trim();
687687 }
688688
689689 static merge_base(repoPath: string, ref1: string, ref2: string, options: { forkPoint?: boolean } = {}) {
@@ -709,7 +709,7 @@ export class Git {
709709
710710 static async revparse(repoPath: string, ref: string): Promise<string | undefined> {
711711 const data = await git<string>({ cwd: repoPath, errors: GitErrorHandling.Ignore }, 'rev-parse', ref);
712- return data === '' ? undefined : data.trim();
712+ return data.length === 0 ? undefined : data.trim();
713713 }
714714
715715 static async revparse_currentBranch(repoPath: string): Promise<[string, string | undefined] | undefined> {
@@ -734,7 +734,7 @@ export class Git {
734734 '--format=%H',
735735 '--'
736736 );
737- if (data === '' ) return undefined;
737+ if (data.length === 0 ) return undefined;
738738
739739 // Matches output of `git branch -vv`
740740 const sha = data.trim();
@@ -752,7 +752,7 @@ export class Git {
752752 '--short',
753753 'HEAD'
754754 );
755- return data === '' ? undefined : [data.trim(), undefined];
755+ return data.length === 0 ? undefined : [data.trim(), undefined];
756756 }
757757
758758 defaultExceptionHandler(ex, opts, ...params);
@@ -762,7 +762,7 @@ export class Git {
762762
763763 static async revparse_toplevel(cwd: string): Promise<string | undefined> {
764764 const data = await git<string>({ cwd: cwd, errors: GitErrorHandling.Ignore }, 'rev-parse', '--show-toplevel');
765- return data === '' ? undefined : data.trim();
765+ return data.length === 0 ? undefined : data.trim();
766766 }
767767
768768 static async show<TOut extends string | Buffer>(
0 commit comments