3 USAGE
="(edit | show) [commit]"
11 test -z "$GIT_NOTES_REF" && GIT_NOTES_REF
="$(git config core.notesref)"
12 test -z "$GIT_NOTES_REF" && GIT_NOTES_REF
="refs/notes/commits"
14 COMMIT
=$
(git rev-parse
--verify --default HEAD
"$@") ||
15 die
"Invalid commit: $@"
17 MESSAGE
="$GIT_DIR"/new-notes-
$COMMIT
19 test -f "$MESSAGE" && rm "$MESSAGE"
24 GIT_NOTES_REF
= git log
-1 $COMMIT |
sed "s/^/#/" > "$MESSAGE"
26 GIT_INDEX_FILE
="$MESSAGE".idx
29 CURRENT_HEAD
=$
(git show-ref
"$GIT_NOTES_REF" | cut
-f 1 -d ' ')
30 if [ -z "$CURRENT_HEAD" ]; then
33 PARENT
="-p $CURRENT_HEAD"
34 git read-tree
"$GIT_NOTES_REF" || die
"Could not read index"
35 git cat-file blob
:$COMMIT >> "$MESSAGE" 2> /dev
/null
38 ${VISUAL:-${EDITOR:-vi}} "$MESSAGE"
40 grep -v ^
# < "$MESSAGE" | git stripspace > "$MESSAGE".processed
41 mv "$MESSAGE".processed
"$MESSAGE"
42 if [ -s "$MESSAGE" ]; then
43 BLOB
=$
(git hash-object
-w "$MESSAGE") ||
44 die
"Could not write into object database"
45 git update-index
--add --cacheinfo 0644 $BLOB $COMMIT ||
46 die
"Could not write index"
48 test -z "$CURRENT_HEAD" &&
49 die
"Will not initialise with empty tree"
50 git update-index
--force-remove $COMMIT ||
51 die
"Could not update index"
54 TREE
=$
(git write-tree
) || die
"Could not write tree"
55 NEW_HEAD
=$
(echo Annotate
$COMMIT | git commit-tree
$TREE $PARENT) ||
56 die
"Could not annotate"
57 git update-ref
-m "Annotate $COMMIT" \
58 "$GIT_NOTES_REF" $NEW_HEAD $CURRENT_HEAD
61 git show
"$GIT_NOTES_REF":$COMMIT