From 0c49ca33322de12633a0329008623c009da4e987 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 27 Sep 2012 18:20:39 -0700 Subject: [PATCH] Meta/post-applypatch: use bidirectional notes mapping in amlog --- amlook | 17 +++++++++++++++-- post-applypatch | 12 +++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/amlook b/amlook index 809386b97a..0544f402ee 100755 --- a/amlook +++ b/amlook @@ -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 diff --git a/post-applypatch b/post-applypatch index 1aa18f54e5..886ad76d00 100755 --- a/post-applypatch +++ b/post-applypatch @@ -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 - -- 2.47.3