3 # This is experiment on http://revctrl.org/NeutralInterface, implementing
11 # Take a field name as an argument and check in the $interesting[] array
12 # whether we should output it.
14 [ "${interesting[0]}" = '*' ] && return 0
15 for field
in "${interesting[@]}"; do
16 [ "$field" = "$1" ] && return 0
22 if [ ! "$1" ] ||
[ "$1" = "-h" ] ||
[ "$1" = "--help" ]; then
23 die http
://revctrl.org
/NeutralInterface
27 if [ "$1" = "-s" ]; then
28 shift; interesting
=(${1//,/ }); shift
31 cmd
="$1"; shift; args
=("$@");
33 [ "$cmd" = "-i" ] && interactive
=1
36 if [ "$cmd" = "-i" ]; then
39 elif [ "$cmd" = "version" ]; then
40 interesting
"version" && echo "version:1:0"
42 elif [ "$cmd" = "identify" ]; then
43 interesting
"type" && echo "type:3:git"
45 elif [ "$cmd" = "changeset" ]; then
46 [ "${args[0]}" ] || die
"missing changeset id"
47 commit
="$(git-rev-parse --verify "${args[0]}")" || die
"bad changeset id"
48 interesting
"identifier" && echo "identifier:40:$commit"
50 interesting
"parent" &&
51 for parent
in $
(git-rev-parse
--verify "$commit"^
); do
52 echo "parent:40:$parent"
56 grep -r -l "$commit" ${GIT_DIR:-.git}/refs
/tags |
57 while IFS
=$
'\n' read tag
; do
59 echo "tag:${#tag}:$tag"
62 # FIXME: doesn't handle filenames containing newlines
64 echo $commit $
(git-rev-parse
--verify "$commit"^
) |
65 git-diff-tree
-r -m --stdin |
grep ^
: | cut
-f 2- |
66 while IFS
=$
'\n' read file; do
67 echo "file:${#file}:$file"
70 if interesting
"user" || interesting
"date"; then
71 author
="$(git-cat-file commit "$commit" | sed -n 's/^author //p;/^$/q')"
73 if interesting
"user"; then
74 user
="$(echo "$author" | sed 's/\([^<]* <[^>]*>\).*/\1/')"
75 echo user
:${#user}:"$user"
78 if interesting
"date"; then
79 date="$(echo "$author" | sed 's/[^<]* <[^>]*> \(.*\)/\1/')"
80 echo date:${#date}:"$date"
84 if interesting
"description"; then
85 desc
="$(git-cat-file commit "$commit" | sed -n '/^$/{:a n;p;b a}')"
86 echo description
:${#desc}:"$desc"
94 if [ "$interactive" ]; then
95 echo # terminate output
99 if [ "$cmdname" != "$cmd" ]; then
101 interesting
=(${fields//,/ })
107 # do with bash, I guess.
112 while [ "${#argval}" -lt "$arglen" ]; do
113 IFS
=$
'\n' read argvalmore
117 [ "${#argval}" -gt "$arglen" ] &&
118 die
"announced value length ($arglen) doesn't match what I really snapped (${#argval})"
119 args
[${#args[@]}]=${arg#*:}