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

Every time getting Couldn't restore hidden unstaged files: exit status 1 error #627

Closed
saneef opened this issue Feb 9, 2024 · 4 comments · Fixed by #676
Closed

Every time getting Couldn't restore hidden unstaged files: exit status 1 error #627

saneef opened this issue Feb 9, 2024 · 4 comments · Fixed by #676
Labels
bug Something isn't working

Comments

@saneef
Copy link

saneef commented Feb 9, 2024

🔧 Summary

I'm faced with error: Couldn't restore hidden unstaged files: exit status 1 on every commit.

Lefthook version

1.6.1 e69adc10c99fd8887673a8b18894082453c6ceaf

Steps to reproduce

  1. Stage files on Git.
  2. Do git commit

Expected results

Shouldn't see any errors.

Actual results

Error Couldn't restore hidden unstaged files: exit status 1, but Git commit continues.

Possible Solution

Nothing.

Logs / Screenshots

❯ LEFTHOOK_VERBOSE=true git commit -m "test"
│ [lefthook] cmd: [git rev-parse --show-toplevel]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: /Users/saneef/workspace/saneef/saneef.com

│ [lefthook] cmd: [git rev-parse --git-path hooks]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: .git/hooks

│ [lefthook] cmd: [git rev-parse --git-path info]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: .git/info

│ [lefthook] cmd: [git rev-parse --git-dir]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: .git

╭──────────────────────────────────────╮
│ 🥊 lefthook v1.6.1  hook: pre-commit │
╰──────────────────────────────────────╯
│ [lefthook] cmd: [git status --short]
│ [lefthook] dir: /Users/saneef/workspace/saneef/saneef.com
│ [lefthook] err: <nil>
│ [lefthook] out:  M README.md
M  package.json
M  src/experiments.njk

│ [lefthook] cmd: [git diff --name-only --cached --diff-filter=ACMR]
│ [lefthook] dir: /Users/saneef/workspace/saneef/saneef.com
│ [lefthook] err: <nil>
│ [lefthook] out: package.json
src/experiments.njk

│ [lefthook] files before filters:
[package.json src/experiments.njk]
│ [lefthook] files after filters:
[]
│  eslint (skip) no files for inspection
│ [lefthook] cmd: [git diff --name-only --cached --diff-filter=ACMR]
│ [lefthook] dir: /Users/saneef/workspace/saneef/saneef.com
│ [lefthook] err: <nil>
│ [lefthook] out: package.json
src/experiments.njk

│ [lefthook] files before filters:
[package.json src/experiments.njk]
│ [lefthook] files after filters:
[package.json src/experiments.njk]
│ [lefthook] files after escaping:
[package.json src/experiments.njk]
│ [lefthook] executing: pnpm prettier --write package.json src/experiments.njk
┃  prettier ❯

package.json 19ms (unchanged)
src/experiments.njk 27ms (unchanged)

│ [lefthook] cmd: [git diff --name-only --cached --diff-filter=ACMR]
│ [lefthook] dir: /Users/saneef/workspace/saneef/saneef.com
│ [lefthook] err: <nil>
│ [lefthook] out: package.json
src/experiments.njk

│ [lefthook] files before filters:
[package.json src/experiments.njk]
│ [lefthook] files after filters:
[]
│  stylelint (skip) no files for inspection
│ [lefthook] cmd: [git apply -v --whitespace=nowarn --recount --unidiff-zero .git/info/lefthook-unstaged.patch]
│ [lefthook] dir: /Users/saneef/workspace/saneef/saneef.com
│ [lefthook] err: exit status 1
│ [lefthook] out: Checking patch eleventy/filters.js...
error: while searching for:
            const urlObj = new URL(d["url"]);

error: patch failed: eleventy/filters.js:59
error: eleventy/filters.js: patch does not apply

Couldn't restore hidden unstaged files: exit status 1


  ────────────────────────────────────
summary: (done in 0.42 seconds)
✔️  prettier
│ [lefthook] cmd: [git rev-parse --show-toplevel]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: /Users/saneef/workspace/saneef/saneef.com

│ [lefthook] cmd: [git rev-parse --git-path hooks]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: .git/hooks

│ [lefthook] cmd: [git rev-parse --git-path info]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: .git/info

│ [lefthook] cmd: [git rev-parse --git-dir]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: .git

╭──────────────────────────────────────────────╮
│ 🥊 lefthook v1.6.1  hook: prepare-commit-msg │
╰──────────────────────────────────────────────╯
│ [lefthook] skip: Hook prepare-commit-msg doesn't exist in the config
[main 34aab66] test
 2 files changed, 1 insertion(+), 1 deletion(-)
@saneef saneef added the bug Something isn't working label Feb 9, 2024
@saneef
Copy link
Author

saneef commented Feb 9, 2024

Is this due to some previously botched git commit? If that is the case, how would I clear those files?

@saneef
Copy link
Author

saneef commented Feb 9, 2024

I deleted the file .git/info/lefthook-unstaged.patch and it worked fine.

@saneef saneef closed this as completed Feb 9, 2024
@mrexox
Copy link
Member

mrexox commented Feb 12, 2024

Thank you for creating this bug. This is indeed a real problem with lefthook, I will try to fix it with the next release.

@saneef saneef reopened this Feb 12, 2024
@technicalpickles
Copy link
Contributor

I've been seeing this as well. The way we say it exposed was that pre-commit was failing for files that weren't actually staged.

Confirmed that deleting it fixes it. Would it be worth deleting this file everytime a pre-commit hook runs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants