about summary refs log tree commit diff
path: root/xlocate
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-10-17 16:23:56 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-10-17 16:26:20 +0200
commit2b59a122223466eab3a847a5eae7f49a892de797 (patch)
tree03f36c3414333e3bfd90662a8338832d58012cfb /xlocate
parent751d4cb77c1c8e006236d029f247d2ed90904688 (diff)
downloadxtools-2b59a122223466eab3a847a5eae7f49a892de797.tar.gz
xtools-2b59a122223466eab3a847a5eae7f49a892de797.tar.xz
xtools-2b59a122223466eab3a847a5eae7f49a892de797.zip
xlocate: better outdated check
With packed refs, refs/heads/master isn't there, but FETCH_HEAD works
well enough too.

Fixes #49.
Diffstat (limited to 'xlocate')
-rwxr-xr-xxlocate8
1 files changed, 7 insertions, 1 deletions
diff --git a/xlocate b/xlocate
index 5f5d387..6960edd 100755
--- a/xlocate
+++ b/xlocate
@@ -52,6 +52,7 @@ xsyncgit() {
 	else
 		[ -n "${XLOCATE_GIT%/*}" ] && mkdir -p "${XLOCATE_GIT%/*}"
 		git clone --bare "$XLOCATE_REPO" "$XLOCATE_GIT"
+		git -C "$XLOCATE_GIT" fetch -u -f "$XLOCATE_REPO" master:master
 	fi
 }
 
@@ -67,7 +68,12 @@ elif [ "$1" = -S ]; then
 fi
 
 if [ -d "$XLOCATE_GIT" ]; then
-	if find /var/db/xbps/ -name '*repodata' -newer "$XLOCATE_GIT/refs/heads/master" | grep -q .; then
+	if [ -f "$XLOCATE_GIT/refs/heads/master" ]; then
+		BASE="$XLOCATE_GIT/refs/heads/master"
+	elif [ -f "$XLOCATE_GIT/FETCH_HEAD" ]; then
+		BASE="$XLOCATE_GIT/FETCH_HEAD"
+	fi
+	if [ -z "$BASE" ] || find /var/db/xbps/ -name '*repodata' -newer "$BASE" | grep -q .; then
 		if grep -q origin "$XLOCATE_GIT/config"; then
 			echo "xlocate: database outdated, please run xlocate -S." 1>&2
 		else