You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Heisenbug with stack build resetting git history #2748
Thanks for the report! I bet what is happening is that there is an empty directory and it tries to do a git reset on that dir, and it finds your repo instead! Argh!
I think the solution is to use --git-dir or the GIT_DIR environment variable to fix this in all of our usages of git. Relying on the working directory of the git command is too fragile.
I've made a change which causes stack to invoke git in such a way that this shouldn't be possible. If you do another stack upgrade --git, it'll pull in the change.
This doesn't address the root problem - that somehow the directory doesn't have a repository - but should prevent it from affecting your repo.
Activity
mgsloan commentedon Nov 3, 2016
Thanks for the report! I bet what is happening is that there is an empty directory and it tries to do a git reset on that dir, and it finds your repo instead! Argh!
I think the solution is to use
--git-diror theGIT_DIRenvironment variable to fix this in all of our usages of git. Relying on the working directory of the git command is too fragile.Restrict git fetch / reset to expected dir #2748
mgsloan commentedon Nov 8, 2016
I've made a change which causes stack to invoke git in such a way that this shouldn't be possible. If you do another
stack upgrade --git, it'll pull in the change.This doesn't address the root problem - that somehow the directory doesn't have a repository - but should prevent it from affecting your repo.
parsonsmatt commentedon Nov 8, 2016
Thanks! I'll run it through my reproduction tomorrow and report back.
parsonsmatt commentedon Nov 8, 2016
I haven't been able to get it to happen again, so I'm happy saying this is solved. Thanks for the quick fix! 😄
mgsloan commentedon Nov 8, 2016
Welcome!
Use --git-dir=.git in more places #2748