summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--README2
-rwxr-xr-xxlocate14
2 files changed, 14 insertions, 2 deletions
diff --git a/README b/README
index 15a4cd3..ee64b87 100644
--- a/README
+++ b/README
@@ -21,7 +21,7 @@ https://github.com/voidlinux/xbps
   xilog [PATTERN] - list installed packages by install-date
   xlg PKG - open short commit log for XBPS template
   xlint TEMPLATE - scan XBPS template for common mistakes
-  xlocate [-u | -g | PATTERN] - locate files in all XBPS packages
+  xlocate [-u | -g | -S | PATTERN] - locate files in all XBPS packages
   xlog PKG - open commit log for XBPS template
   xls PKGS... - list files contained in PKGS (including binpkgs)
   xmandoc MANPAGE - read manpage of possibly not installed package
diff --git a/xlocate b/xlocate
index 255ca8f..cbfbfe4 100755
--- a/xlocate
+++ b/xlocate
@@ -1,8 +1,9 @@
 #!/bin/sh
-# xlocate [-u | -g | PATTERN] - locate files in all XBPS packages
+# xlocate [-u | -g | -S | PATTERN] - locate files in all XBPS packages
 
 : ${XLOCATE_DB:=~/.cache/xlocate.db}
 : ${XLOCATE_GIT:=~/.cache/xlocate.git}
+: ${XLOCATE_REPO:=https://repo.voidlinux.eu/xlocate/xlocate.git}
 
 if command -v pv >/dev/null; then
 	PROGRESS="pv -l"
@@ -45,12 +46,23 @@ xupdategit() {
 	rm -rf "$DIR"
 }
 
+xsyncgit() {
+	if [ -d "$XLOCATE_GIT" ]; then
+		git -C "$XLOCATE_GIT" fetch -u -f "$XLOCATE_REPO" master:master
+	else
+		git clone --bare "$XLOCATE_REPO" "$XLOCATE_GIT"
+	fi
+}
+
 if [ "$1" = -u ]; then
 	xupdatedb
 	exit $?
 elif [ "$1" = -g ]; then
 	xupdategit
 	exit $?
+elif [ "$1" = -S ]; then
+	xsyncgit
+	exit $?
 fi
 
 if [ -d "$XLOCATE_GIT" ]; then