{"action":"created","issue":{"url":"https://api.github.com/repos/commercialhaskell/stack/issues/1425","labels_url":"https://api.github.com/repos/commercialhaskell/stack/issues/1425/labels{/name}","comments_url":"https://api.github.com/repos/commercialhaskell/stack/issues/1425/comments","events_url":"https://api.github.com/repos/commercialhaskell/stack/issues/1425/events","html_url":"https://github.com/commercialhaskell/stack/issues/1425","id":118779314,"number":1425,"title":"stack rebuilds `Stack.Upgrade` when you change the git index at all","user":{"login":"kadoban","id":52635,"avatar_url":"https://avatars.githubusercontent.com/u/52635?v=3","gravatar_id":"","url":"https://api.github.com/users/kadoban","html_url":"https://github.com/kadoban","followers_url":"https://api.github.com/users/kadoban/followers","following_url":"https://api.github.com/users/kadoban/following{/other_user}","gists_url":"https://api.github.com/users/kadoban/gists{/gist_id}","starred_url":"https://api.github.com/users/kadoban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kadoban/subscriptions","organizations_url":"https://api.github.com/users/kadoban/orgs","repos_url":"https://api.github.com/users/kadoban/repos","events_url":"https://api.github.com/users/kadoban/events{/privacy}","received_events_url":"https://api.github.com/users/kadoban/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-11-25T07:36:06Z","updated_at":"2015-11-25T17:29:35Z","closed_at":null,"body":"When you're developing on `stack` itself and modify the git index (aka the cache or staging area), it causes the `Stack.Upgrade` module to need to be rebuilt.\r\n\r\nIt's not exactly the end of the world, but it adds an extra delay in certain cases, like when you are running tests and it lengthens the time between iterations of what you're trying to mess with.\r\n\r\n```\r\n~/projects/stack (upstream)$ stack build\r\n~/projects/stack (upstream)$ touch bogus.txt\r\n~/projects/stack (upstream %)$ git add bogus.txt \r\n~/projects/stack (upstream +)$ stack build\r\nstack-0.1.9.0: unregistering (local file changes: .git/index)\r\nstack-0.1.9.0: build\r\nPreprocessing library stack-0.1.9.0...\r\n[73 of 76] Compiling Stack.Upgrade    ( src/Stack/Upgrade.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/Stack/Upgrade.o ) [~/projects/stack/.git/index changed]\r\nIn-place registering stack-0.1.9.0...\r\nPreprocessing executable 'stack' for stack-0.1.9.0...\r\n[2 of 2] Compiling Main             ( src/main/Main.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/stack/stack-tmp/Main.o ) [~/projects/stack/.git/index changed]\r\nLinking .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/stack/stack ...\r\nstack-0.1.9.0: copy/register\r\nInstalling library in\r\n~/projects/stack/.stack-work/install/x86_64-linux/lts-3.14/7.10.2/lib/x86_64-linux-ghc-7.10.2/stack-0.1.9.0-K5i01b4VNwNJsmjPkKylJf\r\nInstalling executable(s) in\r\n~/projects/stack/.stack-work/install/x86_64-linux/lts-3.14/7.10.2/bin\r\nRegistering stack-0.1.9.0...\r\n~/projects/stack (upstream +)$ stack build\r\n~/projects/stack (upstream +)$ \r\n```\r\n\r\nSince the `bogus.txt` file doesn't matter at all, I would have ideally expected the second `stack build` to do nothing, but it spends some time rebuilding instead.\r\n\r\nAs pointed out in a short discussion about it on IRC, this is caused by the use of `$gitHash` [here](https://github.com/commercialhaskell/stack/blob/09991d98ed034e036668721de966c199e2e40642/src/Stack/Upgrade.hs#L45)\r\n\r\nThis may actually be more of a [gitrev](https://github.com/acfoltzer/gitrev/blob/master/src/Development/GitRev.hs#L74) issue actually since we're only using `gitHash`, which doesn't appear to care about the index at all, but since it shares an underlying implementation between that and `gitDirty`, it sets the index as a dependent file (`addDependentFile` from TH).\r\n\r\nBut I'm not sure that's the correct place to fix this, or if there's something different to do on our side instead, so I'll add this issue here for discussion."},"comment":{"url":"https://api.github.com/repos/commercialhaskell/stack/issues/comments/159681707","html_url":"https://github.com/commercialhaskell/stack/issues/1425#issuecomment-159681707","issue_url":"https://api.github.com/repos/commercialhaskell/stack/issues/1425","id":159681707,"user":{"login":"kadoban","id":52635,"avatar_url":"https://avatars.githubusercontent.com/u/52635?v=3","gravatar_id":"","url":"https://api.github.com/users/kadoban","html_url":"https://github.com/kadoban","followers_url":"https://api.github.com/users/kadoban/followers","following_url":"https://api.github.com/users/kadoban/following{/other_user}","gists_url":"https://api.github.com/users/kadoban/gists{/gist_id}","starred_url":"https://api.github.com/users/kadoban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kadoban/subscriptions","organizations_url":"https://api.github.com/users/kadoban/orgs","repos_url":"https://api.github.com/users/kadoban/repos","events_url":"https://api.github.com/users/kadoban/events{/privacy}","received_events_url":"https://api.github.com/users/kadoban/received_events","type":"User","site_admin":false},"created_at":"2015-11-25T17:29:35Z","updated_at":"2015-11-25T17:29:35Z","body":"Okay, thanks much; that was going to be my next line of inquiry. A flag would be fine for the only use-case I have that I'd notice this behavior. I'll write up a quick PR."}}