pre-commit Error missing config value GIT_CONFIG_VALUE_0
Asked Answered
F

2

7

When i commit changes via Github Desktop, pre-commit cannot handle the changes and commit them but overwrites all other stages changes (the once i didn't intent to commit now) by its improvements.

This appears since during a commit in Github Desktop to my local branch, Avast free antivirus interrupted the process to check some file for virus. Since i didn't want Avast to interrupt it i canceled the scan, probably making things worse.

Now i get the following message when i'm trying to commit:error message

I tried already to use

  • git reset, git update-indes,
  • delete the repo and set it up new
  • use pre-commit uninstall and install
  • use pre-commit run --all-files

On another machine, the same repo runs smoothly. Does anyone has an idea what and how i have to reset to solve this issue?

Here is the pre-commit log:

version information

pre-commit version: 3.7.1
git --version: git version 2.45.1.windows.1
sys.version:
    3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)]
sys.executable: C:\Users\UsrName\Dokumente\GitHub\RepoName\.env\Scripts\python.exe
os.name: nt
sys.platform: win32

error information

An unexpected error has occurred: CalledProcessError: command: ('C:\\Users\\UsrName\\AppData\\Local\\GitHubDesktop\\app-3.4.2\\resources\\app\\git\\mingw64\\bin\\git.EXE', '-c', 'core.autocrlf=false', 'apply', '--whitespace=nowarn', 'C:\\Users\\UsrName\\.cache\\pre-commit\\patch1719821150-18184')
return code: 128
stdout: (none)
stderr:
    error: missing config value GIT_CONFIG_VALUE_0
    fatal: unable to parse command-line config
