Browse code

Add better ".git" detection and use

This way, packagers can set GIT_DIR appropriately if they'd prefer to not have ".git" inside their working directory.

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)

Tianon Gravi authored on 2014/02/11 05:44:34
Showing 1 changed files
... ...
@@ -53,9 +53,9 @@ DEFAULT_BUNDLES=(
53 53
 )
54 54
 
55 55
 VERSION=$(cat ./VERSION)
56
-if [ -d .git ] && command -v git &> /dev/null; then
56
+if command -v git &> /dev/null && git rev-parse &> /dev/null; then
57 57
 	GITCOMMIT=$(git rev-parse --short HEAD)
58
-	if [ -n "$(git status --porcelain)" ]; then
58
+	if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
59 59
 		GITCOMMIT="$GITCOMMIT-dirty"
60 60
 	fi
61 61
 elif [ "$DOCKER_GITCOMMIT" ]; then