git-mktag: be more careful in reading the input.
[git/repo.git] / git-deltafy-script
blobf63cf075ec3f350036c7654606424b5be5a2abbb
1 #!/bin/bash
3 # Script to deltafy an entire GIT repository based on the commit list.
4 # The most recent version of a file is the reference and previous versions
5 # are made delta against the best earlier version available. And so on for
6 # successive versions going back in time. This way the delta overhead is
7 # pushed towards older version of any given file.
9 # NOTE: the "best earlier version" is not implemented in mkdelta yet
10 # and therefore only the next eariler version is used at this time.
12 # TODO: deltafy tree objects as well.
14 # The -d argument allows to provide a limit on the delta chain depth.
15 # If 0 is passed then everything is undeltafied.
17 set -e
19 depth=
20 [ "$1" == "-d" ] && depth="--max-depth=$2" && shift 2
22 curr_file=""
24 git-rev-list HEAD |
25 git-diff-tree -r --stdin |
26 awk '/^:/ { if ($5 == "M" || $5 == "N") print $4, $6 }' |
27 LC_ALL=C sort -s -k 2 | uniq |
28 while read sha1 file; do
29 if [ "$file" == "$curr_file" ]; then
30 list="$list $sha1"
31 else
32 if [ "$list" ]; then
33 echo "Processing $curr_file"
34 echo "$head $list" | xargs git-mkdelta $depth -v
36 curr_file="$file"
37 list=""
38 head="$sha1"
40 done