3 #=======================================================================
5 # File ID: 8ccdcd38-f1c3-11e3-96ba-c80aa9e67bbd
7 # Read filenames from stdin and store the git-annex key to
8 # /kopiert-annex/$1. For documenting where I got files from or who I've
9 # given a copy to. If all copies should be destroyed (FSM forbid) I know
10 # where to get another copy. Example:
12 # ls | ga-other Some_Bloke
13 # find -type l | ga-other Another_Bloke
15 # Author: Øyvind A. Holm <sunny@sunbase.org>
16 # License: GNU General Public License version 2 or later.
17 #=======================================================================
31 " -n "$progname" -- "$@
")"
32 test "$?" = "0" ||
exit 1
40 -h|
--help) opt_help
=1; shift ;;
41 -q|
--quiet) opt_quiet
=$
(($opt_quiet + 1)); shift ;;
42 -v|
--verbose) opt_verbose
=$
(($opt_verbose + 1)); shift ;;
43 --version) echo $progname $VERSION; exit 0 ;;
45 *) echo $progname: Internal error
>&2; exit 1 ;;
48 opt_verbose
=$
(($opt_verbose - $opt_quiet))
50 if test "$opt_help" = "1"; then
51 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
54 Read filenames from stdin and store the git-annex key to
55 /kopiert-annex/$1. For documenting where I got files from or who I've
56 given a copy to. If all copies should be destroyed (FSM forbid) I know
57 where to get another copy. Example:
59 ls | ga-other Some_Bloke
60 find -type l | ga-other Another_Bloke
62 Usage: $progname [options]
69 Be more quiet. Can be repeated to increase silence.
71 Increase level of verbosity. Can be repeated.
73 Print version information.
79 test -z "$1" && { echo $progname: Name not specified
>&2; exit 1; }
80 topdir
="$(git rev-parse --show-toplevel)"
81 kopidir
="$topdir/kopiert-annex"
82 test -d "$kopidir" || mkdir
"$kopidir" || \
83 { echo $progname: $kopidir: Cannot create directory
>&2; exit 1; }
85 destfile
="$kopidir/$filename"
88 key
=$
(git annex lookupkey
"$f")
89 test -n "$key" && echo "$key" >>"$destfile"
92 sort -u "$destfile" >"$destfile.tmp"
93 mv "$destfile.tmp" "$destfile"