Meta/post-applypatch: use bidirectional notes mapping in amlog

todo
Junio C Hamano 2012-09-27 18:20:39 -07:00
parent 4781a1f7de
commit 0c49ca3332
2 changed files with 24 additions and 5 deletions

17
amlook
View File

@ -5,8 +5,19 @@
# 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...
@ -15,11 +26,13 @@ find_commit () {
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

View File

@ -22,7 +22,7 @@ message_id=$(sed -ne '
}
# 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
@ -36,6 +36,8 @@ message_id=$(sed -ne '
# 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") &&

@ -43,7 +45,11 @@ if test -n "$message_id" &&
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