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
|
#!/bin/sh
|
||||||
|
#
|
||||||
# This script can be used to add git-annex metadata to files when they're
|
# 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>
|
# Copyright 2014 Joey Hess <id@joeyh.name>
|
||||||
# License: GPL-3+
|
# License: GPL-3+
|
||||||
|
@ -12,8 +17,6 @@ if [ -z "$want" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$want"
|
|
||||||
|
|
||||||
case "$(git config --bool metadata.overwrite || true)" in
|
case "$(git config --bool metadata.overwrite || true)" in
|
||||||
true)
|
true)
|
||||||
overwrite=1
|
overwrite=1
|
||||||
|
@ -46,7 +49,8 @@ fi
|
||||||
|
|
||||||
IFS="
|
IFS="
|
||||||
"
|
"
|
||||||
for f in $(git diff-index --name-only --cached $against); do
|
|
||||||
|
process () {
|
||||||
if [ -e "$f" ]; then
|
if [ -e "$f" ]; then
|
||||||
for l in $(extract "$f" | egrep "$want"); do
|
for l in $(extract "$f" | egrep "$want"); do
|
||||||
field="${l%% - *}"
|
field="${l%% - *}"
|
||||||
|
@ -54,4 +58,14 @@ for f in $(git diff-index --name-only --cached $against); do
|
||||||
addmeta "$f" "$field" "$value"
|
addmeta "$f" "$field" "$value"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -n "$*" ]; then
|
||||||
|
for f in $@; do
|
||||||
|
process "$f"
|
||||||
done
|
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