# Meta/amlook --gc
find_commit () {
- in=
- commits=$(sed -ne "s|^\([0-9a-f]\{40\}\) $1|\1|p" .git/am.log)
+ in= commits=
+
+ if test -z "$commits"
+ then
+ blob=$(echo "Message-Id: $1" | git hash-object --stdin)
+ commits=$(git notes --ref amlog show $blob | sed -e '/^$/d')
+ fi
+
+ if test -z "$commits"
+ then
+ commits=$(sed -ne "s|^\([0-9a-f]\{40\}\) $1|\1|p" .git/am.log)
+ fi
+
if test -z "$commits"
then
# I know I know there should be "notes grep" command...
sed -e 's|^notes/amlog:||' -e 's|/||g'
)
fi
+
if test -z "$commits"
then
echo "Never applied"
return
fi
+
found=$(
echo "$commits" |
while read commit
}
# Hold this new line, and look at what is in the hold space
x
- # Is it the Message-ID line? If so, spit out and finish.
+ # Is it the Message-ID line? If so, spit it out and finish.
/^[Mm][Ee][Ss][Ss][Aa][Gg][Ee]-[Ii][Dd]:[ ]*/{
s///p
q
# And start the next cycle
b
: end
+ # ??? do we want to check if we held onto the last message-id line
+ # and process it here if we did???
q
' "$dotest/$msgnum") &&
head=$(git rev-parse --verify HEAD 2>/dev/null)
then
echo "$head $message_id" >>"$GIT_DIR"/am.log &&
- GIT_NOTES_REF=refs/notes/amlog \
+ (
+ GIT_NOTES_REF=refs/notes/amlog
+ export GIT_NOTES_REF
git notes add -f -m "Message-Id: $message_id" "$head"
+ blob=$(git notes list "$head") &&
+ git notes append -m "$head" $blob
+ )
fi
-