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.

When a watcher process being used, git stash restoration might fail

See original GitHub issue

I’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:

  1. Checkout https://github.com/component-driven/component-driven-development
  2. Run npm run generate:watch
  3. Edit src/exercises/3-Primitives/templates/Text.js and see how src/exercises/3-Primitives/final/Text.js and being updated.
  4. Add those changes to the index by git add .
  5. 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:closed
  • Created 4 years ago
  • Comments:28 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
iirojcommented, Dec 14, 2019

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.

0reactions
iirojcommented, Jan 19, 2020

v10.0.0 has been released so this should be closed from the milestone.

Read more comments on GitHub >

github_iconTop 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 >

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