git-wad

Manage files via git but not their content
git clone git://git.meso-star.fr/git-wad.git
Log | Files | Refs | README | LICENSE

commit e3450f7af3f6505c4faaa1e6b8056873b29fbc3a
parent ba0b0b381f4777c0b9f5f89e95c9b2b24fe4c67a
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Sat,  2 Dec 2023 15:39:55 +0100

Add the fetch subcommand

This is the symmetry of the push subcommand. It uses rsync to transfer
data from the remote server defined in a configuration variable. Note
that it does not update the contents of WAD files. This is the task of a
specific command (checkout).

Diffstat:
Mgit-wad | 20++++++++++++++++++++
1 file changed, 20 insertions(+), 0 deletions(-)

diff --git a/git-wad b/git-wad @@ -39,6 +39,7 @@ synopsis() { >&2 printf "usage: git-wad init\n" >&2 printf " git-wad push [--all]\n" + >&2 printf " git-wad fetch [--all]\n" } log() # str [, arg...] @@ -162,6 +163,12 @@ objects_to_push() # [--all] "if [ -f \"${GIT_WAD_OBJDIR}/{}\" ]; then echo \"{}\"; fi" } +objects_to_fetch() # [--all] +{ + wad_objects "$@" | xargs -I {} sh -c \ + "if [ ! -f \"${GIT_WAD_OBJDIR}/{}\" ]; then echo \"{}\"; fi" +} + ######################################################################## # Sub commands ######################################################################## @@ -189,6 +196,18 @@ push() # [--all] --files-from=- "${GIT_WAD_OBJDIR}" "${GIT_WAD_REMOTE_PUSH}" } +fetch() # [--all] +{ + if [ -z "${GIT_WAD_REMOTE_FETCH}" ]; then + log "Remote undefined, i.e. variable GIT_WAD_REMOTE_FETCH is empty\n" + return 1 + fi + + log "Fetching from %s\n" "${GIT_WAD_REMOTE_FETCH}" + objects_to_fetch "$@" | rsync -av --progress --ignore-existing \ + --files-from=- "${GIT_WAD_REMOTE_FETCH}" "${GIT_WAD_OBJDIR}" +} + ######################################################################## # The command ######################################################################## @@ -200,6 +219,7 @@ case "${sub_cmd}" in "filter-clean") shift 1; clean "$@" ;; "filter-smudge") shift 1; smudge "$@" ;; "init") shift 1; init "$@" ;; + "fetch") shift 1; fetch "$@" ;; "push") shift 1; push "$@" ;; *) synopsis; exit 1 ;; esac