summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mirror.17
-rw-r--r--mirror.sh9
2 files changed, 11 insertions, 5 deletions
diff --git a/mirror.1 b/mirror.1
index 361f256..a19da7c 100644
--- a/mirror.1
+++ b/mirror.1
@@ -3,13 +3,14 @@
mirror \- copies remote git repositories in bulk
.SH SYNOPSIS
.SY mirror
+.RB [ -n ]
.RI [ repositories ]
.SY mirror\ -v
.YS
.SH DESCRIPTION
This script will read
.I repositories
-file for paths or addresses to git repositories, clone them in a bare mirror mode or update existing mirrors as
+file for paths or addresses to git repositories and clone them in a bare mirror mode or update existing mirrors as
necessary. If not provided
.I repositories
will default to
@@ -17,6 +18,10 @@ will default to
in the current working directory.
.P
With
+.B -n
+option the script will only print actions it would perform and not attempt any updates.
+.P
+With
.B -v
option the script will print version information to standard output and terminate immediately after.
.SH EXIT STATUS
diff --git a/mirror.sh b/mirror.sh
index 88ed524..118d2a4 100644
--- a/mirror.sh
+++ b/mirror.sh
@@ -6,7 +6,7 @@ _version() {
_usage() {
- echo "Usage: $0 [-v] [repositories]"
+ echo "Usage: $0 [-vn] [repositories]"
exit 1
} >&2
@@ -53,17 +53,18 @@ _update() {
local path="$(_path ${repo})"
test -d "${path}" || git clone -q --mirror "${repo}" "${path}" || return 1 # TODO: Check if remotes are the same?
if git -C "${path}" fetch -q; then
- echo "Updated ${path}"
+ echo "Updated: ${path}"
else
- echo "Failed to update ${path}" >&2
+ echo "Failed to update: ${path}" >&2
return 1
fi
}
-while getopts :v opt; do
+while getopts :vn opt; do
case ${opt} in
v) _version;;
+ n) _update() { echo "Would update: $(_path $1)"; };;
?) _usage;;
esac
done