When a watcher process being used, git stash restoration might fail
See original GitHub issueI’ve been testing beta-6
and noticed that if there is a watcher process that modifies files is being used, lint-staged will fail ungracefully:
M src/components/primitives/Text/Text.js
MM src/exercises/3-Primitives/Text.js
M src/exercises/3-Primitives/final/Text.js
MM src/exercises/3-Primitives/templates/Text.js
component-driven-development on rerere2 [⇡$!+] is 📦 v0.1.0 via ⬢ v10.15.3
➜ gc
husky > pre-commit (node v10.15.3)
✔ Preparing...
✔ Running tasks...
✖ Applying modifications...
→ Unstaged changes could not be restored due to a merge conflict!
Cleaning up...
Unstaged changes could not be restored due to a merge conflict!
husky > pre-commit hook failed (add --no-verify to bypass)
component-driven-development on rerere2 [⇡=$+] is 📦 v0.1.0 via ⬢ v10.15.3 took 2s
➜ g st
## rerere2...origin/rerere2 [ahead 2]
M src/components/primitives/Text/Text.js
M src/exercises/3-Primitives/Text.js
UU src/exercises/3-Primitives/final/Text.js
M src/exercises/3-Primitives/templates/Text.js
Notice how after the fail my index looks very differently having staged files that weren’t staged before the commit attempt. Ultimately, the new index is exactly the changes I didn’t want to commit in the first attempt.
Also the error message isn’t helpful in resolving the situation.
Steps to repro:
- Checkout https://github.com/component-driven/component-driven-development
- Run
npm run generate:watch
- Edit
src/exercises/3-Primitives/templates/Text.js
and see howsrc/exercises/3-Primitives/final/Text.js
and being updated. - Add those changes to the index by
git add .
- Try to commit
I realize this is might look like a rare scenario at first, but I believe most of issues with lint-staged staging algorithm came from webpack (or other tools) users running it in watch mode in parallel.
Issue Analytics
- State:
- Created 4 years ago
- Comments:28 (13 by maintainers)
Top Results From Across the Web
Why does git stash pop say that it could not restore untracked ...
It seems if you stash untracked files and then you create those files (in your example, foo.txt and bar.txt ), then you have...
Read more >Loading a pull request's overview or diff can fail with a merge ...
When that happens, the pull request becomes unviewable in the UI due to an error running git merge-base. Steps to Reproduce. The exact...
Read more >Recover a lost Git stash in two steps - DEV Community
Here's the two-steps recovery procedure. 1. List lost stashes. Let's run this command for a project where all stashes were trashed: git fsck...
Read more >Stash local changes - Product Documentation | ServiceNow
Application developers can remove and save changes locally to apply them ... When the stash is applied, each update is restored in the ......
Read more >Git Extensions Documentation - Read the Docs
When you use the stash a lot, it can be useful to show the number ... When a process has failed, the dialog...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A new untracked, unstaged file would still be in the original backup stash (
--include-untracked
setting) and thus get restored when applying the stash back after running tasks.v10.0.0
has been released so this should be closed from the milestone.