question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve context on pre-commit hook failures and provide escape hatch

See original GitHub issue

Describe the bug

I cannot commit to the excalidraw/excalidraw repo in GitHub Desktop. Using GitUp (another GUI) or the git CLI both work fine.L

Version & OS

GitHub Desktop Version 2.4.0, macOS Version 10.15.3 (19D76)

Steps to reproduce the behavior

  1. Clone https://github.com/excalidraw/excalidraw
  2. Run npm install to install the dependencies
  3. Open the repo in your favorite editor and delete lines 8–18 of src/index.tsx so you have something to commit.
  4. In GitHub Desktop, commit the change.

Expected behavior

The commit occurs successfully.

Actual behavior

An error dialog displaying this text:

Commit failed - exit code 1 received, with output: 'husky > pre-commit (node v13.11.0)
Preparing... [started]
Preparing... [failed]
→ error: unknown option 'ignore-skip-worktree-entries'
usage: git update-index [<options>] [--] [<file>...]

[removed: listing of all options]

Cannot save the current worktree state
Running tasks... [started]
Running tasks... [skipped]
→ Skipped because of previous git error.
Applying modifications... [started]
Applying modifications... [skipped]
→ Skipped because of previous git error.
Cleaning up... [started]
Cleaning up... [skipped]
→ Skipped because of previous git error.

  ✖ lint-staged failed due to a git error.
  Any lost modifications can be restored from a git stash:

    > git stash list
    stash@{0}: On master: automatic lint-staged backup
    > git stash pop stash@{0}

error: unknown option 'ignore-skip-worktree-entries'

[removed: listing of all options]

Cannot save the current worktree state
husky > pre-commit hook failed (add --no-verify to bypass)

Additional context

I’m guessing this is because --ignore-skip-worktree-entries was recently added to Git and Husky is using Desktop’s bundled version for some reason?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:17
  • Comments:17 (4 by maintainers)

github_iconTop GitHub Comments

14reactions
billygriffincommented, Mar 15, 2021

This came up again in #11802. If a contributor wants to take a crack at adding a “Commit anyway” button to the error dialog, I think that’d be a great next step.

3reactions
rafecacommented, Mar 27, 2020

I’ve confirmed with @j-f1 that git config stash.usebuiltin false fixes the issue, so this can be used as a workaround.

It’s still unclear why does lint-staged executes the system git binary in some systems. This could probably be caused by some specific bash configuration…

Anyways, I see 3 different things going on here:

  1. There’s an issue on git, which causes git to spawn internally a binary of a different version causing failures when using GIT_EXEC_PATH.
  2. The git version bundled in Desktop is a bit old, upgrading it to the latest one would fix that issue.
  3. Desktop doesn’t have any escape hatch when such pre-commit issues occur, so users are helpless and need to fallback to the terminal.

Maybe we can refocus this issue (or create a new issue) to try to address point 3. so:

  • Errors happening on pre-commit hooks are clear and as easy to understand as possible.
  • Desktop offers a way to “Commit anyways” when a pre-commit error happens.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error in committing rubyonrails code in Github - Stack Overflow
desktop/desktop issue 9351: "Improve context on pre-commit hook failures and provide escape hatch". So you have to option a command-line: press ...
Read more >
Improving your life with pre-commit
[pre-commit] is a multi-language package manager for pre-commit hooks. ... Now these mistakes can be automatically prevented before the commit is made.
Read more >
pre-commit
We built pre-commit to solve our hook issues. It is a multi-language package manager for pre-commit hooks. You specify a list of hooks...
Read more >
Automatically checking for syntax errors with Git's pre-commit ...
This block is an escape hatch. One day I will want to bypass the hook and make a commit without performing the checks,...
Read more >
Comparing Code Quality Meta Tools - Dave Rolsky
What's a code quality meta tool? It's a tool that lets you orchestrate many linting and formatting tools to operate on an entire...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found