From 63b667bbef98305fbe621db42d764bf62e166236 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonne=20Ha=C3=9F?= <me@mrzyx.de>
Date: Mon, 20 May 2013 18:14:33 +0200
Subject: [PATCH] gracefully handle unavailable git in script/server

---
 Changelog.md  |  1 +
 script/server | 14 +++++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/Changelog.md b/Changelog.md
index cf62724ccb..07d1ae039d 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -7,6 +7,7 @@
 ## Bug fixes
 
 * Don't use Pathname early to circumvent some rare initialization errors [#3816](https://github.com/diaspora/diaspora/issues/3816)
+* Don't error out in script/server if git is unavailable.
 
 ## Features
 
diff --git a/script/server b/script/server
index b8eab4115c..5a773eded5 100755
--- a/script/server
+++ b/script/server
@@ -103,13 +103,21 @@ fi
 # Force AGPL
 if [ -w "public" -a ! -e  "public/source.tar.gz" ]
 then
-  branch=$(git branch | awk '/^[*]/ {print $2}')
-  tar czf public/source.tar.gz  $(git ls-tree -r $branch | awk '{print $4}')
+  if command -v git > /dev/null 2>&1 && git rev-parse --is-inside-work-tree > /dev/null 2>&1
+  then
+    branch=$(git branch | awk '/^[*]/ {print $2}')
+    tar czf public/source.tar.gz  $(git ls-tree -r $branch | awk '{print $4}')
+  else
+    fatal <<MSG
+Can't generate public/source.tar.gz for you. Please tar up a copy of
+your Diaspora installtion and place it there.
+MSG
+  fi
 fi
 
 if [ ! -e "public/source.tar.gz" ]
 then
-  fatal "Can't find, or even create, public/source.tar.gz."
+  fatal "Can't find public/source.tar.gz"
 fi
 
 # Check if assets are precompiled
-- 
GitLab