Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FAILED in gitlens.outputLevel=verbose; likely due to regex not in quotes #526

Closed
diablodale opened this issue Oct 14, 2018 · 2 comments
Closed
Assignees
Labels
bug Something isn't working needs-verification Request for community verification
Milestone

Comments

@diablodale
Copy link

FAILED errors are appearing in the GitLens logs. Perhaps these are harmless, though I've isolated the issues and perhaps it can be fixed.

At some part of the GitLens startup on a repo, it is doing several activities which include getting the user.name and user.email. However, the regex that is given is not within quotes or shell escaped. Therefore, it fails due to special characters like the following three )(|. Naturally, there are even more special characters recognized by the cmd, power, sh, and bash shells.

The command attempted is:

git -c core.quotepath=false -c color.ui=false config --get-regex user.(name|email)

This will fail in many cases:

  • CMD will see the | pipe and try to route output to an executable named email). The specific error that CMD will give is:
    'email)' is not recognized as an internal or external command,
    operable program or batch file.
    
  • BASH will see the ( and fail with the error:
    -bash: syntax error near unexpected token `('
    
  • SH will have error:
    sh: 1: Syntax error: "(" unexpected
    

Setup

Extension version: 8.5.6
VS Code version: Code 1.28.1 (3368db6750222d319c851f6d90eb619d886e08f5, 2018-10-11T18:13:53.910Z)
OS version: Windows_NT x64 10.0.17763

System Info
Item Value
CPUs Intel(R) Core(TM) i7-3720QM CPU @ 2.60GHz (8 x 2594)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 15.89GB (8.34GB free)
Process Argv
Screen Reader no
VM 0%

Steps to Reproduce

  1. Run vscode
  2. View errors in gitlens logs

Expected

No errors in GitLens logs

Actual Result

GitLens

Running(n:/opsworkspace/zfs-auto-snapshot): git blame --root --incremental -- Makefile
Completed(n:/opsworkspace/zfs-auto-snapshot): git blame --root --incremental -- Makefile Completed in 1297 ms
Running(n:/opsworkspace/zfs-auto-snapshot): git config --get-regex user.(name|email)
FAILED(n:/opsworkspace/zfs-auto-snapshot): git config --get-regex user.(name|email) FAILED in 259 ms
getBlameForRangeSync('n:/opsworkspace/zfs-auto-snapshot', 'n:\opsworkspace\zfs-auto-snapshot\Makefile', 'undefined', [0, 28])

GitLens (git)

[2018-10-14 01:19:37:561] git rev-parse --show-toplevel Completed in 460 ms (n:\opsworkspace\zfs-auto-snapshot)
[2018-10-14 01:19:38:121] git remote -v Completed in 527 ms (n:/opsworkspace/zfs-auto-snapshot)
[2018-10-14 01:19:38:542] git ls-files Makefile Completed in 409 ms (n:/opsworkspace/zfs-auto-snapshot)
[2018-10-14 01:19:38:543] git ls-files Makefile Completed in 403 ms (n:/opsworkspace/zfs-auto-snapshot)
[2018-10-14 01:19:38:924] git ls-files n:\opsworkspace\zfs-auto-snapshot\Makefile Completed in 379 ms (n:/opsworkspace/zfs-auto-snapshot)
[2018-10-14 01:19:40:225] git blame --root --incremental -- Makefile Completed in 1297 ms (n:/opsworkspace/zfs-auto-snapshot)
[2018-10-14 01:19:40:485] git config --get-regex user.(name|email) FAILED in 259 ms (n:/opsworkspace/zfs-auto-snapshot)

Error: Command failed: C:\njs\wslgit\wslgit.exe -c core.quotepath=false -c color.ui=false config --get-regex user.(name|email)
/bin/bash: -c: line 0: syntax error near unexpected token `('
/bin/bash: -c: line 0: `cd /mnt/n/opsworkspace/zfs-auto-snapshot && git -c core.quotepath=false -c color.ui=false config --get-regex user.(name|email)'

Workaround

None known.
If the commands are sent to a command interpreter (cmd, bash, sh, etc.) then special characters must be escaped or quoted. It is possible to bypass a command interpreter, however, that may be a substantial change to codebase.

Since the escaping method and special characters are different in each command interpreter, the code will likely need to take the most common approach -or- create a conditional escaping mechanism.

Below are three quick ways of escaping/quoting. Of these three, only the third (double quotes) may work in all three shells (cmd, bash, and sh). Maybe....

git config --get-regex user.(name|email)
git config --get-regex 'user.(name|email)'
git config --get-regex "user.(name|email)"

@eamodio eamodio added the bug Something isn't working label Nov 11, 2018
@eamodio eamodio added the help wanted Want community input and/or pull request label Jan 3, 2019
@eamodio eamodio self-assigned this Dec 2, 2020
@eamodio eamodio closed this as completed in e792941 Dec 2, 2020
@eamodio eamodio added needs-verification Request for community verification and removed help wanted Want community input and/or pull request labels Dec 2, 2020
@eamodio eamodio added this to the Soon™ milestone Dec 2, 2020
@eamodio
Copy link
Member

eamodio commented Dec 2, 2020

Can you please verify this fix in tomorrow's insiders edition? Be sure to disable/uninstall the stable version of GitLens first.

You can install the insiders edition from here.

@eamodio eamodio reopened this Dec 2, 2020
@eamodio eamodio added the pending-release Resolved but not yet released to the stable edition label Dec 4, 2020
@eamodio eamodio closed this as completed Dec 6, 2020
@eamodio eamodio removed the pending-release Resolved but not yet released to the stable edition label Dec 24, 2020
@eamodio eamodio modified the milestones: Soon™, Shipped Dec 24, 2020
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working needs-verification Request for community verification
Projects
None yet
Development

No branches or pull requests

2 participants