modify so the script can be run with existing annexed files to extract their metadata
This commit is contained in:
parent
f7446a903a
commit
6a0ba7a2ad
1 changed files with 19 additions and 5 deletions
|
@ -1,6 +1,11 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# This script can be used to add git-annex metadata to files when they're
|
||||
# committed.
|
||||
# committed. It is typically installed as .git/hooks/pre-commit-annex
|
||||
#
|
||||
# You can also run this script by hand, passing it the names of files
|
||||
# already checked into git-annex, and it will extract/refresh the git-annex
|
||||
# metadata from the files.
|
||||
#
|
||||
# Copyright 2014 Joey Hess <id@joeyh.name>
|
||||
# License: GPL-3+
|
||||
|
@ -12,8 +17,6 @@ if [ -z "$want" ]; then
|
|||
exit 0
|
||||
fi
|
||||
|
||||
echo "$want"
|
||||
|
||||
case "$(git config --bool metadata.overwrite || true)" in
|
||||
true)
|
||||
overwrite=1
|
||||
|
@ -46,7 +49,8 @@ fi
|
|||
|
||||
IFS="
|
||||
"
|
||||
for f in $(git diff-index --name-only --cached $against); do
|
||||
|
||||
process () {
|
||||
if [ -e "$f" ]; then
|
||||
for l in $(extract "$f" | egrep "$want"); do
|
||||
field="${l%% - *}"
|
||||
|
@ -54,4 +58,14 @@ for f in $(git diff-index --name-only --cached $against); do
|
|||
addmeta "$f" "$field" "$value"
|
||||
done
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
if [ -n "$*" ]; then
|
||||
for f in $@; do
|
||||
process "$f"
|
||||
done
|
||||
else
|
||||
for f in $(git diff-index --name-only --cached $against); do
|
||||
process "$f"
|
||||
done
|
||||
fi
|
||||
|
|
Loading…
Add table
Reference in a new issue