Add git-config option to set rsync put flags
authorTravis Chen <travis.chen@everchanging.dev>
Sat, 8 Feb 2020 19:46:30 +0000 (11:46 -0800)
committerSean Whitton <spwhitton@spwhitton.name>
Sun, 9 Feb 2020 02:16:48 +0000 (19:16 -0700)
Provide the ability to pass flags to `rsync` when uploading.

There are two ways to set the configuration:

- `gcrypt.rsync-put-flags`
- `remote.<name>.gcrypt-rsync-put-flags`

The flags will be applied to `rsync` during uploading when using the `rsync://`
backend. If `remote.<name>.gcrypt-rsync-put-flags` is set, the flags set in
`gcrypt.rsync-put-flags` will not be applied to the remote `<name>`.

This change also includes documentation.

We have tested with the following configurations:

1. none set
2. `git config gcrypt.rsync-put-flags "--perms --chmod=g+rX"`
3. `git config remote.<name>.rsync-put-flags "--perms --chmod=o+rX"`
4. both (2) and (3)

All local files start with only owner permissions set, and umask is set to 077.
In (1), no change in behavior as before, as expected. In (2), the remote files
have the group permissions set, as expected. In (3), the remote files have the
other permissions set, as expected. In (4), the remote files have the other
permissions set, but do not have the group permissions set, as expected.

Signed-off-by: Travis Chen <travis.chen@everchanging.dev>
README.rst
git-remote-gcrypt

index 1bfbdaf98d1be7b29010e49ae0cba2235310c8e2..902e15f4cffa5e49ae4d28cbc23c299ea72727d9 100644 (file)
@@ -89,6 +89,13 @@ The following ``git-config(1)`` variables are supported:
     part of the participant list. You may use the per-remote version
     to sign different remotes using different keys.
 
+``remote.<name>.gcrypt-rsync-put-flags``
+    ..
+``gcrypt.rsync-put-flags``
+    Flags to be passed to ``rsync`` when uploading to a remote using the
+    ``rsync://`` backend. If the flags are set to a specific remote, the
+    global flags, if also set, will not be applied for that remote.
+
 Environment variables
 =====================
 
index dcdec7517232393dbd4596772a47ace58b322c39..689e025a646e4618231658534692b113b8998323 100755 (executable)
@@ -249,7 +249,7 @@ PUT()
                curl -s -S -k --ftp-create-dirs -T "$3" "$1/$2"
        elif isurl rsync "$1"
        then
-               rsync -I -W "$3" "${1#rsync://}"/"$2" >&2
+               rsync $Conf_rsync_put_flags -I -W "$3" "${1#rsync://}"/"$2" >&2
        elif isurl rclone "$1"
        then
                rclone copyto "$3" "${1#rclone://}"/"$2" >&2
@@ -280,7 +280,8 @@ PUTREPO()
                :
        elif isurl rsync "$1"
        then
-               rsync -q -r --exclude='*' "$Localdir/" "${1#rsync://}" >&2
+               rsync $Conf_rsync_put_flags -q -r --exclude='*' \
+                       "$Localdir/" "${1#rsync://}" >&2
        elif isurl rclone "$1"
        then
                rclone mkdir "${1#rclone://}" >&2
@@ -429,6 +430,8 @@ read_config()
        Conf_pubish_participants=$(git config --get --bool "remote.$NAME.gcrypt-publish-participants" '.+' ||
                git config --get --bool gcrypt.publish-participants || :)
        Conf_gpg_args=$(git config --get gcrypt.gpg-args '.+' || :)
+       Conf_rsync_put_flags=$(git config --get "remote.$NAME.gcrypt-rsync-put-flags" '.+' ||
+               git config --get "gcrypt.rsync-put-flags" '.+' || :)
 
        # Figure out which keys we should encrypt to or accept signatures from
        if isnull "$conf_part" || iseq "$conf_part" simple