Traceback (most recent call last):
  File "C:\Users\UsrName\Dokumente\GitHub\RepoName\.env\Lib\site-packages\pre_commit\staged_files_only.py", line 29, in _git_apply
    cmd_output_b('git', *args)
  File "C:\Users\UsrName\Dokumente\GitHub\RepoName\.env\Lib\site-packages\pre_commit\util.py", line 111, in cmd_output_b
    raise CalledProcessError(returncode, cmd, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('C:\\Users\\UsrName\\AppData\\Local\\GitHubDesktop\\app-3.4.2\\resources\\app\\git\\mingw64\\bin\\git.EXE', 'apply', '--whitespace=nowarn', 'C:\\Users\\UsrName\\.cache\\pre-commit\\patch1719821150-18184')
return code: 128
stdout: (none)
stderr:
    error: missing config value GIT_CONFIG_VALUE_0
    fatal: unable to parse command-line config

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\UsrName\Dokumente\GitHub\RepoName\.env\Lib\site-packages\pre_commit\staged_files_only.py", line 86, in _unstaged_changes_cleared
    _git_apply(patch_filename)
  File "C:\Users\UsrName\Dokumente\GitHub\RepoName\.env\Lib\site-packages\pre_commit\staged_files_only.py", line 32, in _git_apply
    cmd_output_b('git', '-c', 'core.autocrlf=false', *args)
  File "C:\Users\UsrName\Dokumente\GitHub\RepoName\.env\Lib\site-packages\pre_commit\util.py", line 111, in cmd_output_b
    raise CalledProcessError(returncode, cmd, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('C:\\Users\\UsrName\\AppData\\Local\\GitHubDesktop\\app-3.4.2\\resources\\app\\git\\mingw64\\bin\\git.EXE', '-c', 'core.autocrlf=false', 'apply', '--whitespace=nowarn', 'C:\\Users\\UsrName\\.cache\\pre-commit\\patch1719821150-18184')
return code: 128
stdout: (none)
stderr:
    error: missing config value GIT_CONFIG_VALUE_0
    fatal: unable to parse command-line config

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\UsrName\Dokumente\GitHub\RepoName\.env\Lib\site-packages\pre_commit\staged_files_only.py", line 29, in _git_apply
    cmd_output_b('git', *args)
  File "C:\Users\UsrName\Dokumente\GitHub\RepoName\.env\Lib\site-packages\pre_commit\util.py", line 111, in cmd_output_b
    raise CalledProcessError(returncode, cmd, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('C:\\Users\\UsrName\\AppData\\Local\\GitHubDesktop\\app-3.4.2\\resources\\app\\git\\mingw64\\bin\\git.EXE', 'apply', '--whitespace=nowarn', 'C:\\Users\\UsrName\\.cache\\pre-commit\\patch1719821150-18184')
return code: 128
stdout: (none)
stderr:
    error: missing config value GIT_CONFIG_VALUE_0
    fatal: unable to parse command-line config

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\UsrName\Dokumente\GitHub\RepoName\.env\Lib\site-packages\pre_commit\error_handler.py", line 73, in error_handler
    yield
  File "C:\Users\UsrName\Dokumente\GitHub\RepoName\.env\Lib\site-packages\pre_commit\main.py", line 389, in main
    return hook_impl(
           ^^^^^^^^^^
  File "C:\Users\UsrName\Dokumente\GitHub\RepoName\.env\Lib\site-packages\pre_commit\commands\hook_impl.py", line 271, in hook_impl
    return retv | run(config, store, ns)
                  ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\UsrName\Dokumente\GitHub\RepoName\.env\Lib\site-packages\pre_commit\commands\run.py", line 418, in run
    with contextlib.ExitStack() as exit_stack:
  File "C:\Users\UsrName\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 586, in __exit__
    raise exc_details[1]
  File "C:\Users\UsrName\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 571, in __exit__
    if cb(*exc_details):
       ^^^^^^^^^^^^^^^^
  File "C:\Users\UsrName\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 144, in __exit__
    next(self.gen)
  File "C:\Users\UsrName\Dokumente\GitHub\RepoName\.env\Lib\site-packages\pre_commit\staged_files_only.py", line 112, in staged_files_only
    with _intent_to_add_cleared(), _unstaged_changes_cleared(patch_dir):
  File "C:\Users\UsrName\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 144, in __exit__
    next(self.gen)
  File "C:\Users\UsrName\Dokumente\GitHub\RepoName\.env\Lib\site-packages\pre_commit\staged_files_only.py", line 96, in _unstaged_changes_cleared
    _git_apply(patch_filename)
  File "C:\Users\UsrName\Dokumente\GitHub\RepoName\.env\Lib\site-packages\pre_commit\staged_files_only.py", line 32, in _git_apply
    cmd_output_b('git', '-c', 'core.autocrlf=false', *args)
  File "C:\Users\UsrName\Dokumente\GitHub\RepoName\.env\Lib\site-packages\pre_commit\util.py", line 111, in cmd_output_b
    raise CalledProcessError(returncode, cmd, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('C:\\Users\\UsrName\\AppData\\Local\\GitHubDesktop\\app-3.4.2\\resources\\app\\git\\mingw64\\bin\\git.EXE', '-c', 'core.autocrlf=false', 'apply', '--whitespace=nowarn', 'C:\\Users\\UsrName\\.cache\\pre-commit\\patch1719821150-18184')
return code: 128
stdout: (none)
stderr:
    error: missing config value GIT_CONFIG_VALUE_0
    fatal: unable to parse command-line config
Floorwalker answered 2/7 at 7:3 Comment(4)
I cannot solve your problem but let's me try to point you to this direction: GIT_CONFIG_* env vars. Do you have ``GIT_CONFIG_COUNT` env var?Tearjerker
Having the same issue! Committing through VS Code and command line has no problem, so it seems to be specific to GitHub Desktop. Likewise, GitHub Desktop had an update recently. I wonder if that affected this. In particular, the pre-commit that is failing for me is check-added-large-files. trim-trailing-whitespace passed before failing on large files.Thionic
@ramon would you be willing to open up an issue on the GitHub Desktop repo? github.com/desktop/desktop/issues/…Thionic
I commented out check-added-large-files and now it errors on check-merge-conflicts after passing python-ast and json. EDIT: xref: github.com/pre-commit/pre-commit/issues/3245Thionic
K
1

There's a temporary fix/workaround for this.

  1. Exit GitHub Desktop.
  2. Go to your GitHub Desktop resource app folder. It should be listed in the error you receive, in your case C:\\Users\\UsrName\\AppData\\Local\\GitHubDesktop\\app-3.4.2\\resources\\app. In my case I'm on version 3.4.3 now, so I would choose whatever is newest.
  3. Open the renderer.js file in a text editor
  4. Search for "GIT_CONFIG_VALUE_0":"" in the file
  5. Change it to "GIT_CONFIG_VALUE_0":null. (some people have reported setting the value to 0 or "*" and it also working)
  6. Restart GitHub Desktop
  7. I assume we'll need to re-apply this fix every time the version updates.

Fix found in this thread - https://github.com/desktop/desktop/issues/18945. Unfortunately they closed the issue. If you'd like to ask for them to investigate a long-term fix on that issue maybe we can get movement.

Keshiakesia answered 12/8 at 14:28 Comment(0)
S
1

Workaround from GitHub issue comment. Run this and reopen Github Desktop.

import os

file = r'%LOCALAPPDATA%\GitHubDesktop\app-3.4.3\resources\app\renderer.js'
file = os.path.expandvars(file)
find = 'GIT_CONFIG_VALUE_0:""'
replace = 'GIT_CONFIG_VALUE_0:"null"'
with open(file, 'r') as f:
    content = f.read()
    content = content.replace(find, replace)
with open(file, 'w') as f:
    f.write(content)    
Sightseeing answered 12/8 at 14:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.