aboutsummaryrefslogtreecommitdiffhomepage
path: root/git-remote-gcrypt
diff options
context:
space:
mode:
authorJoey Hess <id@joeyh.name>2021-01-20 11:23:01 -0400
committerSean Whitton <spwhitton@spwhitton.name>2021-01-20 13:25:58 -0700
commit3b69f816c9c371e935544b87cf2f321fdd795486 (patch)
treefc7cb25d717ae9c87a8fe7009a38c769119dce5a /git-remote-gcrypt
parentde7db5f9e6a10110ef3bb06935f6ea4c8b05726c (diff)
downloadgit-remote-gcrypt-3b69f816c9c371e935544b87cf2f321fdd795486.tar.gz
support more standard rsync URIs
This adds support for "rsync://user@host/path", which is a valid URI, and will be parseable by URI parsers, unlike the old "rsync://user@host:path", which at least some URI parsers will reject due to the ":path" looking like an unparseable port number. The old nonstandard URI form is also still accepted. Note that, the path in the new URI form is not relative to the home directory, but absolute. This is necessary because "/path" looks like an absolute directory, and there needs to be a way to specify an absolute directory. Something like "/~/path" could be added to specify the home directory, but seems like an unncessary complication. Note that rsync supports rsync:// URIs itself, but those communicate with a rsync daemon on its own port, rather than via ssh. gcrypt already was using rsync:// to denote rsync over ssh, and this does not change that. So, the url has to be rewritten from "rsync://user@host/path" to the rsync location "user@host:/path" I used this test suite while developing the rather complicated sed expression, to make sure I did not break handling of the old URI form. set -e test $(rsynclocation "rsync://host/path/foo") = host:/path/foo test $(rsynclocation "rsync://host:path/foo") = host:path/foo test $(rsynclocation "rsync://user@host/path/foo") = user@host:/path/foo test $(rsynclocation "rsync://user@host:path/foo") = user@host:path/foo test $(rsynclocation "rsync://user@host/path:foo") = user@host:/path:foo test $(rsynclocation "rsync://user@host:path:foo") = user@host:path:foo test $(rsynclocation "rsync://user@host/path:foo/bar") = user@host:/path:foo/bar test $(rsynclocation "rsync://user@host:path:foo/bar") = user@host:path:foo/bar test $(rsynclocation "rsync://user@host/path/foo/bar") = user@host:/path/foo/bar test $(rsynclocation "rsync://user@host:path/foo/bar") = user@host:path/foo/bar Signed-off-by: Joey Hess <id@joeyh.name>
Diffstat (limited to 'git-remote-gcrypt')
-rwxr-xr-xgit-remote-gcrypt14
1 files changed, 10 insertions, 4 deletions
diff --git a/git-remote-gcrypt b/git-remote-gcrypt
index 5c15b60..c519bf8 100755
--- a/git-remote-gcrypt
+++ b/git-remote-gcrypt
@@ -149,6 +149,12 @@ line_count()
xecho "$#"
}
+# Convert URI in standard or nonstandard form to rsync's user@host:path
+rsynclocation ()
+{
+ echo "${1#rsync://}" | sed 's/\(^[^:/]*\)\//\1:\//'
+}
+
## gitception part
# Fetch giturl $1, file $2
@@ -229,7 +235,7 @@ GET()
(exec 0>&-; curl -s -S -k "$1/$2") > "$3"
elif isurl rsync "$1"
then
- (exec 0>&-; rsync -I -W "${1#rsync://}"/"$2" "$3" >&2)
+ (exec 0>&-; rsync -I -W "$(rsynclocation "$1")"/"$2" "$3" >&2)
elif isurl rclone "$1"
then
(exec 0>&-; rclone copyto "${1#rclone://}"/"$2" "$3" >&2)
@@ -249,7 +255,7 @@ PUT()
curl -s -S -k --ftp-create-dirs -T "$3" "$1/$2"
elif isurl rsync "$1"
then
- rsync $Conf_rsync_put_flags -I -W "$3" "${1#rsync://}"/"$2" >&2
+ rsync $Conf_rsync_put_flags -I -W "$3" "$(rsynclocation "$1")"/"$2" >&2
elif isurl rclone "$1"
then
rclone copyto "$3" "${1#rclone://}"/"$2" >&2
@@ -281,7 +287,7 @@ PUTREPO()
elif isurl rsync "$1"
then
rsync $Conf_rsync_put_flags -q -r --exclude='*' \
- "$Localdir/" "${1#rsync://}" >&2
+ "$Localdir/" "$(rsynclocation "$1")" >&2
elif isurl rclone "$1"
then
rclone mkdir "${1#rclone://}" >&2
@@ -304,7 +310,7 @@ REMOVE()
elif isurl rsync "$1"
then
xfeed "$2" rsync -I -W -v -r --delete --include-from=- \
- --exclude='*' "$Localdir"/ "${1#rsync://}/" >&2
+ --exclude='*' "$Localdir"/ "$(rsynclocation "$1")/" >&2
elif isurl rclone "$1"
then
xfeed "$2" rclone delete -v --include-from=/dev/stdin "${1#rclone://}/" >&2