From 2b59a122223466eab3a847a5eae7f49a892de797 Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Mon, 17 Oct 2016 16:23:56 +0200 Subject: xlocate: better outdated check With packed refs, refs/heads/master isn't there, but FETCH_HEAD works well enough too. Fixes #49. --- xlocate | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'xlocate') 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 -- cgit 1.4.1