3 #==============================================================================
5 # File ID: 6317a006-78d9-11ea-8dd3-4f45262dc9b5
7 # Author: Øyvind A. Holm <sunny@sunbase.org>
8 # License: GNU General Public License version 2 or later.
9 #==============================================================================
16 opt_block_size
=$std_block_size
22 while test -n "$1"; do
24 -b|
--block-size) opt_block_size
="$2"; shift 2 ;;
25 -h|
--help) opt_help
=1; shift ;;
26 -o|
--old-file) opt_old_file
="$2"; shift 2 ;;
27 -q|
--quiet) opt_quiet
=$
(($opt_quiet + 1)); shift ;;
28 -v|
--verbose) opt_verbose
=$
(($opt_verbose + 1)); shift ;;
29 -w|
--whole) opt_whole
=1; shift ;;
30 --version) echo $progname $VERSION; exit 0 ;;
33 if printf '%s\n' "$1" |
grep -q ^
-; then
34 echo "$progname: $1: Unknown option" >&2
42 opt_verbose
=$
(($opt_verbose - $opt_quiet))
44 if test "$opt_help" = "1"; then
45 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
48 Create a rdiff(1) file with differences between the previous and
49 current version of a file stored in git-annex.
51 Usage: $progname [options] ANNEX_FILE RDIFF_FILE
55 -b SIZE, --block-size SIZE
56 Use SIZE as block size with "rdiff signature". Smaller size may
57 create a smaller rdiff file, but takes longer time.
58 Default value: $std_block_size
61 -o FILE, --old-file FILE
62 Use FILE instead of previous version as base for the patch.
64 Be more quiet. Can be repeated to increase silence.
66 Increase level of verbosity. Can be repeated.
68 Create rdiff patch for the whole file against /dev/null if no
69 previous version of the file was found.
71 Print version information.
73 For example, to create rdiff files for all files in the current
76 \$ git annex find | while read f; do ga-rdiff "\$f" "\$f.rdiff"; done
78 Does not work with files renamed or moved in the newest revision.
85 local src
="$1" dest
="$2"
87 repotop
="$(git rev-parse --show-toplevel)"
88 if [ -z "$repotop" ]; then
89 echo "$progname: Could not find top of Git repo" >&2
93 local currfile
="$(realpath -e "$src")"
94 if [ -z "$currfile" ]; then
95 echo -n "$progname: $src: " >&2
96 echo "Could not find annex data for current revision" >&2
100 local prevfile
="$opt_old_file"
101 if [ -z "$opt_old_file" ]; then
102 prevfile
="$(git log -1 -p --color=never "$src" \
104 | grep -F .git/annex/objects/ \
105 | sed 's/^.*\.git/.git/')"
106 prevfile
="$(cd "$repotop" && test -e "$prevfile" \
107 && realpath -e "$prevfile")"
108 if [ -z "$prevfile" ]; then
109 if [ "$opt_whole" = "1" ]; then
112 echo -n "$progname: $src: Could not find " >&2
113 echo "annex data for previous revision" >&2
119 rdiff
-b $opt_block_size signature
"$prevfile" \
120 | rdiff delta
- "$currfile" "$dest"
124 echo "$progname: Need src and dest command line arguments" >&2
128 create_rdiff
"$1" "$2"
130 # vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 :