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 8e6a17e350e3dff0eae745c6fb7210260622d617
parent d7203b82a09e48ec3f81a73471edf3f4e240085d
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Sat,  2 Dec 2023 15:32:41 +0100

Rewriting the push sub-command

This new implementation calls the rsync command only once for files read
from standard input. This is both more efficient and more elegant in
terms of shell practice.

Diffstat:
Mgit-wad | 17+++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/git-wad b/git-wad @@ -156,6 +156,12 @@ wad_objects() # [--all] | sed "s/^${GIT_WAD_HEADER} \([0-9a-z]\{64\}\) [0-9]\{1,\}$/\1/" } +objects_to_push() # [--all] +{ + wad_objects "$@" | xargs -I {} sh -c \ + "if [ -f \"${GIT_WAD_OBJDIR}/{}\" ]; then echo \"{}\"; fi" +} + ######################################################################## # Sub commands ######################################################################## @@ -178,14 +184,9 @@ push() # [--all] return 1 fi - wad_objects "$@" | while read -r i; do - object="${GIT_WAD_OBJDIR}/${i}" - if [ -f "${object}" ]; then - rsync -av --progress --ignore-existing "${object}" \ - "${GIT_WAD_REMOTE_PUSH}" - fi - done - log "Pushed to %s\n" "${GIT_WAD_REMOTE_PUSH}" + log "Pushing to %s\n" "${GIT_WAD_REMOTE_PUSH}" + objects_to_push "$@" | rsync -av --progress --ignore-existing \ + --files-from=- "${GIT_WAD_OBJDIR}" "${GIT_WAD_REMOTE_PUSH}" } ########################################################################