]> git.phdru.name Git - git-scripts.git/commitdiff
Add `run-bare-repos`: run a command over all bare repositories
authorOleg Broytman <phd@phdru.name>
Fri, 17 Apr 2020 15:41:21 +0000 (18:41 +0300)
committerOleg Broytman <phd@phdru.name>
Fri, 17 Apr 2020 15:41:21 +0000 (18:41 +0300)
run-bare-repos [new file with mode: 0755]

diff --git a/run-bare-repos b/run-bare-repos
new file mode 100755 (executable)
index 0000000..9f667ce
--- /dev/null
@@ -0,0 +1,18 @@
+#! /bin/sh
+
+cd "`dirname \"$0\"`" &&
+prog_dir="`pwd`" &&
+export prog_dir
+
+if [ "$1" = "-v" ]; then
+   verbose=1
+   shift
+fi
+
+cat "$prog_dir"/locate-all.list |
+while read d; do
+   if ! test -d "$d"; then echo "No such dir: $d" >&2; continue; fi
+   if test -d "$d/.git"; then continue; fi # Skip non-bare repos
+   if [ "$verbose" = 1 ]; then echo "$d"; fi
+   cd "$d" && "$@" < /dev/tty || exit 1
+done