Lib/unicode/: Add all files from <ftp://ftp.unicode.org/Public/12.1.0/>
[sunny256-utils.git] / ga-getnew
blob829067a32c25ab51df903b2a1eb4a239a4825cd9
1 #!/usr/bin/env bash
3 #=======================================================================
4 # ga-getnew
5 # File ID: 8af4d956-f358-11e4-b717-000df06acc56
7 # Get new files from the last month (can be overridden) that haven't got
8 # enough copies in git-annex yet, then optionally execute a fast fsck to
9 # check that the files have enough copies.
11 # Author: Øyvind A. Holm <sunny@sunbase.org>
12 # License: GNU General Public License version 2 or later.
13 #=======================================================================
15 progname=ga-getnew
16 VERSION=0.5.1
18 ARGS="$(getopt -o "\
23 " -l "\
24 from:,\
25 fsck,\
26 help,\
27 quiet,\
28 resume,\
29 verbose,\
30 version,\
31 " -n "$progname" -- "$@")"
32 test "$?" = "0" || exit 1
33 eval set -- "$ARGS"
35 opt_from=''
36 opt_fsck=0
37 opt_help=0
38 opt_quiet=0
39 opt_resume=0
40 opt_verbose=0
41 while :; do
42 case "$1" in
43 --from) opt_from="$2"; shift 2 ;;
44 --fsck) opt_fsck=1; shift ;;
45 -h|--help) opt_help=1; shift ;;
46 -q|--quiet) opt_quiet=$(($opt_quiet + 1)); shift ;;
47 -r|--resume) opt_resume=1; shift ;;
48 -v|--verbose) opt_verbose=$(($opt_verbose + 1)); shift ;;
49 --version) echo $progname $VERSION; exit 0 ;;
50 --) shift; break ;;
51 *) echo $progname: Internal error >&2; exit 1 ;;
52 esac
53 done
54 opt_verbose=$(($opt_verbose - $opt_quiet))
56 if test "$opt_help" = "1"; then
57 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
58 cat <<END
60 Get new files from the last month (can be overridden) that haven't got
61 enough copies in git-annex yet, then optionally execute a fast fsck to
62 check that the files have enough copies.
64 Arguments and options after " -- " are delivered to git-allfiles(1)
65 which delivers them further to "git log".
67 Usage: $progname [options] [ -- options_to_git-allfiles ]
69 Options:
71 --from REMOTE
72 Get new files from Git remote REMOTE.
73 --fsck
74 Execute "ga fsck" after the files are copied.
75 -h, --help
76 Show this help.
77 -q, --quiet
78 Be more quiet. Can be repeated to increase silence.
79 -r, --resume
80 Don't execute an initial "ga sync", resume an earlier interrupted
81 session.
82 -v, --verbose
83 Increase level of verbosity. Can be repeated.
84 --version
85 Print version information.
87 END
88 exit 0
91 msg() {
92 echo
93 echo ==== $progname: $*
96 toplevel="$(git rev-parse --show-toplevel)"
97 cd "$toplevel" || {
98 echo $progname: $toplevel: Cannot chdir to top of repo >&2
99 exit 1
102 if test "$opt_resume" != "1"; then
103 # Using backslash before { and } to suppress folding when editing this
104 # file.
105 msg ga sync \{\{\{
106 ga sync 2>&1
107 echo $progname: ga sync \}\}\}
110 if test -n "$opt_from"; then
111 from_str=" --from=$opt_from"
112 else
113 from_str=''
116 msg git allfiles --since=1.month $*
117 msg ga get --auto$from_str
118 git allfiles --since=1.month "$@" |
119 strip-nonexisting |
120 xargs -d \\n --no-run-if-empty ga get --auto$from_str
122 if test "$opt_fsck" = "1"; then
123 msg ga fsck --fast --quiet
124 git allfiles --since=1.month "$@" |
125 strip-nonexisting |
126 xargs -d \\n --no-run-if-empty ga fsck --fast --quiet
129 msg ga sync \{\{\{
130 ga sync 2>&1
131 echo $progname: ga sync \}\}\}