From 93a0a93ea9ff6a471f8ac852ec7f19f822a8653b Mon Sep 17 00:00:00 2001
From: maxice8 <thinkabit.ukim@gmail.com>
Date: Wed, 6 Mar 2019 23:26:54 -0300
Subject: [PATCH] xbps-src; export XBPS_GIT_CMD, defaulting to chroot-git and
 fallback on git.

---
 xbps-src | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/xbps-src b/xbps-src
index 1753d5e682..5cb02a83e6 100755
--- a/xbps-src
+++ b/xbps-src
@@ -270,7 +270,7 @@ check_build_requirements() {
         if [ -n "$IN_CHROOT" ]; then
             _gitbranch="$(chroot-git symbolic-ref --short HEAD 2>/dev/null)"
         else
-            _gitbranch="$(git symbolic-ref --short HEAD 2>/dev/null)"
+            _gitbranch="$($XBPS_GIT_CMD symbolic-ref --short HEAD 2>/dev/null)"
         fi
         if [ -n "${_gitbranch}" -a "${_gitbranch}" != "master" ]; then
             export XBPS_ALT_REPOSITORY="${_gitbranch}"
@@ -477,6 +477,18 @@ readonly REQHOST_UTILS="xbps-install xbps-query xbps-rindex xbps-uhelper \
 
 check_reqhost_utils
 
+# Try using chroot-git then git from the host system
+if command -v chroot-git &>/dev/null; then
+	XBPS_GIT_CMD=$(command -v chroot-git)
+elif command -v git &>/dev/null; then
+	XBPS_GIT_CMD=$(command -v git)
+else
+    echo "neither chroot-git or git are available in your system!"
+    exit 1
+fi
+
+readonly XBPS_GIT_CMD
+
 if [ -n "$IN_CHROOT" ]; then
     readonly XBPS_CONFIG_FILE=/etc/xbps/xbps-src.conf
     readonly XBPS_DISTDIR=/void-packages