Fix Git commit ID detection in Git worktrees

Authored by Sylvain Henry <hsyl20@gmail.com> on Jul 28 2018, 10:48 AM.

Description

Fix Git commit ID detection in Git worktrees

Summary: When using a Git worktree, ".git" is a file, not a directory

Reviewers: bgamari, monoidal

Reviewed By: monoidal

Subscribers: rwbarton, thomie, erikd, carter

Differential Revision: https://phabricator.haskell.org/D5016

(cherry picked from commit 3539561b24b78aee2b37280ddf6bb64e2db3a67d)